本文整理汇总了PHP中modResource::fromArray方法的典型用法代码示例。如果您正苦于以下问题:PHP modResource::fromArray方法的具体用法?PHP modResource::fromArray怎么用?PHP modResource::fromArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类modResource
的用法示例。
在下文中一共展示了modResource::fromArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
public function process()
{
if (!$this->validate()) {
return $this->failure();
}
$this->resource->fromArray($this->getProperties());
if ($this->resource->save() === false) {
return $this->failure($this->modx->lexicon('resource_err_save'));
}
return $this->success();
}
示例2: process
public function process(array $scriptProperties = array())
{
$placeholders = array();
$reloadData = $this->getReloadData();
$loaded = $this->getResource();
if ($loaded !== true) {
return $this->failure($loaded);
}
if (is_array($reloadData) && !empty($reloadData)) {
$this->resource->fromArray($reloadData);
}
/* get context */
$this->setContext();
/* check for locked status */
$this->checkForLocks();
/* set template overrides */
if (isset($scriptProperties['template'])) {
$this->resource->set('template', $scriptProperties['template']);
}
$this->setParent();
/* invoke OnDocFormRender event */
$this->fireOnRenderEvent();
/* check permissions */
$this->setPermissions();
/* register FC rules */
$this->resourceArray = $this->resource->toArray();
$overridden = $this->checkFormCustomizationRules($this->resource);
$this->resourceArray = array_merge($this->resourceArray, $overridden);
$this->resourceArray['published'] = intval($this->resourceArray['published']) == 1 ? true : false;
$this->resourceArray['hidemenu'] = intval($this->resourceArray['hidemenu']) == 1 ? true : false;
$this->resourceArray['isfolder'] = intval($this->resourceArray['isfolder']) == 1 ? true : false;
$this->resourceArray['richtext'] = intval($this->resourceArray['richtext']) == 1 ? true : false;
$this->resourceArray['searchable'] = intval($this->resourceArray['searchable']) == 1 ? true : false;
$this->resourceArray['cacheable'] = intval($this->resourceArray['cacheable']) == 1 ? true : false;
$this->resourceArray['deleted'] = intval($this->resourceArray['deleted']) == 1 ? true : false;
$this->resourceArray['uri_override'] = intval($this->resourceArray['uri_override']) == 1 ? true : false;
if (!empty($this->resourceArray['parent'])) {
if ($this->parent->get('id') == $this->resourceArray['parent']) {
$this->resourceArray['parent_pagetitle'] = $this->parent->get('pagetitle');
} else {
$overriddenParent = $this->modx->getObject('modResource', $this->resourceArray['parent']);
if ($overriddenParent) {
$this->resourceArray['parent_pagetitle'] = $overriddenParent->get('pagetitle');
}
}
}
/* get TVs */
$this->resource->set('template', $this->resourceArray['template']);
$this->prepareResource();
$this->loadTVs($reloadData);
$this->getPreviewUrl();
/* single-use token for reloading resource */
$this->setResourceToken();
$this->setPlaceholder('resource', $this->resource);
return $placeholders;
}
示例3: updateResource
public function updateResource($id, $tempDir)
{
include_once MODX_BASE_PATH . 'assets/lib/MODxAPI/modResource.php';
@rename(MODX_BASE_PATH . 'assets/images/' . $tempDir, MODX_BASE_PATH . 'assets/images/' . $this->params['contentDir'] . '/' . $id);
$doc = new \modResource($this->modx);
$fields = $doc->edit($id)->toArray();
foreach ($fields as &$field) {
if (is_string($field)) {
$field = str_replace($tempDir, $this->params['contentDir'] . '/' . $id, $field);
}
}
$doc->fromArray($fields)->save(false, true);
}