Boost action.

@param bool $run
971950
public function boostAction($run = false)
    {
        $configurationService = $this->objectManager->get(ConfigurationService::class);
        $queueRepository = $this->objectManager->get(QueueRepository::class);
        if ($run) {
            $items = $queueRepository->findOpen(10);
            $queueService = GeneralUtility::makeInstance(QueueService::class);
            try {
                foreach ($items as $item) {
                    $queueService->runSingleRequest($item);
                }
            } catch (\Exception $ex) {
            }

            $this->addFlashMessage('Run ' . \count($items) . ' entries', 'Runner', FlashMessage::OK, true);
        }
        $this->view->assignMultiple([
            'enable' => (bool)$configurationService->get('boostMode'),
            'open' => \count($queueRepository->findOpen(99999999)),
            'old' => \count($queueRepository->findOld()),
        ]);
    }
458900
static public function reenable( $reactivate=false )
    {
        self::$has_run = false;
        if ( $reactivate )
        {
            self::$activated = true;
        }
    }
278154
private void pushRun(int runBase, int runLen) {
        this.runBase[stackSize] = runBase;
        this.runLen[stackSize] = runLen;
        stackSize++;
    }
9944
public function run()
    {
        if (!isset($this->conditions)
            || !isset($this->callable)
        ) {

            $message = "You have called the run function but have not provided both a array of conditions";
            $message .= " and a callable function, which will be called if all the given conditions are met.";

            throw new \RuntimeException($message);
        }

        $this->conditions->rewind();
        while ($this->conditions->valid()) {

            $condition = $this->conditions->current();

            if (!call_user_func($condition)) {
                return false;
            }

            $this->conditions->next();
        }

        call_user_func($this->callable, $this->request);
        return true;

    }
780173
private function _run(): void
  {
    // The DB and the controller exist
    if ( $this->check() && isset($this->data['type'])){
      if ( !defined('BBN_EXTERNAL_USER_ID') && defined('BBN_EXTERNAL_USER_EMAIL') ){
        define('BBN_EXTERNAL_USER_ID', $this->db->select_one('bbn_users', 'id', ['email' => BBN_EXTERNAL_USER_EMAIL]));
      }
      if ( defined('BBN_EXTERNAL_USER_ID') && class_exists('\\bbn\\appui\\history') ){
        \bbn\appui\history::set_user(BBN_EXTERNAL_USER_ID);
      }
      $type = $this->data['type'];
      // Removing file cache
      clearstatcache();
      // only 2 types: poll or cron
      if ( $type !== 'poll' ){
        $type = 'cron';
      }
      $pid = $this->get_pid_path($this->data);

      // Checking for the presence of the manual files
      if (
        !$this->is_active() ||
        (($type === 'cron') && !$this->is_cron_active()) ||
        (($type === 'poll') && !$this->is_poll_active())
      ){
        // Exiting the script if one is missing
        if ( is_file($pid) ){
          @unlink($pid);
        }
        exit("GETTING OUT of $type BECAUSE one of the manual files is missing");
      }
      // Loooking for a running PID
      if ( is_file($pid) && ($file_content = @file_get_contents($pid)) ){
        $pid_content = explode('|', $file_content);
        if ( $pid_content[1] && file_exists('/proc/'.$pid_content[0]) ){
          // If it's currently running we exit
          exit("There is already a process running with PID ".file_get_contents($pid)." in $pid");
        }
        else{
          // Otherwise we delete the PID file
          echo "DELETING FILEPID AS THE PROCESS IS DEAD ".implode(PHP_EOL, $pid_content).PHP_EOL;
          @unlink($pid);
        }
      }
      // We create the PID file corresponding to the current process
      file_put_contents($pid, getmypid().'|'.time());
      $cron =& $this;
      // Shutdown function, will be always executed, except if the server is stopped
      register_shutdown_function(function() use($cron){
        $data = $cron->get_data();
        $pid = $this->get_pid_path($data);
        $file_content = @file_get_contents($pid);
        // Write the error log if an error is present
        if ( $error = error_get_last() ){
          @file_put_contents($cron->get_error_log_path($data), \bbn\x::get_dump($error));
          if ( defined('BBN_DATA_PATH') && is_dir(BBN_DATA_PATH.'logs') ){
            bbn\x::log([$data, $error], 'cron');
          }
        }
        $ok = true;
        // We check if there is a problem with the PID file (it's only debug it shouldn't be necessary)
        if ( $file_content ){
          echo $file_content.PHP_EOL;
          $pid_content = explode('|', $file_content);
          if ( $pid_content[1] && ($pid_content[0] != getmypid()) ){
            echo 'Different processes: '.$pid_content[0].'/'.getmypid().PHP_EOL;
            $ok = false;
          }
        }
        if ( $ok && isset($data['type']) ){
          // We output the ending time (as all output will be logged in the output file
          echo 'SHUTDOWN '.date('H:i:s');
          // Removing PID file
          if ( is_file($pid) ){
            @unlink($pid);
          }
          // And relaunching the continuous tasks if we are in the poller...
          if ( ($data['type'] === 'poll') && $cron->is_poll_active() ){
            $cron->launch_poll();
          }
          else if ( !array_key_exists('id', $data) && ($data['type'] === 'cron') && $cron->is_cron_active() ){
            $cron->launch_task_system();
          }
        }
      });
      // And here we really do what we have to do
      // Poll case
      if ( $type === 'poll' ){
        $this->poll();
      }
      else if ( $type === 'cron' ){
        if ( array_key_exists('id', $this->data) ){
          echo 'Launching task...';
          $this->run_task($this->data);
        }
        else{
          $this->run_task_system();
        }
      }
    }
  }
