Zephir\Commands\CommandAbstract::execute PHP Method

execute() public method

Executes the command
public execute ( Zephir\Config $config, Zephir\Logger $logger )
$config Zephir\Config
$logger Zephir\Logger
    public function execute(Config $config, Logger $logger)
    {
        $params = $this->parseArguments();
        $backend = null;
        if (!isset($params['backend'])) {
            $params['backend'] = BaseBackend::getActiveBackend();
        }
        $className = 'Zephir\\Backends\\' . $params['backend'] . '\\Backend';
        if (!class_exists($className)) {
            throw new \InvalidArgumentException('Backend ' . $params['backend'] . ' does not exist');
        }
        $backend = new $className($config);
        $compiler = new Compiler($config, $logger, $backend);
        if (isset($params['parser-compiled'])) {
            if ($params['parser-compiled'] !== 'force') {
                $compiler->parserCompiled = true;
            } else {
                $compiler->parserCompiled = 'force';
            }
        }
        $command = $this->getCommand();
        $compiler->{$command}($this);
    }

Usage Example

示例#1
0
 public function execute(Config $config, Logger $logger)
 {
     if (isset($_SERVER['argv'][2])) {
         $this->setParameter('namespace', strtolower(preg_replace('/[^0-9a-zA-Z]/', '', $_SERVER['argv'][2])));
     }
     parent::execute($config, $logger);
 }
All Usage Examples Of Zephir\Commands\CommandAbstract::execute