src/Util/ObjectAclManipulator.php
public function configureAcls(
        OutputInterface $output,
        AdminInterface $admin,
        \Traversable $oids,
        UserSecurityIdentity $securityIdentity = null
    ) {
        $countAdded = 0;
        $countUpdated = 0;
        $securityHandler = $admin->getSecurityHandler();
        if (!$securityHandler instanceof AclSecurityHandlerInterface) {
            $output->writeln(sprintf('Admin `%s` is not configured to use ACL : <info>ignoring</info>', $admin->getCode()));

            return [0, 0];
        }

        $acls = $securityHandler->findObjectAcls($oids);

        foreach ($oids as $oid) {
            if ($acls->contains($oid)) {
                $acl = $acls->offsetGet($oid);
                ++$countUpdated;
            } else {
                $acl = $securityHandler->createAcl($oid);
                ++$countAdded;
            }

            if (null !== $securityIdentity) {
                // add object owner
                $securityHandler->addObjectOwner($acl, $securityIdentity);
            }

            $securityHandler->addObjectClassAces($acl, $securityHandler->buildSecurityInformation($admin));

            try {
                $securityHandler->updateAcl($acl);
            } catch (\Exception $e) {
                $output->writeln(sprintf('Error saving ObjectIdentity (%s, %s) ACL : %s <info>ignoring</info>', $oid->getIdentifier(), $oid->getType(), $e->getMessage()));
            }
        }

        return [$countAdded, $countUpdated];
    }
public function configureAcls(
        OutputInterface $output,
        AdminInterface $admin,
        \Traversable $oids,
        UserSecurityIdentity $securityIdentity = null
    ) {
        $countAdded = 0;
        $countUpdated = 0;
        $securityHandler = $admin->getSecurityHandler();
        if (!$securityHandler instanceof AclSecurityHandlerInterface) {
            $output->writeln(sprintf('Admin `%s` is not configured to use ACL : <info>ignoring</info>', $admin->getCode()));

            return [0, 0];
        }

        $acls = $securityHandler->findObjectAcls($oids);

        foreach ($oids as $oid) {
            if ($acls->contains($oid)) {
                $acl = $acls->offsetGet($oid);
                ++$countUpdated;
            } else {
                $acl = $securityHandler->createAcl($oid);
                ++$countAdded;
            }

            if (null !== $securityIdentity) {
                // add object owner
                $securityHandler->addObjectOwner($acl, $securityIdentity);
            }

            $securityHandler->addObjectClassAces($acl, $securityHandler->buildSecurityInformation($admin));

            try {
                $securityHandler->updateAcl($acl);
            } catch (\Exception $e) {
                $output->writeln(sprintf('Error saving ObjectIdentity (%s, %s) ACL : %s <info>ignoring</info>', $oid->getIdentifier(), $oid->getType(), $e->getMessage()));
            }
        }

        return [$countAdded, $countUpdated];
    }
public function configureAcls ( OutputInterface $ output , AdminInterface $ admin , \ Traversable $ oids , UserSecurityIdentity $ securityIdentity = null ) { $ countAdded = 0 ; $ countUpdated = 0 ; $ securityHandler = $ admin -> getSecurityHandler ( ) ; if ( ! $ securityHandler instanceof AclSecurityHandlerInterface ) { $ output -> writeln ( sprintf ( 'Admin `%s` is not configured to use ACL : <info>ignoring</info>' , $ admin -> getCode ( ) ) ) ; return [ 0 , 0 ] ; } $ acls = $ securityHandler -> findObjectAcls ( $ oids ) ; foreach ( $ oids as $ oid ) { if ( $ acls -> contains ( $ oid ) ) { $ acl = $ acls -> offsetGet ( $ oid ) ; ++ $ countUpdated ; } else { $ acl = $ securityHandler -> createAcl ( $ oid ) ; ++ $ countAdded ; } if ( null !== $ securityIdentity ) { // add object owner $ securityHandler -> addObjectOwner ( $ acl , $ securityIdentity ) ; } $ securityHandler -> addObjectClassAces ( $ acl , $ securityHandler -> buildSecurityInformation ( $ admin ) ) ; try { $ securityHandler -> updateAcl ( $ acl ) ; } catch ( \ Exception $ e ) { $ output -> writeln ( sprintf ( 'Error saving ObjectIdentity (%s, %s) ACL : %s <info>ignoring</info>' , $ oid -> getIdentifier ( ) , $ oid -> getType ( ) , $ e -> getMessage ( ) ) ) ; } } return [ $ countAdded , $ countUpdated ] ; }
Configure the object ACL for the passed object identities.

@throws \Exception

@return array [countAdded, countUpdated]
Configure the object ACL for the passed object identities .