本文整理汇总了PHP中Element::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Element::get方法的具体用法?PHP Element::get怎么用?PHP Element::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Element
的用法示例。
在下文中一共展示了Element::get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* @param string $key
* @param null $default
* @return mixed|string
*/
public function get($key, $default = null)
{
if ($key == 'slug') {
return $this->slug;
}
return parent::get($key, $default);
}
示例2: testSetAll
/**
* @covers Element::setAll
*/
public function testSetAll()
{
$keyOne = "alt";
$valueOne = "logo fruition";
$keyTwo = "target";
$valueTwo = "_blank";
$keyThree = "href";
$valueThree = "fruitionsciences.com";
$atts = array($keyOne => $valueOne, $keyTwo => $valueTwo, $keyThree => $valueThree);
$this->assertEmpty($this->elt->getAll());
$this->elt->setAll($atts);
$this->assertSame($valueOne, $this->elt->get($keyOne));
$this->assertSame($valueTwo, $this->elt->get($keyTwo));
$this->assertSame($valueThree, $this->elt->get($keyThree));
}
示例3: setup_tv_template_access
/**
* Sets up all template access for a template variable
*
* @param integer $tv_id
* @param array $templates
*
* @return boolean
*/
public function setup_tv_template_access($tv_id, $templates)
{
$template_collection = $this->modx->getCollection('modTemplate');
// Remove all tv access for each template
foreach ($template_collection as $template) {
$template = Element::insert($template);
if (!$this->remove_template_access($tv_id, $template->get_property('id'))) {
return false;
}
}
// Give access to all templates if the first name is *
if ($templates[0] === '*') {
foreach ($template_collection as $template) {
$template = Element::insert($template);
if ($template) {
if (!$this->add_template_access($tv_id, $template->get_property('id'))) {
return false;
}
}
}
} else {
foreach ($templates as $template_name) {
$template = Element::get($this->modx, 'modTemplate', $template_name);
// If the template exists add access to the tv
if ($template) {
if (!$this->add_template_access($tv_id, $template->get_property('id'))) {
return false;
}
}
}
}
return true;
}
示例4: valid
public function valid()
{
if ($this->_position == 0 && !isset($this->_item->elements[$this->identifier], $this->_item->elements[$this->identifier][0])) {
parent::set(0, array());
}
return parent::get($this->_position) !== null;
}
示例5: foreach
if ($element_helper->update_tv_file($updated_tvs)) {
foreach ($flagged_tvs as $i) {
$element_sync->remove_element('modTemplateVar', $tvs[$i]->name);
}
}
}
// Process the template variable elements
foreach ($modx->getCollection('modTemplateVar') as $element_object) {
// Check if the tv exists in the template variables file
$element = Element::insert($element_object);
$name = $element->get_property('name');
$category_id = $element->get_property('category');
$tv_file_has_tv = false;
// Check if the element has a category and is whitelisted
if ($category_id !== 0) {
$category = Element::get($modx, 'modCategory', $category_id);
if (!in_array($category->get_property('name'), $category_whitelist)) {
continue;
}
}
// Loop through the tvs to check if it exists in the template variables file
foreach ($tvs as $i => $tv) {
if ($tv->name === $name) {
$tv_file_has_tv = true;
}
}
// If the tv doesn't exist in the template variables json file
if ($tv_file_has_tv === false) {
// If the element is not in the sync
if (!$element_sync->has_element('modTemplateVar', $name)) {
// Collect the tv element properties