コード例 #1
0
ファイル: BasePolicyPeer.php プロジェクト: yasirgit/afids
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      Policy $value A Policy object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(Policy $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
コード例 #2
0
 /**
  *
  * Insert/Update an Policy on the database
  * @param Policy $policy
  * @throws Exception
  */
 private function _setPolicy(Policy &$policy, $insertMode = FALSE)
 {
     $method = "PUT";
     $url = E3_PROV_URL_POLICY . "/" . rawurlencode($policy->getId());
     if ($insertMode) {
         $method = "POST";
         $url = E3_PROV_URL_POLICY;
     }
     /**
      * Send the XML payload the the Provisioning Backend
      */
     LoggerInterface::log(($insertMode ? "Creating" : "Updating") . " Policy: {$policy->toXML()}\nEndpoint: ({$method}) {$url}", LoggerInterface::INFO);
     $reply = $this->restClient->makeCall($url, $method, $policy->toXML());
     $xml = simplexml_load_string($reply->getPayload());
     if ($reply->getHTTPCode() === "200") {
         if ($insertMode) {
             if ($policy->getId() == NULL) {
                 $policy->setId((string) $xml->id);
             }
         }
         return true;
     } else {
         $error = $insertMode ? "Unable to create policy" : "Unable to update policy with id: " . $policy->getId();
         // default error msg
         if ($xml != null) {
             $errorText = $xml->xpath('/response/error/errorText');
             // error msg from response
             if (count($errorText) > 0) {
                 $error = (string) $errorText[0];
             }
         }
         PolicyManager::error($error);
         return false;
     }
 }