Get the pending commands for a given queue name.

@param  string  $name
@return array
548485
public function pending($name)
    {
        $length = $this->connection()->llen('commands:'.$name);

        if ($length < 1) {
            return [];
        }

        $results = $this->connection()->pipeline(function ($pipe) use ($name, $length) {
            $pipe->lrange('commands:'.$name, 0, $length - 1);

            $pipe->ltrim('commands:'.$name, $length, -1);
        });

        return collect($results[0])->map(function ($result) {
            return (object) json_decode($result, true);
        })->all();
    }
768585
protected function getProcessInfo($name)
    {
        $pidFile = $this->pidPath.'/'.$name.'.pid';
        $pid = file_exists($pidFile) ? (int) file_get_contents($pidFile) : '';
        $isRunning = false;
        if (is_numeric($pid)) {
            $isRunning = process_kill($pid, 0);
        }

        return [
            $name,
            $isRunning ? $pid : '',
            $isRunning ? 'running' : 'stopped',
            $isRunning ? date('Y-m-d H:i:s', filemtime($pidFile)) : '',
            $isRunning ? time() - filemtime($pidFile) : '',
        ];
    }
125981
public function getQueueInfo($queueName)
    {
        $result = [
            self::STATS_JOBS_READY    => $this->getJobCount($queueName, self::STATE_READY),
            self::STATS_JOBS_RESERVED => $this->getJobCount($queueName, self::STATE_RESERVED),
            self::STATS_JOBS_DELAYED  => $this->getJobCount($queueName, self::STATE_DELAYED),
            self::STATS_JOBS_BURIED   => $this->getJobCount($queueName, self::STATE_BURIED),
        ];

        $result[self::STATS_JOBS_TOTAL] = array_sum($result);
        $result[self::STATS_QUEUE_STOP] = $this->isStop($queueName);

        return $result;
    }
1337180
protected function searchCommand(string $name):array
    {
        $f = $this->fileCommand;
        $finalC = array();
        if ($f == null) {
            throw new Server500(new \ArrayObject(array("explain" =>
                "Framework Console Arguments Error : Command File is empty",
                "solution" => "Command file not be empty")));
        }
        $commands = $f->commands;

        foreach ($commands as $command => $val) {
            if ($val->type === "single") {
                if ($command == $name) {
                    return (array("name" => $command, "class" => $val->class, "desc" => $val->desc));
                }
            } elseif ($val->type === "multiple") {
                foreach ($val->args as $aval) {
                    if ($aval->name === $name) {
                        return (array("name" => $aval->name, "class" => $val->class, "desc" => $aval->desc));
                    }
                }
            } else {
                throw new Server500(new \ArrayObject(array("explain" => "Undefined command type [".$val->type."]",
                    "solution" => "Please set a valid command type [single, multiple]")));
            }
        }
        return ($finalC);
    }
571436
public static function parsePredict(string $name):array
    {
        $f = ComManager::getFileCommand();
        $meaning = [];
        if ($f == null) {
            throw new Server500(new \ArrayObject(array("explain" =>
                "Framework Predictions Error : Command File is empty",
                "solution" => "Command file cannot not be empty")));
        }
        $commands = $f->commands;

        foreach ($commands as $command => $val) {
            if ($val->type === "single") {
                if (stristr($command, $name) != false) {
                    $meaning[] = $commands;
                }
            } elseif ($val->type === "multiple") {
                foreach ($val->args as $acommand => $aval) {
                    if (stristr($aval->name, $name) != false) {
                        $meaning[] = $aval->name;
                    }
                }
            }
        }
        return ($meaning);
    }
1184263
public function stickyGet($name)
    {
        if (isset($_GET[$name])) {
            $this->sticky_get_arguments[$name] = $_GET[$name];

            return $_GET[$name];
        }
    }
805989
public function getQueue($name, $connection)
    {
        if (!isset($this->queues[$connection][$name])) {
            if (!isset($this->queues[$connection])) {
                $this->queues[$connection] = array();
            }

            $queue = new \AMQPQueue(
                $this->getChannel($connection)
            );
            $queue->setName($name);

            $this->queues[$connection][$name] = $queue;
        }

        return $this->queues[$connection][$name];
    }
