Build an Action Api class instance

@param string $action
@param array $data
@param CliInput $input
@param Mapping $mapping
@return ActionApi
972719
public function build(
        $action,
        array $data,
        CliInput $input,
        Mapping $mapping
    ) {
        $context = new ZMQContext();
        $socket = new ZMQSocket($context, ZMQ::SOCKET_REQ);
        $socket->setSockOpt(ZMQ::SOCKOPT_LINGER, 0);

        if ($input->getMapping() === 'compact') {
            $transportMapper = new CompactTransportMapper();
            $runtimeCallMapper = new CompactRuntimeCallMapper($transportMapper);
        } else {
            $transportMapper = new ExtendedTransportMapper();
            $runtimeCallMapper = new ExtendedRuntimeCallMapper($transportMapper);
        }

        $caller = new ZeroMQRuntimeCaller(
            new MessagePackSerializer(),
            new CompactTransportMapper(),
            $socket,
            $runtimeCallMapper,
            new Timer()
        );

        $transport = $this->mapper->getTransport($data);
        return new ActionApi(
            $this->logger->getRequestLogger($transport->getMeta()->getId()),
            $this->component,
            $mapping,
            dirname(realpath($_SERVER['SCRIPT_FILENAME'])),
            $input->getName(),
            $input->getVersion(),
            $input->getFrameworkVersion(),
            $input->getVariables(),
            $input->isDebug(),
            $action,
            $caller,
            $transport,
            new TypeCatalog(),
            $this->mapper->getParams($data)
        );
    }
916155
public function action($action, $parameters = [], $absolute = true)
    {
        if (is_null($route = $this->routes->getByAction($action = $this->formatAction($action)))) {
            throw new InvalidArgumentException("Action {$action} not defined.");
        }

        return $this->toRoute($route, $parameters, $absolute);
    }
578137
public function callAction(string $action, ?DataMap $params = null): void
    {
        list ($moduleName, $controllerName, $actionName) = $this->getFullAction($action);
        $this->routeInfo->moduleName = $moduleName;
        $this->routeInfo->controllerName = $controllerName;
        $this->routeInfo->actionName = $actionName;
        if ($params != null) {
            $this->routeInfo->params = $params;
        }
        $this->invokeRoute();
    }
314189
public function getData($action, $key)
    {
        if (!is_string($action) || empty($action)) {
            throw new \InvalidArgumentException('The action name is invalid');
        }

        if (!is_string($key) || empty($key)) {
            throw new \InvalidArgumentException('The data key name is invalid');
        }

        return $this->data[$action][$key];
    }
1321909
final public function execute($input, $output)
    {
        $action = $this->action;
        $group  = static::getName();

        if ($this->isDisabled($action)) {
            $output->liteError(\sprintf("Sorry, The command '%s' is invalid in the group '%s'!", $action, $group));
            return -1;
        }

        $method = $this->actionSuffix ? $action . \ucfirst($this->actionSuffix) : $action;

        // the action method exists and only allow access public method.
        if (\method_exists($this, $method) && (($rfm = new \ReflectionMethod($this, $method)) && $rfm->isPublic())) {
            // before
            if (\method_exists($this, $before = 'before' . \ucfirst($action))) {
                $this->$before($input, $output);
            }

            // run action
            $result = $this->$method($input, $output);

            // after
            if (\method_exists($this, $after = 'after' . \ucfirst($action))) {
                $this->$after($input, $output);
            }

            return $result;
        }

        // if you defined the method '$this->notFoundCallback' , will call it
        if (($notFoundCallback = $this->notFoundCallback) && \method_exists($this, $notFoundCallback)) {
            $result = $this->{$notFoundCallback}($action);
        } else {
            $result = -1;
            $output->liteError("Sorry, The command '$action' not exist of the group '{$group}'!");

            // find similar command names
            $similar = Helper::findSimilar($action, $this->getAllCommandMethods(null, true));

            if ($similar) {
                $output->write(sprintf("\nMaybe what you mean is:\n    <info>%s</info>", \implode(', ', $similar)));
            } else {
                $this->showCommandList();
            }
        }

        return $result;
    }
1247881
private function executeAction(string $action)
    {
        list($controller, $method) = explode('@', $action);

        $class = '\App\Controllers\\'.ucfirst($controller).'Controller';

        if (!class_exists($class)) {
            throw new ExceptionHandler('Class "'.$class.'" not found.');
        }

        $controllerInstantiate = new $class();

        if (!method_exists($controllerInstantiate, $method)) {
            throw new ExceptionHandler('Method "'.$method.'" not found in '.$class.'.');
        }

        return call_user_func_array([new $controllerInstantiate, $method], []);
    }
