requestStack = $request_stack; $this->urlGenerator = $url_generator; } /** * {@inheritdoc} */ public function getAsArray() { return ['destination' => $this->get()]; } /** * {@inheritdoc} */ public function get() { if (!isset($this->destination)) { $query = $this->requestStack->getCurrentRequest()->query; if (UrlHelper::isExternal($query->get('destination'))) { $this->destination = '/'; } elseif ($query->has('destination')) { $this->destination = $query->get('destination'); } else { $this->destination = $this->urlGenerator->generateFromRoute('', [], ['query' => UrlHelper::filterQueryParameters($query->all())]); } } return $this->destination; } /** * {@inheritdoc} */ public function set($new_destination) { $this->destination = $new_destination; return $this; } }