1038966
public function getQueueAliasByQueueName(string $queueName): string
    {
        return is_array($this->queues)
            ? ((array_flip($this->queues)[$queueName]) ?? $queueName)
            : $queueName;
    }
857785
protected function getList($name)
    {
        if (null === ($list = $this->cache->get($name)) || !\is_array($list)) {
            return [];
        }

        return $list;
    }
886329
public function getRoles($name)
    {
        $route = $this->router->getRoutes()->getByName($name);

        // If route not exists, return NULL
        if ($route === null) {
            return null;
        }

        $roles = [];

        // Get permissions from array syntax
        $action = $route->getAction();

        if (array_key_exists('role', $action)) {
            $roles[] = $action['role'];
        }

        if (array_key_exists('roles', $action)) {
            $roles = array_merge($roles, $action['roles']);
        }

        return array_unique($roles);
    }
351560
private function doPopMessage($queueName)
    {
        $query = 'SELECT id, message FROM bernard_messages
                  WHERE queue = :queue AND visible = :visible
                  ORDER BY sentAt LIMIT 1 '.$this->connection->getDatabasePlatform()->getForUpdateSql();

        list($id, $message) = $this->connection->fetchArray($query, [
            'queue' => $queueName,
            'visible' => true,
        ]);

        if ($id) {
            $this->connection->update('bernard_messages', ['visible' => 0], compact('id'));

            return [$message, $id];
        }
    }
1033969
public function front($name)
    {
        $queue = $this->getInstance($name);
        return $queue->isEmpty() ? false : $queue->top();
    }
370905
public function getInstance($name)
    {
        if(!isset($this->data[$name]))
        {
            $this->data[$name] = new \SplQueue;
        }
        return $this->data[$name];
    }
910686
protected function _getUsedTasks($name) {
		$plugin = $this->getConfig(static::CONFIG_PLUGIN);
		if (substr($name, -4) === 'Task') {
			$className = App::className(($plugin ? $plugin . '.' : '') . $name, 'Shell/Task');
		} else {
			$className = App::className(($plugin ? $plugin . '.' : '') . $name, 'Shell');
		}
		if (!$className) {
			throw new Exception($name);
		}

		$reflection = new ReflectionClass($className);
		if ($reflection->isAbstract()) {
			return [];
		}

		try {
			/** @var \Cake\Console\Shell $object */
			$object = new $className();
			$object->loadTasks();
		} catch (Exception $e) {
			if ($this->getConfig(static::CONFIG_VERBOSE)) {
				$this->_io->warn('   Skipping shell task annotations: ' . $e->getMessage());
			}
			return [];
		} catch (\Throwable $e) {
			if ($this->getConfig(static::CONFIG_VERBOSE)) {
				$this->_io->warn('   Skipping shell task annotations: ' . $e->getMessage());
			}
			return [];
		}

		$map = $this->_invokeProperty($object, '_taskMap');
		if (!$map) {
			return [];
		}
		foreach ($map as $alias => $row) {
			$fullClass = App::className($row['class'], 'Shell/Task', 'Task');
			if (!$fullClass) {
				$this->_io->warn('   Skipping invalid task ' . $alias . ': ' . $row['class']);
				unset($map[$alias]);
				continue;
			}
			$map[$alias]['fullClass'] = $fullClass;
		}

		return $map;
	}
564468
public function getToolbarCommands($name)
    {
        $result = array();

        if ($this->_state->toolbar instanceof AnControllerToolbarAbstract) {
            $this->_state->toolbar->reset();
            $method = 'add'.ucfirst($name).'Commands';

            if (method_exists($this->_state->toolbar, $method)) {
                $this->_state->toolbar->$method();
            }

            $commands = $this->_state->toolbar->getCommands();

            foreach ($commands as $command) {
                $result[] = $command->getname();
            }
        }

        return $result;
    }
854368
public function getScheduledCommands()
    {
        $scheduledCommands = [];
        foreach ($this->console->all() as $command) {
            if ($command instanceof ScheduledCommandInterface) {
                $scheduledCommands[] = $command;
            }
        }

        return $scheduledCommands;
    }
387065
public function getTermVocabulary($name)
    {
        return isset($this->instances[$name]) ? $this->instances[$name] : null;
    }