执行钩子

@param string $behavior
@param mixed $params
@param mixed $extra

@return mixed
429713
protected function executeHook($behavior, &$params = null, $extra = null)
    {
        if (is_string($behavior)) {
            if (strpos($behavior, '::')) {
                $behavior = explode('::', $behavior, 2);
            } else {
                $behavior = [
                    $behavior,
                    $this->_hookMethod
                ];
            }
        }
        return call_user_func_array($behavior, [
            &$params,
            $extra,
            $this
        ]);
    }
1092833
public function showAction($id, $extra) {
        $entity = $this->container->get("layout.read_handler")->get($id);
        $delete_form = $this->container->get("layout.form_handler")->createDeleteForm($id);


//        $route_collection = $this->container->get('router')->getRouteCollection()->all();
//        echo '<pre>';
//        if(is_object($route_collection))
//            print_r(get_class_methods($route_collection));
//            print_r($route_collection);
//            
//            echo '</pre>';

        $layout = str_replace(":show.html.twig", ":display.html.twig", $this->container->get("request")->get('_layout'));

        $params = array(
            "entity" => $entity
            , "extra" => $extra
        );

        return new Response($this->container->get('templating')->render($layout, $params));
    }
127340
public function displayAction($id, $extra = null) {
        
        $entity = $this->container->get("page.read_handler")->getWithModelPageContent($id);

        return array(
            'entity' => $entity
            , 'extra' => $extra
        );
    }
988833
private function _action($params)
    {
        // Shift and get the method
        $method = array_shift($params);

        // Behavior
        if ($this->behaviors[$method]) {
            $this->behaviors[$method]();
        }

        if (!isset($this->routes[$method])) {
            $this->_defaultAction();
        }

        // Get corresponding method name
        $method = $this->routes[$method];

        if (!method_exists($this, $method)) {
            $this->_defaultAction();
        }

        return call_user_func_array([$this, $method], $params);
    }
1215211
public static function listen($tag, $params = null, $extra = null)
    {
        $result = true;

        if (isset(self::$tags[$tag])) {
            foreach (self::$tags[$tag] as $behaviors) {
                $result = self::exec($behaviors, $params, $extra);

                if ($result === false) {
                    return $result;
                }
            }
        }

        return $result;
    }
674849
public static function debug( $message, $context = array(), $extra = null )
    {
        return static::log( $message, LoggingLevels::DEBUG, $context, $extra );
    }
1011238
public function get_sql_filter($extra='', array $params=null) {
        global $SESSION;

        $sqls = array();
        if ($extra != '') {
            $sqls[] = $extra;
        }
        $params = (array)$params;

        if (!empty($SESSION->user_filtering)) {
            foreach ($SESSION->user_filtering as $fname => $datas) {
                if (!array_key_exists($fname, $this->_fields)) {
                    continue; // Filter not used.
                }
                $field = $this->_fields[$fname];
                foreach ($datas as $i => $data) {
                    list($s, $p) = $field->get_sql_filter($data);
                    $sqls[] = $s;
                    $params = $params + $p;
                }
            }
        }

        if (empty($sqls)) {
            return array('', array());
        } else {
            $sqls = implode(' AND ', $sqls);
            return array($sqls, $params);
        }
    }
112070
public function getPageListFromPageTransclusions( $pageName, array $extraParams = [] ) {
		$params = array_merge( $extraParams, [
			'list' => 'embeddedin',
			'eititle' => $pageName,
		] );
		return $this->runQuery( $params, 'eicontinue', 'embeddedin' );
	}
482290
protected static function saveConfigParams(array $data, array $extra)
    {
        Logger::log('Saving required config parameters');
        //En caso de tener parámetros nuevos los guardamos
        if (array_key_exists('label', $extra) && is_array($extra['label'])) {
            foreach ($extra['label'] as $index => $field) {
                if (array_key_exists($index, $extra['value']) && !empty($extra['value'][$index])) {
                    /** @var $data array */
                    $data[$field] = $extra['value'][$index];
                }
            }
        }
        return $data;
    }
1273693
public function invoke( $args, $assoc_args, $extra_args ) {

		if ( 'help' !== $this->name ) {
			static $prompted_once = false;

			if ( \WP_CLI::get_config( 'prompt' ) && ! $prompted_once ) {
				list( $_args, $assoc_args ) = $this->prompt_args( $args, $assoc_args );
				$args                       = array_merge( $args, $_args );
				$prompted_once              = true;
			}
		}

		$extra_positionals = array();
		foreach ( $extra_args as $k => $v ) {
			if ( is_numeric( $k ) ) {
				if ( ! isset( $args[ $k ] ) ) {
					$extra_positionals[ $k ] = $v;
				}
				unset( $extra_args[ $k ] );
			}
		}
		$args += $extra_positionals;

		list( $to_unset, $args, $assoc_args, $extra_args ) = $this->validate_args( $args, $assoc_args, $extra_args );

		foreach ( $to_unset as $key ) {
			unset( $assoc_args[ $key ] );
		}

		$path   = get_path( $this->get_parent() );
		$parent = implode( ' ', array_slice( $path, 1 ) );
		$cmd    = $this->name;
		if ( $parent ) {
			WP_CLI::do_hook( "before_invoke:{$parent}" );
			$cmd = $parent . ' ' . $cmd;
		}
		WP_CLI::do_hook( "before_invoke:{$cmd}" );

		call_user_func( $this->when_invoked, $args, array_merge( $extra_args, $assoc_args ) );

		if ( $parent ) {
			WP_CLI::do_hook( "after_invoke:{$parent}" );
		}
		WP_CLI::do_hook( "after_invoke:{$cmd}" );
	}
