當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Registry::loadJSON方法代碼示例

本文整理匯總了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];
 }
開發者ID:glauberm,項目名稱:cinevi,代碼行數:53,代碼來源:package.php


注:本文中的Joomla\Registry\Registry::loadJSON方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。