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