コード例 #1
0
 /**
  * {@inheritDoc}
  */
 public function addRoles(\XLite\Model\Role $roles)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'addRoles', array($roles));
     return parent::addRoles($roles);
 }
コード例 #2
0
ファイル: Profile.php プロジェクト: kingsj/core
 /**
  * Update profile role 
  * 
  * @param \XLite\Model\Profile $profile Profile
  *  
  * @return void
  */
 protected function updateProfileRole(\XLite\Model\Profile $profile)
 {
     $rootRole = \XLite\Core\Database::getRepo('XLite\\Model\\Role')->findOneRoot();
     if (\XLite\Core\Auth::getInstance()->getAdminAccessLevel() == $profile->getAccessLevel()) {
         // Add root role
         if ($rootRole && !$profile->getRoles()->contains($rootRole)) {
             $profile->addRoles($rootRole);
             $rootRole->addProfiles($profile);
         }
     } else {
         // Remove root role
         if ($rootRole && $profile->getRoles()->contains($rootRole)) {
             $profile->getRoles()->removeElement($rootRole);
             $rootRole->getProfiles()->removeElement($profile);
         }
     }
     \XLite\Core\Database::getEM()->flush();
 }