public function isLinkVerified(Request $request, Component $component): bool
    {
        try {
            $parameters = $request->getParameters();
            if (isset($parameters[Presenter::SIGNAL_KEY])) {
                // No need to check anything else, the requirements for presenter,
                // action and component had to be met for the current request.
                $signalId = $parameters[Presenter::SIGNAL_KEY];
                if (!is_string($signalId)) {
                    throw new InvalidArgumentException('Signal name is not a string.');
                }

                $pos = strrpos($signalId, '-');
                if ($pos !== false) {
                    // signal for a component
                    $name = $component->getUniqueId();
                    if ($name !== substr($signalId, 0, $pos)) {
                        throw new InvalidArgumentException("Wrong signal receiver, expected '".substr($signalId, 0, $pos)."' component but '$name' was given.");
                    }
                    $reflection = new ComponentReflection($component);
                    $signal = substr($signalId, $pos + 1);
                } else {
                    // signal for presenter
                    $name = null;
                    $presenter = $request->getPresenterName();
                    $reflection = new ComponentReflection($this->presenterFactory->getPresenterClass($presenter));
                    $signal = $signalId;
                }

                // Signal requirements
                $method = 'handle'.$signal;
                if ($reflection->hasCallableMethod($method)) {
                    $this->checkReflection($reflection->getMethod($method), $request, $name);
                }
            } else {
                $presenter = $request->getPresenterName();
                $reflection = new ComponentReflection($this->presenterFactory->getPresenterClass($presenter));

                // Presenter requirements
                $this->checkReflection($reflection, $request);

                // Action requirements
                $action = $parameters[Presenter::ACTION_KEY];
                $method = 'action'.$action;
                if ($reflection->hasCallableMethod($method)) {
                    $this->checkReflection($reflection->getMethod($method), $request);
                }
            }
        } catch (VerificationException $e) {
            return false;
        }

        return true;
    }
public function isLinkVerified(Request $request, Component $component): bool
    {
        try {
            $parameters = $request->getParameters();
            if (isset($parameters[Presenter::SIGNAL_KEY])) {
                // No need to check anything else, the requirements for presenter,
                // action and component had to be met for the current request.
                $signalId = $parameters[Presenter::SIGNAL_KEY];
                if (!is_string($signalId)) {
                    throw new InvalidArgumentException('Signal name is not a string.');
                }

                $pos = strrpos($signalId, '-');
                if ($pos !== false) {
                    // signal for a component
                    $name = $component->getUniqueId();
                    if ($name !== substr($signalId, 0, $pos)) {
                        throw new InvalidArgumentException("Wrong signal receiver, expected '".substr($signalId, 0, $pos)."' component but '$name' was given.");
                    }
                    $reflection = new ComponentReflection($component);
                    $signal = substr($signalId, $pos + 1);
                } else {
                    // signal for presenter
                    $name = null;
                    $presenter = $request->getPresenterName();
                    $reflection = new ComponentReflection($this->presenterFactory->getPresenterClass($presenter));
                    $signal = $signalId;
                }

                // Signal requirements
                $method = 'handle'.$signal;
                if ($reflection->hasCallableMethod($method)) {
                    $this->checkReflection($reflection->getMethod($method), $request, $name);
                }
            } else {
                $presenter = $request->getPresenterName();
                $reflection = new ComponentReflection($this->presenterFactory->getPresenterClass($presenter));

                // Presenter requirements
                $this->checkReflection($reflection, $request);

                // Action requirements
                $action = $parameters[Presenter::ACTION_KEY];
                $method = 'action'.$action;
                if ($reflection->hasCallableMethod($method)) {
                    $this->checkReflection($reflection->getMethod($method), $request);
                }
            }
        } catch (VerificationException $e) {
            return false;
        }

        return true;
    }
public function isLinkVerified ( Request $ request , Component $ component ) : bool { try { $ parameters = $ request -> getParameters ( ) ; if ( isset ( $ parameters [ Presenter :: SIGNAL_KEY ] ) ) { // No need to check anything else, the requirements for presenter, // action and component had to be met for the current request. $ signalId = $ parameters [ Presenter :: SIGNAL_KEY ] ; if ( ! is_string ( $ signalId ) ) { throw new InvalidArgumentException ( 'Signal name is not a string.' ) ; } $ pos = strrpos ( $ signalId , '-' ) ; if ( $ pos !== false ) { // signal for a component $ name = $ component -> getUniqueId ( ) ; if ( $ name !== substr ( $ signalId , 0 , $ pos ) ) { throw new InvalidArgumentException ( "Wrong signal receiver, expected '" . substr ( $ signalId , 0 , $ pos ) . "' component but '$name' was given." ) ; } $ reflection = new ComponentReflection ( $ component ) ; $ signal = substr ( $ signalId , $ pos + 1 ) ; } else { // signal for presenter $ name = null ; $ presenter = $ request -> getPresenterName ( ) ; $ reflection = new ComponentReflection ( $ this -> presenterFactory -> getPresenterClass ( $ presenter ) ) ; $ signal = $ signalId ; } // Signal requirements $ method = 'handle' . $ signal ; if ( $ reflection -> hasCallableMethod ( $ method ) ) { $ this -> checkReflection ( $ reflection -> getMethod ( $ method ) , $ request , $ name ) ; } } else { $ presenter = $ request -> getPresenterName ( ) ; $ reflection = new ComponentReflection ( $ this -> presenterFactory -> getPresenterClass ( $ presenter ) ) ; // Presenter requirements $ this -> checkReflection ( $ reflection , $ request ) ; // Action requirements $ action = $ parameters [ Presenter :: ACTION_KEY ] ; $ method = 'action' . $ action ; if ( $ reflection -> hasCallableMethod ( $ method ) ) { $ this -> checkReflection ( $ reflection -> getMethod ( $ method ) , $ request ) ; } } } catch ( VerificationException $ e ) { return false ; } return true ; }
Checks whether it is possible to run the given request.
Checks whether it is possible to run the given request .