89782
public function run($connections, $autorun = true)
    {
        if (!is_array($connections)) {
            $connections = array($connections);
        }

        $this->on('connect.error', function($message, $connection, $logger) {
            $logger->error($message);
        });

        $this->emit('connect.before.all', array($connections));

        foreach ($connections as $connection) {
            $this->addConnection($connection);
        }

        $writes = array_map(
            function($connection) {
                return $connection->getData('write');
            },
            $connections
        );
        $this->emit('connect.after.all', array($connections, $writes));

        if ($autorun) {
            $this->getLoop()->run();
        }
    }
1355318
public function setFieldBoost($key, $boost)
	{
		$boost = (float) $boost;

		if ($boost > 0.0)
		{
			$this->_fieldBoosts[$key] = $boost;
		}
		else
		{
			$this->_fieldBoosts[$key] = false;
		}
	}
205222
public function run(): bool
    {
        $this->startMeasure(__METHOD__);

        if (!Any::isArray($this->objects)) {
            return false;
        }

        foreach ($this->objects as $class) {
            forward_static_call([$class, 'boot']);
        }

        $this->stopMeasure(__METHOD__);
        return true;
    }
445241
public function run()
    {
        $prefix = $this->notifyPrefix;
        
        $this->addNotification($prefix.'_start_run_tasks');
        
        foreach ($this->runSteps as $actionName => $stepInfos) {
            $context = null;
            if ($stepInfos->context !== null) {
                $context = $stepInfos->context;
            }
            
            if ($stepInfos->callback === null) {
                $this->addNotification($prefix.'_exec_'.$actionName, $context);
                continue;
            }
            
            $this->addNotification($prefix.'_run_'.$actionName, $context);

            if (is_callable($stepInfos->callback)) {
                $callback = $stepInfos->callback;
                $callback();
            }

            $this->addNotification($prefix.'_done_'.$actionName, $context);
        }
        
        $this->addNotification($prefix.'_end_run_tasks');
    }
290797
public function run()
    {
        echo Html::beginTag('div', $this->options) . "\n";
        echo $this->renderContainer ? Html::beginTag('div', $this->containerOptions) . "\n" : '';
        foreach ($this->templates as $template => $options) {
            if (!is_array($options)) {
                echo $this->renderElements($options);
            } else {
                echo Html::beginTag('div', $options);
                echo $this->renderElements($template, $options);
                echo Html::endTag('div');
            }
        }
        echo $this->renderContainer ? Html::endTag('div') . "\n" : '';
        echo Html::endTag('div') . "\n";

        if ($this->registerCss) {
            ActionBarAsset::register($this->view);
        }
    }
758205
public static void runByBoolean(boolean bool, Runnable trueBlock,
            Runnable falseBlock) {
        if (bool)
            trueBlock.run();
        else
            falseBlock.run();
    }
