Initialize WebDocBook environment

@param   \Composer\Script\Event $event
@param   \WebDocBook\Composer\ScriptInterface $cmd
@throws  \WebDocBook\Composer\Exception
@see     \WebDocBook\Kernel::boot()
551734
public static function init(Event $event, ScriptInterface $cmd)
    {
        if (!self::$_inited) {
            try {
                self::$_event   = $event;
                self::$_cmd     = $cmd;
                if (false===@class_exists('\WebDocBook\Filesystem\Helper')) {
                    include_once    __DIR__.'/../Filesystem/Helper.php';
                }
                if (false===@class_exists('\WebDocBook\Kernel')) {
                    include_once    __DIR__.'/../Kernel.php';
                }
                self::parseArguments();
                if (!defined(\WebDocBook\Kernel::BASEDIR_CONSTNAME)) {
                    self::parseExtra();
                }
                \WebDocBook\Kernel::boot(true);
            } catch (\Exception $e) {
                self::error($e);
            }
            self::$_inited = true;
        }
    }
2962
public function onBootstrap(EventInterface $e)
    {
        /** @var EventManagerInterface $eventManager */
        $eventManager = $e->getApplication()->getEventManager();
        $eventManager->attach(MvcEvent::EVENT_RENDER, function (MvcEvent $event) {
            /** @var HelperPluginManager $viewHelperManager */
            $viewHelperManager = $event->getApplication()->getServiceManager()->get('ViewHelperManager');
            /** @var BasePath $basePath */
            $basePath = $viewHelperManager->get('basePath');
            $viewHelperManager->get('inlineScript')->prependFile($basePath() . '/js/kmb.cache.js');
        });
    }
628337
public function initialize(Event $event) {
		$table = $event->getSubject();
		if (!in_array(get_class($table), $this->config['tableClass'])) {
			return;
		}

		$this->_setValidators($table);
	}
690871
public function commandFlags(CommandInterface $cmd, $cmdSignature)
    {
        $args = [];
        $specs = $cmd->getOptionCollection();
        /*
        '(- 1 *)--version[display version and copyright information]' \
        '(- 1 *)--help[print a short help statement]' \
        */
        foreach ($specs->options as $opt) {
            $args[] = $this->optionFlagItem($opt, $cmdSignature);
        }

        return empty($args) ? null : $args;
    }
857783
public function startup(Event $event)
    {
        $prefix = $this->_controller->request->getParam('prefix');
        if ($prefix === 'admin' && $this->_controller->Auth->user('id')) {
            $this->_setupAdminProfileNavBar();
        }
    }
472659
protected function runBuilderCommand($cmd, $className)
    {
        $count = $this->request->getVar('count') ?: 10;
        $parent = $this->request->getVar('parent');
        $parentField = $this->request->getVar('parentField') ?: "ParentID";

        try {
            $builder = MockDataBuilder::create($className);
        } catch (Exception $e) {
            echo $e->getMessage();
            die();
        }

        $builder
            ->setOnlyEmpty($this->request->getVar('onlyEmpty') === "false" ? false : true)
            ->setDownloadImages($this->request->getVar('downloadImages') === "false" ? false : true)
            ->setCount($count)
            ->setParentIdentifier($parent ?: null)
            ->setParentField($parentField)
        ;

        try {
            $builder->$cmd();
        } catch (Exception $e) {
            echo $e->getMessage()."\n\n";
            die();
        }
    }
1330717
protected static function bootLaravel(Event $event) {
        $dir = dirname($event->getComposer()->getConfig()->get('vendor-dir'));

        require $dir . '/bootstrap/autoload.php';

        /* @var $app \Illuminate\Foundation\Application */
        self::$app = require_once $dir . '/bootstrap/app.php';

        self::$kernel = $app->make(\Illuminate\Contracts\Console\Kernel::class);

        self::$kernel->bootstrap();

        self::instantiateConsoleInteraction($event);
    }
249656
public function handle(EventInterface $event)
    {

        try {
            // load the application server, naming directory and system configuration instance
            /** @var \AppserverIo\Psr\ApplicationServer\ApplicationServerInterface $applicationServer */
            $applicationServer = $this->getApplicationServer();
            /** @var \AppserverIo\Psr\Naming\NamingDirectoryInterface $namingDirectory */
            $namingDirectory = $applicationServer->getNamingDirectory();
            /** @var \AppserverIo\Psr\ApplicationServer\Configuration\SystemConfigurationInterface $systemConfiguration */
            $systemConfiguration = $applicationServer->getSystemConfiguration();

            // initialize the loggers
            $loggers = array();
            foreach ($systemConfiguration->getLoggers() as $loggerNode) {
                $loggers[$loggerNode->getName()] = LoggerFactory::factory($loggerNode);
            }

            // register the logger callbacks in the naming directory
            foreach ($loggers as $name => $logger) {
                $namingDirectory->bind(sprintf('php:global/log/%s', $name), $logger);
            }

            // set the initialized loggers finally
            $applicationServer->setLoggers($loggers);

        } catch (\Exception $e) {
            $applicationServer->getSystemLogger()->error($e->__toString());
        }
    }
401031
static function run_interactive($cmd)
    {
        $descriptors = array(
          0 => array ("file", "php://stdin", "r"),
          1 => array ("file", "php://stdout", "w"),
          2 => array ("file", "php://stdout", "w")
        );
        $process = proc_open($cmd, $descriptors, $pipes);
        if (is_resource($process)) {
          $return_value = proc_close($process);
          return $return_value;
        }
    }
