コード例 #1
0
ファイル: AuthController.php プロジェクト: kyroskoh/apigrove
 /**
  * This is the on-enter callback for the "form" state
  * It will load the object needed to back the form.
  * @param $action
  * @param $flowScope
  */
 public function loadFormBacker($action, &$flowScope)
 {
     $registry = Zend_Registry::getInstance();
     $translate = $registry->get("Zend_Translate");
     // Default to using the id from the $flowScope
     $id = @$flowScope['authid'];
     // If that is empty then we use the one from the request
     if (empty($id)) {
         $id = $this->_getParam("id");
     }
     if (empty($id)) {
         throw new Zend_Controller_Action_Exception($translate->translate('Resource Not Found'), 404);
     }
     $howMany = !isset($flowScope['howMany']) ? "1" : $flowScope['howMany'];
     $flowScope['howMany'] = $howMany;
     // Set the id is the flowscope
     $flowScope['authid'] = $id;
     $auth = @$flowScope['auth'];
     /**
      * If the id is "create" and we haven't filled out the form before
      * then we need to create a new Auth and set some defaults
      */
     if ($id === "create" && $auth === null) {
         $auth = new Auth();
         $auth->id = $id;
         $auth->type = AuthType::$AUTHKEY;
         if (isset($flowScope['preSelectedAuthType'])) {
             $auth->type = $flowScope['preSelectedAuthType'];
             $flowScope['authTypeLocked'] = true;
         }
         $auth->apiContext = "actx";
         $auth->policyContext = "pctx";
         $flowScope['isNew'] = true;
     } else {
         if ($auth === null) {
             $authManager = new AuthManager();
             $auth = $authManager->getAuth($id);
             $flowScope['isNew'] = false;
             $flowScope["relatedProperties"] = JsonPropertyPrinter::getRelatedFromAuth($auth);
         }
     }
     /**
      * Put the auth in the flow scope for reference by other states and the views
      */
     $flowScope['auth'] = $auth;
 }