예제 #1
0
 /**
  *
  * @param BOL_AuthorizationAction $action
  * @param array $labels ex.: array('en' => 'Colour', 'en-US' => 'Color')
  */
 public function addAction(BOL_AuthorizationAction $action, array $labels)
 {
     if ($action === null) {
         throw new InvalidArgumentException('action cannot be null');
     }
     $this->actionDao->save($action);
     $group = $this->groupDao->findById($action->groupId);
     foreach ($labels as $tag => $label) {
         $lang = BOL_LanguageService::getInstance()->findByTag($tag);
         if ($lang !== null) {
             $key = 'authorization_action_' . strtolower($group->name) . '_' . strtolower($action->name);
             try {
                 BOL_LanguageService::getInstance()->addValue($lang->id, 'base', $key, $label);
             } catch (Exception $e) {
             }
         }
     }
     $roles = $this->getRoleList();
     foreach ($roles as $role) {
         $this->grantActionListToRole($role, array($action));
     }
 }