protected function execute(InputInterface $input, OutputInterface $output)
    {
        // Parse arguments
        $objectIdentities = array();
        $maskBuilder = new MaskBuilder();
        foreach ($input->getArgument('arguments') as $argument) {
            $data = explode(':', $argument, 2);

            if (count($data) > 1) {
                $objectIdentities[] = new ObjectIdentity($data[1], strtr($data[0], '/', '\\'));
            } else {
                $maskBuilder->add($data[0]);
            }
        }

        // Build permissions mask
        $mask = $maskBuilder->get();

        $userOption = $input->getOption('user');
        $roleOption = $input->getOption('role');
        $classScopeOption = $input->getOption('class-scope');

        if (empty($userOption) && empty($roleOption)) {
            throw new \InvalidArgumentException('A Role or a User must be specified.');
        }

        // Create security identities
        $securityIdentities = array();

        if ($userOption) {
            foreach ($userOption as $user) {
                $data = explode(':', $user, 2);

                if (1 === count($data)) {
                    throw new \InvalidArgumentException('The user must follow the format "Acme/MyUser:username".');
                }

                $securityIdentities[] = new UserSecurityIdentity($data[1], strtr($data[0], '/', '\\'));
            }
        }

        if ($roleOption) {
            foreach ($roleOption as $role) {
                $securityIdentities[] = new RoleSecurityIdentity($role);
            }
        }

        // Sets ACL
        foreach ($objectIdentities as $objectIdentity) {
            // Creates a new ACL if it does not already exist
            try {
                $this->provider->createAcl($objectIdentity);
            } catch (AclAlreadyExistsException $e) {
            }

            $acl = $this->provider->findAcl($objectIdentity, $securityIdentities);

            foreach ($securityIdentities as $securityIdentity) {
                if ($classScopeOption) {
                    $acl->insertClassAce($securityIdentity, $mask);
                } else {
                    $acl->insertObjectAce($securityIdentity, $mask);
                }
            }

            $this->provider->updateAcl($acl);
        }
    }
protected function execute(InputInterface $input, OutputInterface $output)
    {
        
        $objectIdentities = array();
        $maskBuilder = new MaskBuilder();
        foreach ($input->getArgument('arguments') as $argument) {
            $data = explode(':', $argument, 2);

            if (count($data) > 1) {
                $objectIdentities[] = new ObjectIdentity($data[1], strtr($data[0], '/', '\\'));
            } else {
                $maskBuilder->add($data[0]);
            }
        }

        
        $mask = $maskBuilder->get();

        $userOption = $input->getOption('user');
        $roleOption = $input->getOption('role');
        $classScopeOption = $input->getOption('class-scope');

        if (empty($userOption) && empty($roleOption)) {
            throw new \InvalidArgumentException('A Role or a User must be specified.');
        }

        
        $securityIdentities = array();

        if ($userOption) {
            foreach ($userOption as $user) {
                $data = explode(':', $user, 2);

                if (1 === count($data)) {
                    throw new \InvalidArgumentException('The user must follow the format "Acme/MyUser:username".');
                }

                $securityIdentities[] = new UserSecurityIdentity($data[1], strtr($data[0], '/', '\\'));
            }
        }

        if ($roleOption) {
            foreach ($roleOption as $role) {
                $securityIdentities[] = new RoleSecurityIdentity($role);
            }
        }

        
        foreach ($objectIdentities as $objectIdentity) {
            
            try {
                $this->provider->createAcl($objectIdentity);
            } catch (AclAlreadyExistsException $e) {
            }

            $acl = $this->provider->findAcl($objectIdentity, $securityIdentities);

            foreach ($securityIdentities as $securityIdentity) {
                if ($classScopeOption) {
                    $acl->insertClassAce($securityIdentity, $mask);
                } else {
                    $acl->insertObjectAce($securityIdentity, $mask);
                }
            }

            $this->provider->updateAcl($acl);
        }
    }
protected function execute ( InputInterface $ input , OutputInterface $ output ) { // Parse arguments $ objectIdentities = array ( ) ; $ maskBuilder = new MaskBuilder ( ) ; foreach ( $ input -> getArgument ( 'arguments' ) as $ argument ) { $ data = explode ( ':' , $ argument , 2 ) ; if ( count ( $ data ) > 1 ) { $ objectIdentities [ ] = new ObjectIdentity ( $ data [ 1 ] , strtr ( $ data [ 0 ] , '/' , '\\' ) ) ; } else { $ maskBuilder -> add ( $ data [ 0 ] ) ; } } // Build permissions mask $ mask = $ maskBuilder -> get ( ) ; $ userOption = $ input -> getOption ( 'user' ) ; $ roleOption = $ input -> getOption ( 'role' ) ; $ classScopeOption = $ input -> getOption ( 'class-scope' ) ; if ( empty ( $ userOption ) && empty ( $ roleOption ) ) { throw new \ InvalidArgumentException ( 'A Role or a User must be specified.' ) ; } // Create security identities $ securityIdentities = array ( ) ; if ( $ userOption ) { foreach ( $ userOption as $ user ) { $ data = explode ( ':' , $ user , 2 ) ; if ( 1 === count ( $ data ) ) { throw new \ InvalidArgumentException ( 'The user must follow the format "Acme/MyUser:username".' ) ; } $ securityIdentities [ ] = new UserSecurityIdentity ( $ data [ 1 ] , strtr ( $ data [ 0 ] , '/' , '\\' ) ) ; } } if ( $ roleOption ) { foreach ( $ roleOption as $ role ) { $ securityIdentities [ ] = new RoleSecurityIdentity ( $ role ) ; } } // Sets ACL foreach ( $ objectIdentities as $ objectIdentity ) { // Creates a new ACL if it does not already exist try { $ this -> provider -> createAcl ( $ objectIdentity ) ; } catch ( AclAlreadyExistsException $ e ) { } $ acl = $ this -> provider -> findAcl ( $ objectIdentity , $ securityIdentities ) ; foreach ( $ securityIdentities as $ securityIdentity ) { if ( $ classScopeOption ) { $ acl -> insertClassAce ( $ securityIdentity , $ mask ) ; } else { $ acl -> insertObjectAce ( $ securityIdentity , $ mask ) ; } } $ this -> provider -> updateAcl ( $ acl ) ; } }
{@inheritdoc}
{