本文整理汇总了PHP中Element::setParent方法的典型用法代码示例。如果您正苦于以下问题:PHP Element::setParent方法的具体用法?PHP Element::setParent怎么用?PHP Element::setParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Element
的用法示例。
在下文中一共展示了Element::setParent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setParent
function setParent(&$parent)
{
parent::setParent($parent);
$step = $this->level;
if (isset($parent->parent) && is_a($parent->parent, 'ListContainer')) {
$step -= $parent->parent->level;
}
$margin = $this->margin * $step;
if ($step == $this->level) {
$margin += $this->left_margin;
}
if ($this->tag !== 'dl') {
global $_list_pad_str;
$this->style = sprintf($_list_pad_str, $this->level, $margin, $margin);
} else {
global $_dlist_pad_str;
$this->style = sprintf(' class="list%d dl-horizontal" ', $this->level, $margin, $margin);
}
}
示例2: addChild
function addChild(Element $child)
{
$this->children[] = $child;
$child->setParent($this);
}
示例3: testPutPreviousSibling_throwsBadMethodCallException_ifElementIsNotChild
/**
* putPreviousSibling() should throw BadMethodCallException if element is not child
*/
public function testPutPreviousSibling_throwsBadMethodCallException_ifElementIsNotChild()
{
$this->setExpectedException('BadMethodCallException');
$parent = new Group();
$parent->appendChild(new Element())->appendChild(new Element());
$element = new Element();
$element->setParent($parent);
$element->putPreviousSibling(new Element());
return;
}
示例4: setParent
function setParent(&$parent)
{
global $_list_pad_str;
parent::setParent($parent);
$step = $this->level;
if (isset($parent->parent) && is_a($parent->parent, 'ListContainer')) {
$step -= $parent->parent->level;
}
$margin = $this->margin * $step;
if ($step == $this->level) {
$margin += $this->left_margin;
}
$this->style = sprintf($_list_pad_str, $this->level, $margin, $margin);
}
示例5: addChild
/**
* Добавляет элемен в коллекцию
* @param Element $element потомок элемента
*/
public function addChild(Element $element)
{
$this->children[] = $element;
$element->setParent($this);
}