1035439
public function run()
    {
        if (isset(\Yii::$app->cmsMarketplace) && \Yii::$app->cmsMarketplace) {
            \Yii::$app->cmsMarketplace->info;
        }

        if ($this->_isRunning === false && $this->_checkAccess()) {
            $this->_isRunning = true;
            static::$_runningBakcend = $this;

            $event = new Event();
            $this->trigger(self::EVENT_BEFORE_RUN, $event);

            $this->_run();

            $event = new Event();
            $this->trigger(self::EVENT_RUN, $event);
        }

        return $this;
    }
1309501
function launch($action) {

        global $CFG;

        // Get the action path and invoke it
        $actionsroot = "$CFG->dirroot/$CFG->admin/tool/xmldb/actions";
        $actionclass = $action . '.class.php';
        $actionpath = "$actionsroot/$action/$actionclass";

        // Load and invoke the proper action
        $result = false;
        if (file_exists($actionpath) && is_readable($actionpath)) {
            require_once($actionpath);
            if ($xmldb_action = new $action) {
                $result = $xmldb_action->invoke();
                if ($result) {
                    if ($xmldb_action->does_generate != ACTION_NONE &&
                        $xmldb_action->getOutput()) {
                        $this->does_generate = $xmldb_action->does_generate;
                        $this->title = $xmldb_action->title;
                        $this->str = $xmldb_action->str;
                        $this->output .= $xmldb_action->getOutput();
                    }
                } else {
                    $this->errormsg = $xmldb_action->getError();
                }
            } else {
                $this->errormsg = "Error: cannot instantiate class (actions/$action/$actionclass)";
            }
        } else {
            $this->errormsg = "Error: wrong action specified ($action)";
        }
        return $result;
    }
