src/Sulu/Component/Content/Document/Subscriber/SecuritySubscriber.php
public function handleHydrate(HydrateEvent $event)
    {
        $document = $event->getDocument();
        $node = $event->getNode();

        if (!$this->supports($document)) {
            return;
        }

        $permissions = [];
        foreach ($node->getProperties('sec:*') as $property) {
            /** @var PropertyInterface $property */
            $roleId = substr($property->getName(), 9); // remove the "sec:role-" prefix

            $allowedPermissions = $property->getValue();

            foreach ($this->permissions as $permission => $value) {
                $permissions[$roleId][$permission] = in_array($permission, $allowedPermissions);
            }
        }

        $document->setPermissions($permissions);
    }
public function handleHydrate(HydrateEvent $event)
    {
        $document = $event->getDocument();
        $node = $event->getNode();

        if (!$this->supports($document)) {
            return;
        }

        $permissions = [];
        foreach ($node->getProperties('sec:*') as $property) {
            /** @var PropertyInterface $property */
            $roleId = substr($property->getName(), 9); // remove the "sec:role-" prefix

            $allowedPermissions = $property->getValue();

            foreach ($this->permissions as $permission => $value) {
                $permissions[$roleId][$permission] = in_array($permission, $allowedPermissions);
            }
        }

        $document->setPermissions($permissions);
    }
public function handleHydrate ( HydrateEvent $ event ) { $ document = $ event -> getDocument ( ) ; $ node = $ event -> getNode ( ) ; if ( ! $ this -> supports ( $ document ) ) { return ; } $ permissions = [ ] ; foreach ( $ node -> getProperties ( 'sec:*' ) as $ property ) { /** @var PropertyInterface $property */ $ roleId = substr ( $ property -> getName ( ) , 9 ) ; // remove the "sec:role-" prefix $ allowedPermissions = $ property -> getValue ( ) ; foreach ( $ this -> permissions as $ permission => $ value ) { $ permissions [ $ roleId ] [ $ permission ] = in_array ( $ permission , $ allowedPermissions ) ; } } $ document -> setPermissions ( $ permissions ) ; }
Adds the security information to the hydrated object.

@param HydrateEvent $event
Adds the security information to the hydrated object .