1271288
public function onBootstrap(EventInterface $e)
    {
        /** @var MvcEvent $e */
        $eventManager        = $e->getApplication()->getEventManager();
        $moduleRouteListener = new ModuleRouteListener();
        $moduleRouteListener->attach($eventManager);

        $eventManager->attach(MvcEvent::EVENT_ROUTE, array($this, 'onRoute'), -1 * PHP_INT_MAX);
        $eventManager->attach(MvcEvent::EVENT_RENDER, array($this, 'onRender'), PHP_INT_MAX);


        $serviceManager = $e->getApplication()->getServiceManager();

        /** @var SendResponseListener $sendResponseListener */
        $sendResponseListener = $serviceManager->get('SendResponseListener');

        $sendApiProblemResponseListener = $serviceManager->get(SendApiProblemResponseListener::class);

        $sendResponseEventManager =  $sendResponseListener->getEventManager();
        $sendResponseEventManager->attach(SendResponseEvent::EVENT_SEND_RESPONSE, $sendApiProblemResponseListener, -400);


    }
820085
public function bootstrapCommand(string $id, string $host, string $database)
    {
        $package = $this->packageManager->createPackage('Ttree.FlowPlatformSh')->getPackagePath();
        $distribution = $package . 'Resources/Private/Installer/Distribution/' . $database . '/';
        $this->outputLine($distribution);
        Files::copyDirectoryRecursively($distribution, \FLOW_PATH_ROOT, true, true);
        $project = [
            'id: ' . $id,
            'host: ' . $host,
        ];
        \file_put_contents(\FLOW_PATH_ROOT . '.platform/local/project.yaml', \implode(chr(10), $project));
    }
621944
protected function executeCommandHook($method, $event_type)
    {
        foreach ($this->getCommandsByMethodEventType($method, $event_type) as $command) {
            if (is_string($command)) {
                $command = (new CommandHook())
                    ->setType('raw')
                    ->setCommand($command);
            } elseif (is_array($command)) {
                $command = CommandHook::createWithData($command);
            }

            if (!$command instanceof CommandHookInterface) {
                continue;
            }

            switch ($command->getType()) {
                case 'symfony':
                    $this->executeSymfonyCmdHook($command, $method);
                    break;
                default:
                    $this->executeEngineCmdHook($command);
                    break;
            }
        }

        return $this;
    }
875017
public function init()
    {
        $this->invokeBeforeContainerCreatedHook();

        $this->container = $this->createContainer();

        StaticContainer::push($this->container);

        $this->validateEnvironment();

        $this->invokeEnvironmentBootstrappedHook();

        Piwik::postEvent('Environment.bootstrapped'); // this event should be removed eventually
    }
479954
public function beforePrepare(Event $event)
	{
		$command = $event['command'];
		$operation = $command->getOperation();

		if ($command->getName() !== 'updateEntity' && $command->offsetExists('_id') === true) return;

		$operation->addParam(new Parameter(array(
			'name' => 'body_id',
			'location' => 'json',
			'type' => 'string',
			'default' => $command->offsetGet('_id'),
			'static' => true,
			'sentAs' => '_id'
		)));
	}
165367
public function start(CommandInterface $cmd, RequestInterface $req)
    {
        $ticket = uniqid();
        $this->entries[$ticket] = [
            'command'   => $cmd,
            'request'   => $req,
            'result'    => null,
            'exception' => null,
        ];

        return $ticket;
    }
1155145
public function onBootstrap(EventInterface $e)
    {
        if (!$e instanceof MvcEvent) {
            $errMsg = sprintf('Event not implement %s', MvcEvent::class);
            throw new Exception\InvalidArgumentException($errMsg);
        }

        $app = $e->getApplication();

        $eventManager        = $app->getEventManager();
        $moduleRouteListener = new ModuleRouteListener();
        $moduleRouteListener->attach($eventManager);

        $sl = $app->getServiceManager();
        /** @var ParamsFromDoctrineModuleListener $paramsFromDoctrineModuleListener */
        $paramsFromDoctrineModuleListener = $sl->get(ParamsFromDoctrineModuleListener::class);
        $paramsFromDoctrineModuleListener->attach($eventManager);


        /** @var ResolverManagerRegistryResourceListener $resolverManagerRegistryResourceListener */
        $resolverManagerRegistryResourceListener = $sl->get(ResolverManagerRegistryResourceListener::class);
        $resolverManagerRegistryResourceListener->attach($eventManager);

        /** @var ManagerRegistryListener $managerRegistryListener */
        $managerRegistryListener = $sl->get(ManagerRegistryListener::class);
        $managerRegistryListener->attach($eventManager);

    }
993129
public function startup(Event $event)
    {
        $controller = $event->subject();
        if (!empty($controller->request->data) && !Configure::read('DataPreparation.notrimRequestData')) {
            $controller->request->data = $this->_trimDeep($controller->request->data);
        }
        if (!empty($controller->request->query) && !Configure::read('DataPreparation.notrimRequestQuery')) {
            $controller->request->query = $this->_trimDeep($controller->request->query);
        }
        if (!empty($controller->request->params['pass']) && !Configure::read('DataPreparation.notrimRequestParams')) {
            $controller->request->params['pass'] = $this->_trimDeep($controller->request->params['pass']);
        }
    }