/** * Update (or create) an ACL. * * @param AclEvent $event ACL event. * * @throws PropelException */ public function aclUpdate(AclEvent $event) { // create the ACL if it does not exists if (null == ($acl = AclQuery::create()->findPk($event->getId()))) { $acl = new Acl(); } $acl->setCode($event->getCode())->setModuleId($event->getModuleId())->setLocale($event->getLocale())->setTitle($event->getTitle())->setDescription($event->getDescription())->save(); }
/** * Parse the acl in acl.xml file * @param SimpleXMLElement $xml The xml parsed by parseFile * @param Module $module The enabled module */ protected function parseAcls(SimpleXMLElement $xml, Module $module) { //If there are no acl node continue to parse the xml $acls = $xml->xpath('//config:acls/config:acl'); if (false === $acls) { return; } //Add the acl if they no exists and parse his descriptive /** @var SimpleXMLElement $acl */ foreach ($acls as $acl) { $code = $acl->getAttributeAsPHP("code"); if (AclQuery::create()->findOneByCode($code)) { continue; } $newAcl = new Acl(); $newAcl->setCode($code)->setModuleId($module->getId()); $newAcl->save(); $this->parseDescriptives($acl); } }