protected function registerControllerWithAnnotations($className, Ctrl $ctrlAnnotation) {
        $actions = (new \ReflectionClass($className))->getMethods(\ReflectionMethod::IS_PUBLIC);
        $actions = array_filter($actions, function($value) {
            return $value->name !== 'actions' && strpos($value->name, 'action') === 0 ? $value : false;
        });
        $actions = Reaction\Helpers\ArrayHelper::getColumn($actions, 'name', false);
        if (empty($actions)) {
            return;
        }
        $controller = is_string($className) ? new $className() : $className;
        for ($i = 0; $i < count($actions); $i++) {
            $actionAnnotations = Reaction::$annotations->getMethod($actions[$i], $className);
            if (!isset($actionAnnotations[CtrlAction::class])) {
                continue;
            }
            /** @var CtrlAction $ctrlAction */
            $ctrlAction = $actionAnnotations[CtrlAction::class];
            $path = $ctrlAnnotation->group . '/' . ltrim($ctrlAction->path, '/');
            $path = $path !== '/' ? rtrim($path, '/') : $path;
            $actionId = Controller::getActionId($actions[$i]);
            $this->addRoute($ctrlAction->method, $path, [$controller, $actionId]);
        }
    }
protected function registerControllerWithAnnotations($className, Ctrl $ctrlAnnotation) {
        $actions = (new \ReflectionClass($className))->getMethods(\ReflectionMethod::IS_PUBLIC);
        $actions = array_filter($actions, function($value) {
            return $value->name !== 'actions' && strpos($value->name, 'action') === 0 ? $value : false;
        });
        $actions = Reaction\Helpers\ArrayHelper::getColumn($actions, 'name', false);
        if (empty($actions)) {
            return;
        }
        $controller = is_string($className) ? new $className() : $className;
        for ($i = 0; $i < count($actions); $i++) {
            $actionAnnotations = Reaction::$annotations->getMethod($actions[$i], $className);
            if (!isset($actionAnnotations[CtrlAction::class])) {
                continue;
            }
            /** @var CtrlAction $ctrlAction */
            $ctrlAction = $actionAnnotations[CtrlAction::class];
            $path = $ctrlAnnotation->group . '/' . ltrim($ctrlAction->path, '/');
            $path = $path !== '/' ? rtrim($path, '/') : $path;
            $actionId = Controller::getActionId($actions[$i]);
            $this->addRoute($ctrlAction->method, $path, [$controller, $actionId]);
        }
    }
protected function registerControllerWithAnnotations ( $ className , Ctrl $ ctrlAnnotation ) { $ actions = ( new \ ReflectionClass ( $ className ) ) -> getMethods ( \ ReflectionMethod :: IS_PUBLIC ) ; $ actions = array_filter ( $ actions , function ( $ value ) { return $ value -> name !== 'actions' && strpos ( $ value -> name , 'action' ) === 0 ? $ value : false ; } ) ; $ actions = Reaction \ Helpers \ ArrayHelper :: getColumn ( $ actions , 'name' , false ) ; if ( empty ( $ actions ) ) { return ; } $ controller = is_string ( $ className ) ? new $ className ( ) : $ className ; for ( $ i = 0 ; $ i < count ( $ actions ) ; $ i ++ ) { $ actionAnnotations = Reaction :: $ annotations -> getMethod ( $ actions [ $ i ] , $ className ) ; if ( ! isset ( $ actionAnnotations [ CtrlAction :: class ] ) ) { continue ; } /** @var CtrlAction $ctrlAction */ $ ctrlAction = $ actionAnnotations [ CtrlAction :: class ] ; $ path = $ ctrlAnnotation -> group . '/' . ltrim ( $ ctrlAction -> path , '/' ) ; $ path = $ path !== '/' ? rtrim ( $ path , '/' ) : $ path ; $ actionId = Controller :: getActionId ( $ actions [ $ i ] ) ; $ this -> addRoute ( $ ctrlAction -> method , $ path , [ $ controller , $ actionId ] ) ; } }
Register controller that uses Annotations
@param string|Controller $className
@param Ctrl $ctrlAnnotation
@throws \ReflectionException
Register controller that uses Annotations