450764
public function buildDataGridForm(
        Action $action,
        Request $request,
        DataGrid $dataGrid = null,
        array $formOptions = []
    ): DataGrid {
        if (null === $dataGrid) {
            $dataGrid = $this->getDataGrid($action);
        }
        $formOptions = array_merge(
            [
                'method' => $this->method,
                'csrf_protection' => false,
                'action' => $this->routingHelper->getCurrentUri($action, $request),
                'validation_groups' => ['filters'],
            ],
            $formOptions
        );

        // Create form with filters
        $builder = $this->formFactory->createBuilder(FormType::class, null, $formOptions);
        $dataGrid->buildForm($builder);

        return $dataGrid;
    }
113
public function register_action_map($map)
    {
        if (is_array($map)) {
            foreach ($map as $idx => $val) {
                $this->action_map[$idx] = $val;
            }
        }
    }
70141
public function buildInput(ApiDoc $annotation, $data = null)
    {
        $annotationReflection = new \ReflectionClass('Nelmio\ApiDocBundle\Annotation\ApiDoc');
        $inputReflection = $annotationReflection->getProperty('input');
        $inputReflection->setAccessible(true);

        if (!(isset($data['input']) || $data['input'] === null) || empty($data['input'])) {
            if ($annotation->toArray()['method'] === 'POST' || $annotation->toArray()['method'] === 'PUT') {
                $actionName = $annotation->getRoute()->getDefault('_controller');
                $controllerClass = substr($actionName, 0, strpos($actionName, '::'));
                $reflectionClass = new \ReflectionClass(substr($controllerClass, strpos($controllerClass, ':')));
                $class = str_replace('Controller', '', $reflectionClass->getShortName());
                $inputType = 'Kreta\\Component\\' . $class . '\\Form\\Type\\' . $class . 'Type';
                if (class_exists($inputType)) {
                    $inputReflection->setValue($annotation, $inputType);
                }
            }
        } else {
            $inputReflection->setValue($annotation, $data['input']);
        }

        return $annotation;
    }
955446
public function action(callable $action, $params = [], &$result = null)
    {
        return $this->db->action($action, $params, $result);
    }
1024532
private function setupData($input, $output)
    {
        $command = $this->getApplication()->find('networking:initcms:data-setup');
        $arguments = [
            'command' => 'networking:initcms:data-setup',
            '--drop' => true,
            '--use-acl' => $input->getOption('use-acl'),
        ];

        $input = new ArrayInput($arguments);

        return $command->run($input, $output);
    }
183126
protected function httpRequest($action, $data, $method = 'POST', $options = [ ]) {
        $response = $this->{$this->http_request_type}($action, $data, $method, $options);
        $json = json_decode($response, true);
        if ($json === NULL) {
            throw new Sailthru_Client_Exception(
                "Response: {$response} is not a valid JSON",
                Sailthru_Client_Exception::CODE_RESPONSE_INVALID
            );
        }
        if (!empty($json['error'])) {
            throw new Sailthru_Client_Exception($json['errormsg'], $json['error']);
        }

        return $json;
    }
287592
public function prepare($module, $action, $data = 'default')
    {
        $request = $this->_createRequest($this->config("REQUEST"));
        if ( ! is_object($request)) {
            return null;
        }
        $request->setModule($module);
        $request->setAction($action);
        $request->prepareRequest($data);

        return $request;
    }
1075040
public static function createInstance($data, $table, Connection $connection, IMapper $mapper)
    {
        $dataArray = [];
        $primaryKey = $mapper->getPrimaryKey($table);
        if ($data instanceof DibiRow) {
            $dataArray = [isset($data->$primaryKey) ? $data->$primaryKey : self::DETACHED_ROW_ID => $data->toArray()];
        } else {
            $e = new InvalidArgumentException(
                'Invalid type of data given, only \Dibi\Row, \Dibi\Row[], ArrayAccess[] or array of arrays is supported at this moment.'
            );
            if (!is_array($data)) {
                throw $e;
            }
            if (!empty($data)) {
                $record = reset($data);
                if (!($record instanceof DibiRow) and !is_array($record) and (!$record instanceof ArrayAccess)) {
                    throw $e;
                }
            }
            foreach ($data as $record) {
                $record = (array)$record;
                if (isset($record[$primaryKey])) {
                    $dataArray[$record[$primaryKey]] = $record;
                } else {
                    $dataArray[] = $record;
                }
            }
        }
        return new static($dataArray, $table, $connection, $mapper);
    }
631875
public function apiGet($action, $data = [ ], $method = 'GET', $options = [ ]) {
        return $this->httpRequest($action, $this->prepareJsonPayload($data), $method, $options);
    }
1061597
public static function createKey($resource, $context, $action) {
    return $resource.self::$actionDelimiter.$context.self::$actionDelimiter.$action;
  }
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;
    }