本文整理汇总了PHP中Joomla\Registry\Registry::loadJSON方法的典型用法代码示例。如果您正苦于以下问题:PHP Registry::loadJSON方法的具体用法?PHP Registry::loadJSON怎么用?PHP Registry::loadJSON使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Joomla\Registry\Registry
的用法示例。
在下文中一共展示了Registry::loadJSON方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* Method to get package data.
* Packages are all stored in jos_fabrik_packages - so don't use {package} in the query to load them
*
* @param int $pk The id of the package.
*
* @return mixed Menu item data object on success, false on failure.
*/
public function &getItem($pk = null)
{
// Initialise variables.
$pk = !empty($pk) ? $pk : (int) $this->getState('package.id');
if (!isset($this->_item)) {
$this->_item = array();
}
if (!isset($this->_item[$pk])) {
try {
$db = FabrikWorker::getDbo();
$query = $db->getQuery(true);
$query->select('label, params, published, component_name');
$query->from('#__fabrik_packages');
$query->where('id = ' . (int) $pk);
// Filter by published state.
$published = $this->getState('filter.published');
$archived = $this->getState('filter.archived');
if (is_numeric($published)) {
$query->where('(published = ' . (int) $published . ' OR published =' . (int) $archived . ')');
}
$db->setQuery($query);
$data = $db->loadObject();
if ($error = $db->getErrorMsg()) {
throw new Exception($error);
}
if (empty($data)) {
throw new JException(FText::_('COM_FABRIK_ERROR_PACKAGE_NOT_FOUND'), 404);
}
// Check for published state if filter set.
if ((is_numeric($published) || is_numeric($archived)) && ($data->published != $published && $data->published != $archived)) {
throw new JException(FText::_('COM_FABRIK_ERROR_PACKAGE_NOT_FOUND'), 404);
}
// Convert parameter fields to objects.
$registry = new Registry();
$registry->loadJSON($data->params);
$data->params = clone $this->getState('params');
$data->params->merge($registry);
$this->_item[$pk] = $data;
} catch (JException $e) {
$this->setError($e);
$this->_item[$pk] = false;
}
}
return $this->_item[$pk];
}