src/Yggdrasil/Utils/Form/FormHandler.php
public function handle(Request $request, string $method = self::HTTP_POST): bool
    {
        if (!$request->isMethod($method)) {
            return false;
        }

        if ($request->request->has('csrf_token')) {
            $session = new Session();

            if ($session->get('csrf_token') !== $request->request->get('csrf_token')) {
                throw new InvalidCsrfTokenException();
            }

            $request->request->remove('csrf_token');
        }

        $this->dataCollection = array_merge($request->request->all(), $request->files->all());

        return true;
    }
public function handle(Request $request, string $method = self::HTTP_POST): bool
    {
        if (!$request->isMethod($method)) {
            return false;
        }

        if ($request->request->has('csrf_token')) {
            $session = new Session();

            if ($session->get('csrf_token') !== $request->request->get('csrf_token')) {
                throw new InvalidCsrfTokenException();
            }

            $request->request->remove('csrf_token');
        }

        $this->dataCollection = array_merge($request->request->all(), $request->files->all());

        return true;
    }
public function handle ( Request $ request , string $ method = self :: HTTP_POST ) : bool { if ( ! $ request -> isMethod ( $ method ) ) { return false ; } if ( $ request -> request -> has ( 'csrf_token' ) ) { $ session = new Session ( ) ; if ( $ session -> get ( 'csrf_token' ) !== $ request -> request -> get ( 'csrf_token' ) ) { throw new InvalidCsrfTokenException ( ) ; } $ request -> request -> remove ( 'csrf_token' ) ; } $ this -> dataCollection = array_merge ( $ request -> request -> all ( ) , $ request -> files -> all ( ) ) ; return true ; }
Returns result of form submission

@param Request $request
@param string  $method Expected form HTTP method
@return bool
@throws InvalidCsrfTokenException if received CSRF token doesn't match token stored in session
Returns result of form submission