Sulu\Bundle\PreviewBundle\Preview\Events\PreRenderEvent::getAttribute PHP Method

getAttribute() public method

Returns request attribute with given name.
public getAttribute ( string $name, mixed | null $default = null ) : mixed
$name string
$default mixed | null
return mixed
    public function getAttribute($name, $default = null)
    {
        return $this->requestAttributes->getAttribute($name, $default);
    }

Usage Example

Example #1
0
 /**
  * Set locale to translator.
  *
  * @param PreRenderEvent $event
  */
 public function setLocaleOnPreviewPreRender(PreRenderEvent $event)
 {
     $this->translator->setLocale($event->getAttribute('locale'));
 }