本文整理汇总了PHP中xPDOObject::getTemplateVars方法的典型用法代码示例。如果您正苦于以下问题:PHP xPDOObject::getTemplateVars方法的具体用法?PHP xPDOObject::getTemplateVars怎么用?PHP xPDOObject::getTemplateVars使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xPDOObject
的用法示例。
在下文中一共展示了xPDOObject::getTemplateVars方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: objectToArray
/**
* Turns the object into an array, and do some more processing depending on the object.
*
* @param \xPDOObject $object
* @pram array $options
* @return array
*/
protected function objectToArray(\xPDOObject $object, array $options = array())
{
$data = $object->toArray('', true, true);
switch (true) {
// Handle TVs for resources automatically
case $object instanceof \modResource:
/** @var \modResource $object */
$tvs = array();
$templateVars = $object->getTemplateVars();
foreach ($templateVars as $tv) {
/** @var \modTemplateVar $tv */
$name = $tv->get('name');
if (isset($options['exclude_tvs']) && is_array($options['exclude_tvs'])) {
if (!in_array($name, $options['exclude_tvs'])) {
$tvs[$tv->get('name')] = $tv->get('value');
}
} else {
$tvs[$tv->get('name')] = $tv->get('value');
}
}
ksort($tvs);
$data['tvs'] = $tvs;
break;
// Handle string-based categories automagically on elements
// Handle string-based categories automagically on elements
case $object instanceof \modElement && !$object instanceof \modCategory:
if (isset($data['category']) && !empty($data['category']) && is_numeric($data['category'])) {
$data['category'] = $this->getCategoryName($data['category']);
}
break;
}
return $data;
}