1056124
public function runAction()
    {
        $success = false;
        $message = 'tr_meliscore_microservice_api_key_no_access';
        $data = [];
        $errors = [];
        $hasError = false;
        $apiKey = $this->params()->fromRoute('api_key');
        $module = ucfirst($this->params()->fromRoute('module'));
        $service = ucfirst($this->params()->fromRoute('service_alias'));
        $method = $this->params()->fromRoute('service_method');

        $translator = $this->getServiceLocator()->get('translator');
        $userApiData = $this->getMicroServiceAuthTable()->getUserByApiKey($apiKey)->current();

        /**
         * If user API data is not empty, then proceed on checking its' content
         */
        if ($userApiData) {

            // set the langauge 
            $melisLangTable = $this->serviceLocator->get('MelisCore\Model\Tables\MelisLangTable');
            $langData = $melisLangTable->getEntryById($userApiData->usr_lang_id)->current();
            if($langData) {
                $container = new Container('meliscore');
                $container['melis-lang-locale'] = $langData->lang_locale;
            }

            /**
             * check whether user's accessibility is still "active" or not
             */
            $isUserCanExec = (bool)$userApiData->msoa_status;

            /**
             * If user's API option is still "active"
             */
            if ($isUserCanExec) {

                // check if the module in the route param exists
                $moduleSvc = $this->getServiceLocator()->get('ModulesService');
                $modules = $moduleSvc->getAllModules();

                /**
                 * Checker whether the provided module in the route parameter does exists in Zend Active Modules
                 */
                if (in_array($module, $modules)) {

                    // check if the service alias exists
                    $config = $this->getServiceLocator()->get('config');
                    $services = array_merge($config['service_manager']['aliases'], $config['service_manager']['factories']);
                    $servicesKeys = array_keys($services);
                    
                    /**
                     * Checker whether the requested Service exists in the platform
                     */
                    if (in_array($service, $servicesKeys)) {

                        $tool = $this->getServiceLocator()->get('MelisCoreTool');
                        $post = $tool->sanitizeRecursive($this->getRequest()->getPost());

                        $servicePath = "\\$module\\Service\\$service";
                        $methodExists = method_exists($servicePath, $method);
                        //echo func_num_args($servicePath."\\" . $method);
                        $coreConfig = $this->getServiceLocator()->get('MelisCoreConfig');
                        $form = $coreConfig->getItem('microservice/' . $module . '/' . $service . '/' . $method);
                       

                        /**
                         * Checker whether the requested method exists in the provided Service, and return JSON if
                         * requested method is POST
                         */
                        if ($post && $methodExists) {
                            /**
                             * If form configuration in app.microservice.php is properly configured depending on the provided
                             * route parameters, then we will use its' configuration to interact with the service
                             * and make an invocation to it using ReflectionMethod so we can get the data that is being
                             * returned after invoking the method.
                             */
                            if ($form) {

                                /**
                                 * This listener trigger allows you to modify the structure of your post data, this is useful whenever your method arguments requires an array argument
                                 * in this way, we would be able to modify its' structure depending the needs of the metod.
                                 */
                                $post = $this->getEventManager()->trigger('melis_core_microservice_route_param', $this, array('module' => $module, 'service' => $service, 'method' => $method, 'post' => $post));

                                /**
                                 * This condition checks whether the trigger returns a good data
                                 */
                                if (isset($post[0]) && isset($post[0]['post'])) {

                                    $post = $post->bottom()['post'];

                                    $form = $this->getForm($form);
                                    $form->setData($post);

                                    if ($form->isValid()) {

                                        $tmpInstance = new $servicePath();
                                        $tmpInstance->setServiceLocator($this->getServiceLocator());

                                        $setEventManagerMethodExists = (bool) method_exists($servicePath, 'setEventManager');

                                        if($setEventManagerMethodExists) {
                                            $tmpInstance->setEventManager($this->getEventManager());
                                        }

                                        $reflectionMethod = new \ReflectionMethod($servicePath, $method);

                                        /**
                                         * allow method to accept dynamic arguments
                                         */
                                        $data = $reflectionMethod->invokeArgs($tmpInstance, $post);
                                        

                                        /**
                                         * This listener trigger handles the modification of the results returned by invokeArgs
                                         */
                                        $tmpData = $this->getEventManager()->trigger('melis_core_microservice_amend_data', $this, array('module' => $module, 'service' => $service, 'method' => $method, 'post' => $post, 'results' => $data));
                                      
                                        if(isset($tmpData[0]) && isset($tmpData['0']['results'])) {
                                            $data = $tmpData[0]['results'];
                                        }

                                        // Check data if it's an Object
                                        if(is_object($data)){
                                          
                                            // This will check if the property of an object is protected
                                            $obj = new \ReflectionObject($data);
                                            $objIsProtected = $obj->getProperties(\ReflectionProperty::IS_PROTECTED);

                                            // This is for HydratingResultSet Object
                                            if($data instanceof HydratingResultSet){
                                                $data = $data->toArray();
                                            }

                                            // This is for Object that is protected
                                            if($objIsProtected){
                                                $data = $this->tool()->convertObjectToArray($data);
                                            }
                                        }
                                        // Check data if it's an array
                                        if(is_array($data)){
                                            
                                            $data = $this->tool()->convertObjectToArray($data);
                                        }

                                        $message = 'tr_meliscore_microservice_request_ok';
                                        $success = true;
                                    } else {
                                        $errors = $form->getMessages();
                                    }
                                } else {
                                    $errors['invalid_post_parameters'] = (array) $post;
                                }
                            }

                            /**
                             * If no error encountered, then we will return a JSON response including its' service returned data
                             */
                            if (!$errors) {

                                $response = [
                                    'success'  => $success,
                                    'message'  => $translator->translate($message),
                                    'response' => $data,
                                    'errors'   => $errors
                                ];

                                return new JsonModel($response);
                            } 
                            /**
                             * If provided arguments has errors then return the form with the error message(s)
                             */
                            else {
                                // get the form configuration in app.microservice configuration file
                                $this->layout('layout/layoutBlank');
                                $view = new ViewModel();
                                $view->setTerminal(true);
                                $view->form = $form;
                                $view->methodName = $method;
                                return $view;
                            }
                        } else {
                            /**
                             * If the request method is GET then we display the form
                             */
                            if ($methodExists) {
                                /**
                                 * Display the form that will be used to provide data for the service method arguments
                                 * 
                                 */
                              
                                if ($form) {

                                    //Get the number of arguments passed
                                    $arguments =  new \ReflectionMethod($servicePath, $method);
                                    $numberOfParameters = $arguments->getNumberOfParameters();
                                    //Display the form only when there is parameter(s)
                                    if($numberOfParameters > 0 )
                                     {
                                        // get the form configuration in app.microservice configuration file
                                        $this->layout('layout/layoutBlank');
                                        $view = new ViewModel();
                                        $view->setTerminal(true);
                                        $view->form = $this->getForm($form);
                                        $view->methodName = $method;
                                        return $view;
                                    }
                                    else {

                                        $tmpInstance = new $servicePath();
                                        $tmpInstance->setServiceLocator($this->getServiceLocator());
                                        $reflectionMethod = new \ReflectionMethod($servicePath, $method);

                                         // Check data if it's an Object
                                        if(is_object($data)){
                                          
                                            // This will check if the property of an object is protected
                                            $obj = new \ReflectionObject($data);
                                            $objIsProtected = $obj->getProperties(\ReflectionProperty::IS_PROTECTED);

                                            // This is for HydratingResultSet Object
                                            if($data instanceof HydratingResultSet){
                                                $data = $data->toArray();
                                            }

                                            // This is for Object that is protected
                                            if($objIsProtected){
                                                $data = $this->tool()->convertObjectToArray($data);
                                            }
                                        }
                                        // Check data if it's an array
                                        if(is_array($data)){
                                            
                                            $data = $this->tool()->convertObjectToArray($data);
                                        }

                                        $message = 'tr_meliscore_microservice_request_ok';
                                        $success = true;

                                        if (!$errors) {
                                            $response = [
                                                'success'  => $success,
                                                'message'  => $translator->translate($message),
                                                'response' => $data,
                                                'errors'   => $errors
                                           ];

                                            return new JsonModel($response);
                                        } 
                                    }
                                } else {
                                    $message = 'tr_meliscore_microservice_form_ko';
                                    $hasError = true;
                                }
                            } else {
                                $message = 'tr_meliscore_microservice_method_ko';
                                $hasError = true;
                            }

                        }
                    } else {
                        $message = 'tr_meliscore_microservice_service_ko';
                        $hasError = true;
                    }
                } else {
                    $message = 'tr_meliscore_microservice_module_ko';
                    $hasError = true;
                }

            }else{
                $message = 'tr_meliscore_microservice_api_key_inactive';
                $hasError = true;
            }   


        } else {
            $message = 'tr_meliscore_microservice_api_key_invalid';
            $hasError = true;
        }

        /**
         * If there's an error, we display the JSON response
         */
        if ($hasError) {
            $response = [
                'success' => $success,
                'message' => $translator->translate($message),
                'response' => $data,
                'errors' => $errors
            ];
            return new JsonModel($response);
        }
        die;

    }
