Ejemplo n.º 1
0
 /**
  * @param string $moduleName
  * @param string $policyName
  * @return mixed|null|string
  */
 public function getExplicitActualPolicy($moduleName, $policyName)
 {
     assert('is_string($moduleName)');
     assert('is_string($policyName)');
     assert('$moduleName != ""');
     assert('$policyName != ""');
     if (!SECURITY_OPTIMIZED) {
         // The slow way will remain here as documentation
         // for what the optimized way is doing.
         foreach ($this->policies as $policy) {
             if ($policy->moduleName == $moduleName && $policy->name == $policyName) {
                 return $policy->value;
             }
         }
         return null;
     } else {
         $permitableId = $this->getClassId('Permitable');
         try {
             // not using $default because computing default value would involve extra cpu cycles each time.
             return PoliciesCache::getEntry($permitableId . $moduleName . $policyName . 'ExplicitActualPolicy');
         } catch (NotFoundException $e) {
             $explictActualPolicy = ZurmoDatabaseCompatibilityUtil::callFunction("get_permitable_explicit_actual_policy(\n                                                         {$permitableId}, '{$moduleName}', '{$policyName}')");
         }
         PoliciesCache::cacheEntry($permitableId . $moduleName . $policyName . 'ExplicitActualPolicy', $explictActualPolicy);
         return $explictActualPolicy;
     }
 }