Пример #1
0
         if ($policy === null) {
             $policy = $this->policyManager->getPolicy($id);
             $flowScope['isNew'] = false;
             $flowScope["relatedProperties"] = JsonPropertyPrinter::getRelatedFromPolicy($policy);
         }
     }
     /**
      * Put the policy in the flow scope for reference by other states and the views
      */
     $flowScope['policy'] = $policy;
 }
 /**
  * On-exit callback for the "form" state
  * it should take the form submission and deserialize it into a Policy object and
  * stick it on the flowScope.
  *
  * @param $action
  * @param $flowScope
  */
 public function deserializeForm($action, &$flowScope)
 {
     /**
      * @var Policy $policy
      */
     $policy = $flowScope['policy'];
     // Only accept the id if we are creating a new one
     if ($flowScope['isNew']) {
         $policy->id = $this->_getParam('policy_id');
     }
     $policy->setApiIds($this->getSelectedApis());
     $policy->setAuthIds($this->getSelectedAuths());
     $context = $this->getContextAndRates();
     if ($context != null) {
         $contexts[] = $context;
         $policy->setContexts($contexts);
     }
     $policy->headerTransformations = SharedViewUtility::deserializeHeaderTransformations($this->getRequest());
Пример #2
0
 /**
  * Callback function for the on-exit of the Auth subflow
  * We have already created the API and the Auth(s) so now we need to create a Policy
  * to hook them together
  * @param $action
  * @param $flowScope
  */
 public function postAuthSubflow($action, &$flowScope)
 {
     $registry = Zend_Registry::getInstance();
     $translate = $registry->get("Zend_Translate");
     $authIds = $flowScope['authIds'];
     /**  @var Api $api*/
     $api = $flowScope['api'];
     $policy = PolicyController::createBasicPolicy(null, array($api->id), $authIds);
     $pm = new PolicyManager();
     $result = $pm->createPolicy($policy);
     if ($result) {
         $this->_helper->FlashMessenger($translate->translate("Policy Created: ") . $policy->id);
     } else {
         $this->_helper->FlashMessenger($translate->translate("Error creating Policy"));
     }
 }