当前位置: 首页>>代码示例>>PHP>>正文


PHP Role::getRoleByName方法代码示例

本文整理汇总了PHP中Role::getRoleByName方法的典型用法代码示例。如果您正苦于以下问题:PHP Role::getRoleByName方法的具体用法?PHP Role::getRoleByName怎么用?PHP Role::getRoleByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Role的用法示例。


在下文中一共展示了Role::getRoleByName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 public static function run($allRules = false)
 {
     $database = Database::singleton();
     Notifications::addLog('------------------------- EXEC ENGINE STARTED -------------------------', 'ExecEngine');
     // Load the execEngine functions (security hazard :P)
     $files = getDirectoryList(__DIR__ . '/functions');
     foreach ($files as $file) {
         if (substr($file, -3) !== 'php') {
             continue;
         }
         require_once __DIR__ . '/functions/' . $file;
         Notifications::addLog('Included file: ' . __DIR__ . '/functions/' . $file, 'ExecEngine');
     }
     self::$roleName = Config::get('execEngineRoleName', 'execEngine');
     $role = Role::getRoleByName(self::$roleName);
     $maxRunCount = Config::get('maxRunCount', 'execEngine');
     self::$runCount = 0;
     self::$autoRerun = Config::get('autoRerun', 'execEngine');
     if ($role) {
         // Get all rules that are maintained by the ExecEngine
         while (self::$doRun) {
             self::$doRun = false;
             self::$runCount++;
             if (self::$runCount > $maxRunCount) {
                 throw new Exception('Maximum reruns exceeded for ExecEngine (rules with violations:' . implode(', ', $rulesThatHaveViolations) . ')', 500);
             }
             Notifications::addLog("ExecEngine run #" . self::$runCount . " (auto rerun: " . var_export(self::$autoRerun, true) . ") for role '" . $role->label . "'", 'ExecEngine');
             // Determine affected rules that must be checked by the exec engine
             $affectedConjuncts = (array) RuleEngine::getAffectedInvConjuncts($database->getAffectedConcepts(), $database->getAffectedRelations());
             $affectedConjuncts = array_merge($affectedConjuncts, (array) RuleEngine::getAffectedSigConjuncts($database->getAffectedConcepts(), $database->getAffectedRelations()));
             $affectedRules = array();
             foreach ($affectedConjuncts as $conjunctId) {
                 $conjunct = RuleEngine::getConjunct($conjunctId);
                 foreach ($conjunct['invariantRuleNames'] as $ruleName) {
                     $affectedRules[] = $ruleName;
                 }
                 foreach ($conjunct['signalRuleNames'] as $ruleName) {
                     $affectedRules[] = $ruleName;
                 }
             }
             // Check rules
             $rulesThatHaveViolations = array();
             foreach ($role->maintains() as $ruleName) {
                 if (!in_array($ruleName, $affectedRules) && !$allRules) {
                     continue;
                 }
                 // skip this rule
                 $rule = RuleEngine::getRule($ruleName);
                 $violations = RuleEngine::checkRule($rule, false);
                 if (count($violations)) {
                     $rulesThatHaveViolations[] = $rule['name'];
                     // Fix violations for every rule
                     ExecEngine::fixViolations($rule, $violations);
                     // Conjunct violations are not cached, because they are fixed by the ExecEngine
                     // If $autoRerun, set $doRun to true because violations have been fixed (this may fire other execEngine rules)
                     if (self::$autoRerun) {
                         self::$doRun = true;
                     }
                 }
             }
         }
     } else {
         Notifications::addInfo("ExecEngine extension included but role '" . self::$roleName . "' not found.");
     }
     Notifications::addLog('------------------------- END OF EXEC ENGINE -------------------------', 'ExecEngine');
 }
开发者ID:4ZP6Capstone2015,项目名称:ampersand,代码行数:66,代码来源:ExecEngine.php

示例2: addRole

 /**
  * Add roles to user to make them a concierge
  */
 public function addRole($name)
 {
     $role_id = Role::getRoleByName($name);
     $this->roles()->attach($role_id);
 }
开发者ID:bizcoine,项目名称:ecoinstrader,代码行数:8,代码来源:User.php

示例3: createUserImport

 public function createUserImport($form, $sendEmail = true)
 {
     $values = $form->getValues();
     $pass = Base_PasswordGenerator::generate();
     $values['password'] = $pass['hashed'];
     if ($values['symbol'] != '') {
         /**
          * 1. odnalezenia brancha o podanym symbolu (pole "symbol") w polu profil w danych z csv.
          * 2. dopisanie do profile "id_branch", "id_user", "landing" zawsze na /contact
          * 3. dopisanie uprawnien dla usera do grupy uprawnien "logowanie"
          * 4. dopisanie uprawnien dla usera do konkretnej roli szukanej po nazwie podanej w danych z csv z userami w polu "rola".
          */
         $branchModel = new Branch();
         $branch = $branchModel->getBranchBySymbol($values['symbol']);
         if (isset($branch['id'])) {
             $valuesProfile['id_branch'] = $branch['id'];
             $valuesProfile['landing'] = '/contact';
         }
         if ($values['rola'] != '') {
             $roleModel = new Role();
             $rola = $roleModel->getRoleByName($values['rola']);
             if (isset($rola['id'])) {
                 $valuesRole['id_role'] = $rola['id'];
                 $valuesRole['id_profile'] = '';
                 // po dodaniu profilu wstawiamy jego id.
             }
         }
     }
     if (isset($values['symbol'])) {
         unset($values['symbol']);
     }
     if (isset($values['rola'])) {
         unset($values['rola']);
     }
     $user = new User();
     $row = $user->createRow($values);
     $id_user = $row->save();
     if (is_array($valuesProfile)) {
         $valuesProfile['id_user'] = $id_user;
         $profile = new Profile();
         $rowProfile = $profile->createRow($valuesProfile);
         $id_profile = $rowProfile->save();
         if (isset($id_profile) && isset($valuesRole['id_role'])) {
             $valuesRole['id_profile'] = $id_profile;
             $role = new ProfileRole();
             $rowRole = $role->createRow($valuesRole);
             $id_role = $rowRole->save();
             $valuesProfileGroup['id_profile'] = $id_profile;
             $valuesProfileGroup['id_group'] = 5;
             $profileGroup = new ProfileGroup();
             $rowProfileGroup = $profileGroup->createRow($valuesProfileGroup);
             $id_profile_group = $rowProfileGroup->save();
         }
     }
     $passwordData['id_user'] = $id_user;
     $passwordData['password'] = $pass['hashed'];
     $userPassword = new UserPassword();
     $rowPassword = $userPassword->createRow($passwordData);
     $rowPassword->save();
     /*
      if($sendEmail == true) {
      $mailer = new Logic_Mailer(Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('view'), $translate);
      $user_row = $user->findOne($id_user);
      $mailer->userPass($pass['clean'], $user_row);
      }
     */
 }
开发者ID:knatorski,项目名称:SMS,代码行数:67,代码来源:User.php


注:本文中的Role::getRoleByName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。