/** * @param ArhitectRequest $request * @param callable $next * * @return mixed */ public function handle(ArhitectRequest $request, callable $next) { switch ($request->getMethod()) { case Request::METHOD_POST: case Request::METHOD_PUT: case Request::METHOD_DELETE: $crossSiteForgeryToken = $request->any('csrf'); if (!$crossSiteForgeryToken || $crossSiteForgeryToken != $this->session->get('csrf', NULL)) { $this->session->getErrorsBag()->add('csrf', $this->translator->translate('The request has expired. Please submit the form again.')); } break; } return $next($request); }
/** * @param $key * @param array $params * * @return string */ public function translate($key, array $params = []) { return $this->translator->translate($key, $params); }
/** * @param $label * * @return string */ public function __invoke($label) { return $this->translator->translate($label); }