Exemplo n.º 1
0
 public function load($aclData)
 {
     $aclProvider = $this->container->get('bbapp')->getSecurityContext()->getACLProvider();
     if (null === $aclProvider) {
         throw new \RuntimeException('ACL configuration missing');
     }
     $this->em = $this->container->get('bbapp')->getEntityManager();
     $this->bbapp = $this->container->get('bbapp');
     $grid = Yaml::parse($aclData, true);
     if (false === array_key_exists('groups', $grid) || false === is_array($grid['groups'])) {
         throw new \Exception('Invalid yml: ' . $ymlFile);
     }
     foreach ($grid['groups'] as $group_name => $rights) {
         if (null === ($group = $this->em->getRepository('BackBee\\Security\\Group')->findOneBy(array('_name' => $group_name)))) {
             // ensure group exists
             $group = new \BackBee\Security\Group();
             $group->setName($group_name);
             $this->em->persist($group);
             $this->em->flush($group);
         }
         $securityIdentity = new UserSecurityIdentity($group->getObjectIdentifier(), get_class($group));
         if (true === array_key_exists('sites', $rights)) {
             $sites = $this->addSiteRights($rights['sites'], $aclProvider, $securityIdentity);
             foreach ($sites as $site) {
                 if (true === array_key_exists('layouts', $rights)) {
                     $this->addLayoutRights($rights['layouts'], $sites, $aclProvider, $securityIdentity);
                 }
             }
             if (true === array_key_exists('pages', $rights)) {
                 $this->addPageRights($rights['pages'], $aclProvider, $securityIdentity);
             }
             if (true === array_key_exists('mediafolders', $rights)) {
                 $this->addFolderRights($rights['mediafolders'], $aclProvider, $securityIdentity);
             }
             if (true === array_key_exists('contents', $rights)) {
                 $this->addContentRights($rights['contents'], $aclProvider, $securityIdentity);
             }
             if (true === array_key_exists('bundles', $rights)) {
                 $this->addBundleRights($rights['bundles'], $aclProvider, $securityIdentity);
             }
         }
     }
 }
Exemplo n.º 2
0
             $em->persist($mediafolder);
         }
     }
     if (null === $em->find('BackBee\\NestedNode\\KeyWord', md5('root'))) {
         $keyword = new \BackBee\NestedNode\KeyWord(md5('root'));
         $keyword->setRoot($keyword);
         $keyword->setKeyWord('root');
         $em->persist($keyword);
     }
     $em->flush();
     $step = 5;
     $yamlParser = new \Symfony\Component\Yaml\Parser();
     $groups = $yamlParser->parse(file_get_contents(\BackBee\Standard\Application::getConfigurationDir() . 'groups.yml'));
     foreach ($groups as $groupName => $rights) {
         $group = new \BackBee\Security\Group();
         $group->setName($groupName);
         if (array_key_exists('description', $rights)) {
             $group->setDescription($rights['description']);
             unset($rights['description']);
         }
         $group->setSite($site);
         $em->persist($group);
         $em->flush($group);
         setSiteGroupRights($site, $group, $rights);
     }
 }
 $containerDumpDir = $application->getContainer()->getParameter('container.dump_directory');
 foreach (glob($containerDumpDir . DIRECTORY_SEPARATOR . '*') as $file) {
     if (is_file($file)) {
         unlink($file);
     }