當前位置: 首頁>>代碼示例>>PHP>>正文


PHP xPDOObject::fromArray方法代碼示例

本文整理匯總了PHP中xPDOObject::fromArray方法的典型用法代碼示例。如果您正苦於以下問題:PHP xPDOObject::fromArray方法的具體用法?PHP xPDOObject::fromArray怎麽用?PHP xPDOObject::fromArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在xPDOObject的用法示例。


在下文中一共展示了xPDOObject::fromArray方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: delete

 /**
  * Handle DELETE requests
  * @return array
  */
 public function delete()
 {
     $id = $this->getProperty($this->primaryKeyField, false);
     if (empty($id)) {
         return $this->failure($this->modx->lexicon('rest.err_field_ns', array('field' => $this->primaryKeyField)));
     }
     $c = $this->getPrimaryKeyCriteria($id);
     $this->object = $this->modx->getObject($this->classKey, $c);
     if (empty($this->object)) {
         return $this->failure($this->modx->lexicon('rest.err_obj_nf', array('class_key' => $this->classKey)));
     }
     if (!empty($this->deleteRequiredFields)) {
         if (!$this->checkRequiredFields($this->deleteRequiredFields)) {
             return $this->failure();
         }
     }
     $this->object->fromArray($this->getProperties());
     $beforeDelete = $this->beforeDelete();
     if ($beforeDelete !== true) {
         return $this->failure($beforeDelete === false ? $this->errorMessage : $beforeDelete);
     }
     if (!$this->object->{$this->deleteMethod}()) {
         $this->setObjectErrors();
         return $this->failure($this->modx->lexicon('rest.err_class_remove', array('class_key' => $this->classKey)));
     }
     $objectArray = $this->object->toArray();
     $this->afterDelete($objectArray);
     return $this->success('', $objectArray);
 }
開發者ID:ChrstnMgcn,項目名稱:revolution,代碼行數:33,代碼來源:modrestcontroller.class.php

示例2: process

 /**
  * {@inheritDoc}
  * @return mixed
  */
 public function process()
 {
     /* Run the beforeSet method before setting the fields, and allow stoppage */
     $canSave = $this->beforeSet();
     if ($canSave !== true) {
         return $this->failure($canSave);
     }
     $this->newObject->fromArray($this->object->toArray());
     $name = $this->getNewName();
     $this->setNewName($name);
     if ($this->alreadyExists($name)) {
         $this->addFieldError($this->nameField, $this->modx->lexicon($this->objectType . '_err_ae', array('name' => $name)));
     }
     $canSave = $this->beforeSave();
     if ($canSave !== true) {
         return $this->failure($canSave);
     }
     /* save new chunk */
     if ($this->newObject->save() === false) {
         $this->modx->error->checkValidation($this->newObject);
         return $this->failure($this->modx->lexicon($this->objectType . '_err_duplicate'));
     }
     $this->afterSave();
     $this->logManagerAction();
     return $this->cleanup();
 }
開發者ID:e-gob,項目名稱:apps.gob.cl,代碼行數:30,代碼來源:modprocessor.class.php


注:本文中的xPDOObject::fromArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。