当前位置: 首页>>代码示例>>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;未经允许,请勿转载。