本文整理匯總了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);
}