@param       $command
@param array $args

@throws \Doctrine\ORM\NoResultException
@throws \Doctrine\ORM\NonUniqueResultException

@return Job|mixed
515346
public function getOrCreateIfNotExists($command, array $args = [])
    {
        if (null !== $job = $this->findJob($command, $args)) {
            return $job;
        }

        $job = new Job($command, $args, false);
        $this->_em->persist($job);
        $this->_em->flush($job);

        $firstJob = $this->_em->createQuery('SELECT j FROM JMSJobQueueBundle:Job j WHERE j.command = :command AND j.args = :args ORDER BY j.id ASC')
            ->setParameter('command', $command)
            ->setParameter('args', $args, 'json_array')
            ->setMaxResults(1)
            ->getSingleResult();

        if ($firstJob === $job) {
            $job->setState(Job::STATE_PENDING);
            $this->_em->persist($job);
            $this->_em->flush($job);

            return $job;
        }

        $this->_em->remove($job);
        $this->_em->flush($job);

        return $firstJob;
    }
39388
protected function triggerCommand($command, $arguments = null)
    {
        return $this->getCommandBus()->execute($command, $arguments ?: $this->arguments, $this->update);
    }
301137
public function runCommand(Command $command, array $parameters = [], OutputInterface $output = null)
    {
        $parameters['command'] = $command->getName();
        $input = new ArrayInput($parameters);

        if ($output === null) {
            $output = new NullOutput();
        }

        $command->setApplication(new SymfonyConsoleApplication());

        return $command->run($input, $output);
    }
335587
public function execute($command, $arguments = array())
    {
        $options = $this->getOptions();
        $consoleDir = $this->getConsoleDir();

        if (null === $consoleDir) {
            return;
        }

        $argumentString = '';

        foreach ($arguments as $argument) {
            $argumentString .= escapeshellarg($argument) . ' ';
        }

        $this->executeCommand($consoleDir, $command . ' ' . $argumentString);
    }
994406
public function execute(array $args, array $options = array())
    {
        if (!count($args)) {
            throw new ConsoleException("Missing subcommand name");
        }
        
        $command = ucfirst(Utils::camelize(array_shift($args)));
        $methodName = "execute$command";
        if (!method_exists($this, $methodName)) {
            throw new ConsoleException("Command '$command' does not exist");
        }

        $method = new ReflectionMethod($this, $methodName);
        $params = Utils::computeFuncParams($method, $args, $options);
        return $method->invokeArgs($this, $params);
    }
784089
public function command($command)
    {
        if (!in_array($command, ['start', 'stop', 'restart', 'reload', 'force-reload', 'status'])) {
            throw new \InvalidArgumentException($command);
        }

        $command = 'sudo /etc/init.d/tor '.$command;
        $command = new Command($command);
        $command->execute();

        return $command;
    }
471879
public function run(array $args)
    {
        $command = (string)$args[1];
        $this->router->match($command);
        $args = array_slice($args, 2);

        return $this->router->executeCommand($args);
    }
1215204
public static function route(string $command, array $args) : void {
        $object = new static('test');
        echo "\n";
        if (method_exists(static::class, $command)) {
            $response = call_user_func_array([$object, $command], $args);
            if ($response === NULL)
                echo "SUCCESS";
            else if ($response === FALSE)
                echo "FALSE";
            else if ($response === TRUE)
                echo "TRUE";
            else {
                if (is_string($response))
                    echo $response;
                else print_r($response);
            }
        } else echo "No such method available";
        echo "\n\n";
    }
655125
final protected function callArtisanCommand($command, array $params = [])
    {
        // Default input arguments
        $inputArguments = ['NodesInstall', $command];

        // Add artisan parameters to input arguments
        if (!empty($params) && is_array($params)) {
            $inputArguments[] = implode(' ', $params);
        }

        // Execute Artisan command
        return $this->getInstaller()->getArtisan()->handle(
            new SymfonyConsoleInput($inputArguments),
            new SymfonyConsoleOutput()
        );
    }
