本文整理汇总了PHP中CStoredObject::loadFwdRef方法的典型用法代码示例。如果您正苦于以下问题:PHP CStoredObject::loadFwdRef方法的具体用法?PHP CStoredObject::loadFwdRef怎么用?PHP CStoredObject::loadFwdRef使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStoredObject
的用法示例。
在下文中一共展示了CStoredObject::loadFwdRef方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _toDOM
/**
* Internal DOM export method
*
* @param CStoredObject $object Object to export
* @param int $depth Export depth
*
* @return void
*/
private function _toDOM(CStoredObject $object, $depth)
{
if ($depth == 0 || !$object->_id || !$object->getPerm(PERM_READ)) {
return;
}
$doc = $this->doc;
$object_node = $doc->getElementById($object->_guid);
// Objet deja exporté
if ($object_node) {
return;
}
$object_node = $doc->createElement("object");
$object_node->setAttribute('class', $object->_class);
$object_node->setAttribute('id', $object->_guid);
$object_node->setIdAttribute('id', true);
$doc->documentElement->appendChild($object_node);
$db_fields = $object->getPlainFields();
foreach ($db_fields as $key => $value) {
// Forward Refs Fields
$_fwd_spec = $object->_specs[$key];
if ($_fwd_spec instanceof CRefSpec) {
if ($key === $object->_spec->key && $object->_specs[$key]->className !== $object->_class) {
continue;
}
if (!isset($this->fwdrefs_tree[$object->_class]) || !in_array($key, $this->fwdrefs_tree[$object->_class])) {
continue;
}
$object->loadFwdRef($key);
$guid = "";
$_object = $object->_fwd[$key];
if ($_object && $_object->_id) {
$this->_toDOM($_object, $depth - 1);
$guid = $_object->_guid;
}
if ($this->empty_values || $guid) {
$object_node->setAttribute($key, $guid);
//$doc->insertTextElement($object_node, "field", $id, array("name" => $key));
}
} else {
$value = self::trimString($value);
if ($this->empty_values || $value !== "") {
$doc->insertTextElement($object_node, "field", $value, array("name" => $key));
}
}
}
if ($this->object_callback && is_callable($this->object_callback)) {
call_user_func($this->object_callback, $object, $object_node, $depth);
}
// Collections
if (!isset($this->backrefs_tree[$object->_class])) {
return;
}
foreach ($object->_backProps as $backName => $backProp) {
if (!in_array($backName, $this->backrefs_tree[$object->_class])) {
continue;
}
$_backspec = $object->makeBackSpec($backName);
// Add fwd ref field value for each object in the collection
if ($_backspec) {
$_class = $_backspec->class;
if (!isset($this->fwdrefs_tree[$_class])) {
$this->fwdrefs_tree[$_class] = array();
}
if (!array_key_exists($_backspec->field, $this->fwdrefs_tree[$_class])) {
$this->fwdrefs_tree[$_class][] = $_backspec->field;
}
}
$objects = $object->loadBackRefs($backName);
if ($objects) {
foreach ($objects as $_object) {
$this->_toDOM($_object, $depth - 1);
}
}
}
}