protected function validateAction($action, RequestApplicationInterface $app)
    {
        $annotationsCtrl = Reaction::$annotations->getClass($this);
        $annotationsAction = Reaction::$annotations->getMethod($action, $this);
        $annotations = ArrayHelper::merge(array_values($annotationsCtrl), array_values($annotationsAction));
        $promises = [];
        if (!empty($annotations)) {
            foreach ($annotations as $annotation) {
                if (!$annotation instanceof CtrlActionValidatorInterface) {
                    continue;
                }
                $promise = $annotation->validate($app);
                if (!$promise instanceof PromiseInterface) {
                    $promise = !empty($promise) ? resolve(true) : reject(false);
                    Reaction::warning("Controller validator '{class}' returned NOT a promise", [
                        'class' => get_class($annotation),
                    ]);
                }
                $promises[] = $promise;
                $promises[] = \Reaction\Promise\resolve(true);
            }
        }
        if (empty($promises)) {
            return resolve(true);
        }
        $all = \Reaction\Promise\all($promises);
        return $all;
    }
protected function validateAction($action, RequestApplicationInterface $app)
    {
        $annotationsCtrl = Reaction::$annotations->getClass($this);
        $annotationsAction = Reaction::$annotations->getMethod($action, $this);
        $annotations = ArrayHelper::merge(array_values($annotationsCtrl), array_values($annotationsAction));
        $promises = [];
        if (!empty($annotations)) {
            foreach ($annotations as $annotation) {
                if (!$annotation instanceof CtrlActionValidatorInterface) {
                    continue;
                }
                $promise = $annotation->validate($app);
                if (!$promise instanceof PromiseInterface) {
                    $promise = !empty($promise) ? resolve(true) : reject(false);
                    Reaction::warning("Controller validator '{class}' returned NOT a promise", [
                        'class' => get_class($annotation),
                    ]);
                }
                $promises[] = $promise;
                $promises[] = \Reaction\Promise\resolve(true);
            }
        }
        if (empty($promises)) {
            return resolve(true);
        }
        $all = \Reaction\Promise\all($promises);
        return $all;
    }
protected function validateAction ( $ action , RequestApplicationInterface $ app ) { $ annotationsCtrl = Reaction :: $ annotations -> getClass ( $ this ) ; $ annotationsAction = Reaction :: $ annotations -> getMethod ( $ action , $ this ) ; $ annotations = ArrayHelper :: merge ( array_values ( $ annotationsCtrl ) , array_values ( $ annotationsAction ) ) ; $ promises = [ ] ; if ( ! empty ( $ annotations ) ) { foreach ( $ annotations as $ annotation ) { if ( ! $ annotation instanceof CtrlActionValidatorInterface ) { continue ; } $ promise = $ annotation -> validate ( $ app ) ; if ( ! $ promise instanceof PromiseInterface ) { $ promise = ! empty ( $ promise ) ? resolve ( true ) : reject ( false ) ; Reaction :: warning ( "Controller validator '{class}' returned NOT a promise" , [ 'class' => get_class ( $ annotation ) , ] ) ; } $ promises [ ] = $ promise ; $ promises [ ] = \ Reaction \ Promise \ resolve ( true ) ; } } if ( empty ( $ promises ) ) { return resolve ( true ) ; } $ all = \ Reaction \ Promise \ all ( $ promises ) ; return $ all ; }
Validate that user can perform that action
@param string $action
@param RequestApplicationInterface $app
@return ExtendedPromiseInterface
Validate that user can perform that action