550399
public function run(array $args = [], callable $final = null, callable $fail = null)
    {
        $result = null;

        // declare default final middleware
        if (!is_callable($final)) {
            $final = function ($command) {
                return $command;
            };
        }

        // declare default error middleware
        if (!is_callable($fail)) {
            $fail = function ($exception) {
                throw $exception;
            };
        }

        try {
            $result = $this->handle($args, $final);
        } catch (\Exception $exception) {
            $result = $this->handleError($args, $fail, $exception, $result);
        }

        return $result;
    }
986971
public function run( $args )
    {
        $this->command = $this->getCommand( $args );

        if ( NULL == $this->command )
        {
            throw new CommandException( 'Command: ' . $args[ 1 ] . ' not found' );
        }

        $this->processArgs( $this->command, $args );

        return $this->command->execute();
    }
722623
public static function build($command, array $args = []): string
    {
        $stringArgs = [];
        $realCommand = $command;

        if (count($args) > 0) {
            foreach ($args as $key => $value) {
                $value = trim($value);
                $key = trim($key);

                if (strpos($key, '-') !== 0) {
                    $key = strlen($key) === 1 ? '-' . $key : '--' . $key;
                }

                if (strlen($value) > 0) {
                    $stringArgs[] = $key . '="' . addcslashes($value, '"') . '"';
                } else {
                    $stringArgs[] = $key;
                }
            }
        }

        if (count($stringArgs)) {
            $realCommand = $command . ' ' . implode(' ', $stringArgs);
        }

        return $realCommand;
    }
961523
public function execute($command, callable $next)
    {
        if ($command instanceof QueuedCommand && !$command->isRunningInQueue())
        {
            $delay = $command->getDelay() !== null ?: $this->delay;

            $command->setRunningInQueue(true);
            $job = new QueuedJobWrapper([
                'command' => $command,
                'commandBus' => $this->commandBus
            ]);

            return $this->queue->delay($delay)->push($job);
        }

        return $next($command);
    }
235953
public function _appendClause($command, array $args = []){
		if (!empty($command)){
			$this->_segments[] = $command;
		}
		
		if (!empty($args)){
			$this->_segments[] = array_shift($args);
			
			foreach($args as $arg){
				if (is_array($arg)){
					foreach($arg as $subArg)
						$this->_bind[] = $subArg;
				} else {
					$this->_bind[] = $arg;
				}
			}
		}
		
		return $this;
	}
1009566
public function call($command, array $parameters = [], $outputBuffer = null)
    {
        [$command, $input] = $this->parseCommand($command, $parameters);

        if (! $this->has($command)) {
            throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $command));
        }

        return $this->run(
            $input, $this->lastOutput = $outputBuffer ?: new BufferedOutput
        );
    }
1120516
protected function executeCommand(Command $command, array $arguments, OutputInterface $output)
    {
        $output = clone $output;
        if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
            $output->setVerbosity($output->getVerbosity());
        } else {
            $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
        }

        return $command->run(new ArrayInput($arguments), $output);
    }
673051
protected function call($command, array $options = array())
	{
		$curl = curl_init();
		$options[CURLOPT_URL] = $this->command_url($command);
		$options[CURLOPT_RETURNTRANSFER] = TRUE;
		$options[CURLOPT_FOLLOWLOCATION] = TRUE;

		curl_setopt_array($curl, $options);

		$raw = '';

		Attempt::make(function() use ($curl, & $raw) {
			$raw = trim(curl_exec($curl));
			return curl_getinfo($curl, CURLINFO_HTTP_CODE) == 200;
		});

		$error = curl_error($curl);
		$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);

		curl_close($curl);

		if ($error)
			throw new Exception_Driver('Curl ":command" throws exception :error', array(':command' => $command, ':error' => $error));

		if ($code != 200)
			throw new Exception_Driver('Unexpected response from the panthomjs for :command: :code', array(':command' => $command, ':code' => $code));

		$result = json_decode($raw, TRUE);

		return $result;
	}