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


PHP Engine::get方法代码示例

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


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

示例1: collect

 public static function collect(array $intents)
 {
     $intents = array_map(function (Intent $intent) {
         return self::convertIntentToArray($intent);
     }, array_values($intents));
     $finalArray = [];
     foreach ($intents as $intent) {
         foreach ($intent['fields'] as $field) {
             foreach ($field['profiles'] as $profile) {
                 $finalArray['' . $profile] = true;
             }
         }
     }
     return ['intents' => $intents, 'profiles' => array_map(function ($identifier) {
         return self::convertValidationProfileToArray(Engine::get()->getValidationProfile($identifier));
     }, array_keys($finalArray))];
 }
开发者ID:projectstorm,项目名称:php-actions,代码行数:17,代码来源:RightsDesignerBootstrap.php

示例2: validate

 /**
  * Validates that we can actually use this action
  * @param IntentPayload $payload
  */
 public function validate(IntentPayload $payload, $throw = true)
 {
     $payload->setIntent($this);
     //is this intent allowed at all?
     if (!Engine::get()->isIntentAllowed($this)) {
         if ($throw) {
             throw new ValidationException("Rights check failed for intent: [{$this->getName()}]: not allowed to access this intent.");
         }
         return false;
     }
     $checksPassed = 0;
     $shouldParametersBeValidated = Engine::get()->shouldParametersBeValidated($this);
     if (count($this->inputParameters) == 0) {
         return true;
     }
     //yes it is allowed, now validate each parameter
     //for each parameter we have, we must find the value in the payload
     foreach ($this->inputParameters as $parameter) {
         //check to see if the parameter exists
         if (!$payload->parameterExists($parameter->getName())) {
             if (!$throw) {
                 return false;
             }
             throw new ValidationException("Rights check failed for intent: [{$this->getName()}] on parameter: [{$parameter->getName()}] " . "because the input variable was not found");
         }
         //should we check parameters (useful if the user is an admin in your system, because you can then skip this step)
         if ($shouldParametersBeValidated) {
             //now we need to find validators for the nodes
             $profiles = Engine::get()->getValidationProfilesForIntentParameter($this, $parameter);
             //validate each profile which contains an entry node
             $failures = [];
             $success = 0;
             foreach ($profiles as $profile) {
                 try {
                     $result = $profile->validate($payload->get($parameter->getName()));
                 } catch (ValidationException $ex) {
                     $failures[] = "Rights check failed for intent: [{$this->getName()}] on parameter: [{$parameter->getName()}] reason: [{$ex->getMessage()}]";
                     continue;
                 }
                 //and use the value from the payload (if ever a payload returns false, then we know something went wrong, but always prefer exceptions)
                 if ($result === false) {
                     $failures[] = "Rights check failed for intent: [{$this->getName()}] on parameter: [{$parameter->getName()}]";
                     continue;
                 }
                 $checksPassed++;
                 $success++;
             }
             //there were failures and nothing was successful
             if ($success == 0 && count($failures) > 0) {
                 if (!$throw) {
                     return false;
                 }
                 throw new ValidationException(implode(',', $failures));
             }
         }
     }
     //if this happens, it means we didnt find any profiles
     if ($checksPassed == 0 && $shouldParametersBeValidated) {
         if (!$throw) {
             return false;
         }
         throw new ValidationException("Rights check failed for intent: [{$this->getName()}] because there were no profiles setup to test with");
     }
     //all checks passed
     return true;
 }
开发者ID:projectstorm,项目名称:php-actions,代码行数:70,代码来源:Intent.php

示例3: serialize

 public function serialize()
 {
     return ["type" => Engine::get()->getValidationNodeFactoryForClass(get_class($this))->getName()];
 }
开发者ID:projectstorm,项目名称:php-actions,代码行数:4,代码来源:ValidationNode.php

示例4: deserialize

 public function deserialize($data)
 {
     parent::deserialize($data);
     $this->profile = Engine::get()->getValidationProfile($data['external']);
 }
开发者ID:projectstorm,项目名称:php-actions,代码行数:5,代码来源:ValidationProfileNode.php


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