621585
public static function run()
    {
        self::init();

        /*
         * Register routes.
         */
        call_user_func(function () {
            /** @noinspection PhpIncludeInspection */
            require self::$basePath . '/boot/routes.php';
            if (file_exists(self::$basePath . '/.manifest/plugins/routes.php')) {
                /** @noinspection PhpIncludeInspection */
                include self::$basePath . '/.manifest/plugins/routes.php';
            }
        });

        /*
         * Dispatch the HTTP request and send the response to the browser.
         */
        /** @var \Core\Services\Contracts\Router $router */
        $router   = DI::getInstance()->get('router');
        $request  = DI::getInstance()->get('request');
        $response = $router->dispatch($request);
        $response->send();
    }
1313394
public function run($hide = false)
    {
        $this->boot();
        $this->initNamespace();
        $this->initModules();
        $this->initServices();
        if ($hide === false) {
            return $this->handle()->getContent();
        } else {
            return 'true';
        }
    }
511820
public function run($run, array $arguments = [])
    {

        $lambda = new Lambda($run);

        return $this->repository->transaction(function($repo) use ($lambda, $arguments) {

            $taskTemplate = $this->newTask($lambda);

            $this->callBeforeListeners('run', [$taskTemplate, $lambda, $arguments]);

            $task = $this->repository->create($taskTemplate);

            $job = $this->createJob($task, $lambda, $arguments);

            // We can just ignore to write state because typically the job
            // is typically started in another process
            $task->setJob($job);

            $this->callAfterListeners('run', [$taskTemplate, $job]);

            return $task;

        });
    }