1289172
protected function doTransform(Matrix $mA, $extra = null)
    {
        if ($mA->is('empty')) {
            return new Matrix([]);
        }

        /** @noinspection PhpInternalEntityUsedInspection */
        $this->assertParameterIsArray($extra, 'Second operand is not an array');

        if (empty($extra)) {
            throw new MatrixException('Second operand does not contain col indicator');
        }
        $col = intval($extra[0]);
        $availableCols = $mA->columns();
        if ($col<1 || $col > $availableCols) {
            throw new MatrixException('Col indicator out of bounds');
        }

        $numCols = (isset($extra[1]) ? intval($extra[1]) : 1);
        if ($numCols < 1 || ($numCols+$col-1) > $availableCols) {
            throw new MatrixException('Numcols out of bounds');
        }

        $fT = new Transpose();
        $fR = new Rowreduce();

        return $fT($fR($fT($mA), [$col, $numCols]));
    }
714535
public function callHook($name, &$params, $extra = null)
    {
        $results = [];
        $hooks = $this->getHook($name);

        // 排序
        usort($hooks, [
            $this,
            'compareHookWeight'
        ]);

        foreach ($hooks as $key => $hook) {
            $results[$key] = $this->executeHook($hook['behavior'], $params, $extra);

            // 返回false则停止执行
            if (false === $results[$key]) {
                break;
            }
        }
        return $results;
    }
825948
public function proceed($params = [])
    {
        // before
        if (isset($this->advice['before']) && !empty($this->advice['before'])) {
            list($aspectClass, $aspectMethod) = $this->advice['before'];
            $aspect = App::getBean($aspectClass);
            $aspect->$aspectMethod();
        }

        if (empty($this->advices)) {
            // execute
            $methodParams = !empty($params) ? $params : $this->args;
            $result       = $this->target->{$this->method}(...$methodParams);
        } else {
            /* @var \Swoft\Aop\Aop $aop */
            $aop    = App::getBean(Aop::class);
            $result = $aop->doAdvice($this->target, $this->method, $this->args, $this->advices);
        }

        return $result;
    }
723174
public function execute(array $params = [])
    {
        $context = \Context::getInstance();
        $excludedRoutes = $this->getExcludedRoutes();
        $currentRoute = [
            'extension' => $context->getExtensionName(),
            'module' => $context->getModuleName(),
            'action' => $context->getActionName(),
        ];

        if (!in_array($currentRoute, $excludedRoutes)) {
            $currentUrl = \common_http_Request::currentRequest()->getUrl();
            $url = $this->url . (parse_url($this->url, PHP_URL_QUERY) ? '&' : '?') . 'return_url=' . urlencode($currentUrl);

            $flowController = new FlowController();
            $flowController->redirect($url);
        }
    }
710346
protected function doTransform(Matrix $mA, $extra = null)
    {
        if ($mA->is('empty')) {
            return new Matrix([]);
        }
        /** @noinspection PhpInternalEntityUsedInspection */
        $this->assertParameterIsArray($extra, 'Second operand is not an array');

        if (count($extra) != 2) {
            throw new MatrixException('Second operand does not contain row and column');
        }
        $row = intval($extra[0]);
        $col = intval($extra[1]);
        $size = $mA->rows();
        if ($row<1 || $row > $size) {
            throw new MatrixException('Row indicator out of bounds');
        }
        if ($col<1 || $col > $size) {
            throw new MatrixException('Col indicator out of bounds');
        }

        $fC = new Colreduce();
        $fR = new Rowreduce();
        //R(C(mA))
        return $fR($fC($mA,[$col]),[$row]);
    }
299980
public function extractMeaning($query, $extraParams = [])
    {
        $query = array_merge($extraParams, [
            'lang' => $this->client->getApiLanguage(),
            'query' => $query,
        ]);

        $response = $this->client->post('query', $query);

        return $this->decodeResponse($response);
    }
925415
private function appendBehaviorNode(Behavior $behavior, \DOMNode $parentNode)
    {
        $behaviorNode = $parentNode->appendChild($this->document->createElement('behavior'));
        $behaviorNode->setAttribute('name', $behavior->getName());

        if ($behavior->allowMultiple()) {
            $behaviorNode->setAttribute('id', $behavior->getId());
        }

        foreach ($behavior->getParameters() as $name => $value) {
            $parameterNode = $behaviorNode->appendChild($this->document->createElement('parameter'));
            $parameterNode->setAttribute('name', $name);
            $parameterNode->setAttribute('value', $value);
        }
    }