Command handler.

@param   string      The command name
@param   object      The command context

@return bool Can return both true or false.
162492
public function execute($name, AnCommandContext $context)
    {
        $parts = explode('.', $name);

        //for any before if the item has been fetched
        //then try to fetch it
        if ($parts[0] == 'before') {
            return $this->_mixer->fetchEntity($context);
        }
    }
117215
public boolean handleAction (Component source, String command, Object arg)
    {
        return handleAction(new CommandEvent(source, command, arg));
    }
785334
public static function handle($object) {
		
		// checks if a JSON-RCP request has been received
		if (
			$_SERVER['REQUEST_METHOD'] != 'POST' || 
			empty($_SERVER['CONTENT_TYPE']) ||
			$_SERVER['CONTENT_TYPE'] != 'application/json'
			) {
			// This is not a JSON-RPC request
			return false;
		}
				
		// reads the input data
		$request = json_decode(file_get_contents('php://input'),true);
		
		// executes the task on local object
		try {
			if ($result = @call_user_func_array(array($object,$request['method']),$request['params'])) {
				$response = array (
									'id' => $request['id'],
									'result' => $result,
									'error' => NULL
									);
			} else {
				$response = array (
									'id' => $request['id'],
									'result' => NULL,
									'error' => 'unknown method or incorrect parameters'
									);
			}
		} catch (Exception $e) {
			$response = array (
								'id' => $request['id'],
								'result' => NULL,
								'error' => $e->getMessage()
								);
		}
		
		// output the response
		if (!empty($request['id'])) { // notifications don't want response
			header('content-type: text/javascript');
			echo json_encode($response);
		}
		
		// finish
		return true;
	}
615101
public function dispatchNow($command, $handler = null)
    {
        if ($handler || $handler = $this->getCommandHandler($command)) {
            $callback = function ($command) use ($handler) {
                return $handler->handle($command);
            };
        } else {
            $callback = function ($command) {
                return call_user_func_array([$command, 'handle'], ['kernel'=>Zilf::$container->getShare('consoleKernel')]);
            };
        }

        return $this->pipeline->send($command)->through($this->pipes)->then($callback);
    }
490203
public function getCommand($name, array $args = array()) {
    /*if($name != 'oauth') {
		  $this->checkAuth();
    }*/

    $command = parent::getCommand($name, $args);
    $this->command_history[] = $command;
		return $command;
	}
813573
public function executeCommands(array $commands, \Closure $closure = null, Process $process = null)
    {
        foreach ($commands as $command => $commandClosure) {
            $currentClosure = (null !== $commandClosure) ? $commandClosure : $closure;
            $processResult = $this->executeCommand($command, $currentClosure, $process);
            if ($processResult === -1 || $processResult === 255) {
                return false;
            }
        }

        return true;
    }
1226145
public function hasCallback($callback, $object = null)
    {
        foreach ($this->callbacks as $rawObject) {
            if ($this->callbacks[$rawObject] === $callback && ($object === null || $object === $rawObject)) {
                return true;
            }
        }

        return false;
    }
245240
public function addHandler($commandClassName, $handler)
    {
        if (!is_string($commandClassName)) {
            throw new \InvalidArgumentException('The command name should be a string');
        }

        $this->handlers[$commandClassName] = $handler;
    }
1135683
public function execute($command, $context)
    {
        if (!$context instanceof  AnCommandContext) {
            $context = new AnCommandContext($context);
        }

        $parts = explode('.', $command);
        $method = '_'.$parts[0].'Entity'.ucfirst($parts[1]);
        $result = null;

        if (method_exists($this, $method)) {
            $result = $this->$method($context);
        }

        return $result;
    }
60861
public function execute($name, AnCommandContext $context)
    {
        $result    = true;

        if (isset($this->_callbacks[$name])) {
            $callbacks = $this->_callbacks[$name];
            $params = $this->_params[$name];

            foreach ($callbacks as $key => $callback) {
                $param = $params[$key];

                if (is_array($param) && is_numeric(key($param))) {
                    $result = call_user_func_array($callback, $params);
                } else {
                    $result = call_user_func($callback, $context->append($param));
                }

                //Call the callback
                if ($result === false) {
                    break;
                }
            }
        }

        return $result === false ? false : true;
    }
192283
public function canHandle($object)
    {
        if (parent::canHandle($object) &&
            ($object instanceof Media && $object->getContentType() == 'application/pdf')
        ) {
            return true;
        }

        return false;
    }
456638
public function getCommand($name = null)
    {
        if ($name !== null) {
            return isset($this->commands[$name]) ? $this->commands[$name] : null;
        }

        return $this->command;
    }
734061
function _preCommand(commands) {
  commander.on('--help', function () {

    var hasExample = _.map(_.values(commands), 'examples')
      .filter(function (elem) {
        return elem !== undefined;
      });
    if (hasExample.length > 0) {
      hasExample = hasExample.reduce(function (a, b) {
        return a.concat(b);
      });
    }
    hasExample = hasExample.length > 0;

    if (hasExample) {

      console.log('  Examples:\n');

      Object.keys(commands).forEach(function (command) {
        if (!_.isEmpty(commands[command].examples)) {
          console.log('    %s:', command);
          commands[command].examples.forEach(function (example) {
            console.log('      %s', example);
          });
        }
      });
    }
  });
}
394113
function (name) {
    if (!name || !_.isString(name)) {
      var err = new Error('Please pass a valid string as name!');
      debug(err);
      throw err;
    }

    return _.filter(this.commands, function (cmd) {
      return cmd.name === name;
    });
  }
1122783
protected function onLoaderHandler($object) {
        $ex = explode('\\',$object);
        $count = count($ex);
        switch (true) {
            case isset($this->namespace[$ex[0]]):
                $path = str_replace($ex[0], $this->namespace[$ex[0]], $object).'.php';
                $path = str_replace('\\', '/', $path);
                $first = substr( $path, 0, 1 );
                if($first !== '/') {
                    $path = __APP__.$path;
                }
                break;
            case $ex[0]=='nb':
                $path = str_replace('nb\\', __NB__, $object).'.php';
                $path = str_replace('\\', '/', $path);
                break;
            case $count == 2:
                $path = __APP__.$this->folder_app.'/'.$ex[0].'/'.$ex[1].'.php';
                if(is_file($path) ) {
                    return include $path;
                }
            default:
                $path = __APP__.str_replace('\\', '/', $object).'.php';
                break;
        }
        is_file($path) and include($path);
    }
1156020
public function handle($object, $fromDatabase = true)
    {
        if (!$this->entityStates->contains($object)) {
            $this->createState($object, $fromDatabase);
        }

        return $object;
    }
741432
public function command($name, $command)
    {
        /** @var AbstractCommand $command */
        $command = is_string($command) ? new $command() : $command;
        $command->setContainer($this->container);

        // Set name
        $namespace = $this->config->get('application_name');
        $name = $name ?: $command->getName();
        $command->setName($namespace.':'.$name);

        $this->console->add($command);

        return $command;
    }