Skip to content

Commit

Permalink
Merge pull request #12395 from mbabker/registry-instantiation
Browse files Browse the repository at this point in the history
[3.7] Simplify instantiation of Registry
  • Loading branch information
wilsonge authored Oct 12, 2016
2 parents 33a6549 + f37a777 commit d13d0de
Show file tree
Hide file tree
Showing 48 changed files with 76 additions and 163 deletions.
2 changes: 1 addition & 1 deletion build/helpTOC.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function doExecute()
$namespace = 'Help' . $helpVersion . ':';

// Set up options for JMediawiki
$options = new JRegistry;
$options = new Joomla\Registry\Registry;
$options->set('api.url', 'https://docs.joomla.org');

$mediawiki = new JMediawiki($options);
Expand Down
4 changes: 1 addition & 3 deletions components/com_banners/models/banners.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,7 @@ public function getItems()

foreach ($this->cache['items'] as &$item)
{
$parameters = new Registry;
$parameters->loadString($item->params);
$item->params = $parameters;
$item->params = new Registry($item->params);
}
}

Expand Down
4 changes: 1 addition & 3 deletions components/com_contact/models/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ public function getItems()
$item = & $items[$i];
if (!isset($this->_params))
{
$params = new Registry;
$params->loadString($item->params);
$item->params = $params;
$item->params = new Registry($item->params);
}
$this->tags = new JHelperTags;
$this->tags->getItemTags('com_contact.contact', $item->id);
Expand Down
12 changes: 4 additions & 8 deletions components/com_contact/models/contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,11 @@ public function &getItem($pk = null)
}

// Convert parameter fields to objects.
$registry = new Registry;
$registry->loadString($data->params);
$registry = new Registry($data->params);
$data->params = clone $this->getState('params');
$data->params->merge($registry);

$registry = new Registry;
$registry->loadString($data->metadata);
$registry = new Registry($data->metadata);
$data->metadata = $registry;

$data->tags = new JHelperTags;
Expand Down Expand Up @@ -273,8 +271,7 @@ protected function buildContactExtendedData($contact)
$groups = implode(',', $user->getAuthorisedViewLevels());
$published = $this->getState('filter.published');

$contactParams = new Registry;
$contactParams->loadString($contact->params);
$contactParams = new Registry($contact->params);

// If we are showing a contact list, then the contact parameters take priority
// So merge the contact parameters with the merged parameters
Expand Down Expand Up @@ -459,8 +456,7 @@ protected function getContactQuery($pk = null)
if ($result)
{

$contactParams = new Registry;
$contactParams->loadString($result->params);
$contactParams = new Registry($result->params);

// If we are showing a contact list, then the contact parameters take priority
// So merge the contact parameters with the merged parameters
Expand Down
4 changes: 1 addition & 3 deletions components/com_contact/models/featured.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@ public function getItems()
$item = & $items[$i];
if (!isset($this->_params))
{
$params = new Registry;
$params->loadString($item->params);
$item->params = $params;
$item->params = new Registry($item->params);
}
}

Expand Down
3 changes: 1 addition & 2 deletions components/com_contact/views/category/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ public function display($tpl = null)
foreach ($this->items as $item)
{
$item->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id;
$temp = new Registry;
$temp->loadString($item->params);
$temp = new Registry($item->params);
$item->params = clone($this->params);
$item->params->merge($temp);

Expand Down
4 changes: 1 addition & 3 deletions components/com_contact/views/featured/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ public function display($tpl = null)
{
$item = &$items[$i];
$item->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id;
$temp = new Registry;

$temp->loadString($item->params);
$temp = new Registry($item->params);
$item->params = clone $params;
$item->params->merge($temp);

Expand Down
7 changes: 2 additions & 5 deletions components/com_content/models/article.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,12 @@ public function getItem($pk = null)
}

// Convert parameter fields to objects.
$registry = new Registry;
$registry->loadString($data->attribs);
$registry = new Registry($data->attribs);

$data->params = clone $this->getState('params');
$data->params->merge($registry);

$registry = new Registry;
$registry->loadString($data->metadata);
$data->metadata = $registry;
$data->metadata = new Registry($data->metadata);

// Technically guest could edit an article, but lets not check that to improve performance a little.
if (!$user->get('guest'))
Expand Down
6 changes: 2 additions & 4 deletions components/com_content/models/articles.php
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,7 @@ public function getItems()
// Convert the parameter fields into objects.
foreach ($items as &$item)
{
$articleParams = new Registry;
$articleParams->loadString($item->attribs);
$articleParams = new Registry($item->attribs);

// Unpack readmore and layout params
$item->alternative_readmore = $articleParams->get('alternative_readmore');
Expand Down Expand Up @@ -620,8 +619,7 @@ public function getItems()
// Merge the selected article params
if (count($articleArray) > 0)
{
$articleParams = new Registry;
$articleParams->loadArray($articleArray);
$articleParams = new Registry($articleArray);
$item->params->merge($articleParams);
}
}
Expand Down
6 changes: 2 additions & 4 deletions components/com_content/models/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ public function getItem($itemId = null)
$value = ArrayHelper::toObject($properties, 'JObject');

// Convert attrib field to Registry.
$value->params = new Registry;
$value->params->loadString($value->attribs);
$value->params = new Registry($value->attribs);

// Compute selected asset permissions.
$user = JFactory::getUser();
Expand Down Expand Up @@ -141,8 +140,7 @@ public function getItem($itemId = null)
}

// Convert the metadata field to an array.
$registry = new Registry;
$registry->loadString($value->metadata);
$registry = new Registry($value->metadata);
$value->metadata = $registry->toArray();

if ($itemId)
Expand Down
8 changes: 2 additions & 6 deletions components/com_finder/helpers/html/filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ public static function slider($options = array())
// Initialize the filter parameters.
if ($filter)
{
$registry = new Registry;
$registry->loadString($filter->params);
$filter->params = $registry;
$filter->params = new Registry($filter->params);
}
}

Expand Down Expand Up @@ -255,9 +253,7 @@ public static function select($idxQuery, $options)
// Initialize the filter parameters.
if ($filter)
{
$registry = new Registry;
$registry->loadString($filter->params);
$filter->params = $registry;
$filter->params = new Registry($filter->params);
}
}

Expand Down
7 changes: 2 additions & 5 deletions components/com_newsfeeds/models/newsfeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,11 @@ public function &getItem($pk = null)
}

// Convert parameter fields to objects.
$registry = new Registry;
$registry->loadString($data->params);
$registry = new Registry($data->params);
$data->params = clone $this->getState('params');
$data->params->merge($registry);

$registry = new Registry;
$registry->loadString($data->metadata);
$data->metadata = $registry;
$data->metadata = new Registry($data->metadata);

// Compute access permissions.

Expand Down
3 changes: 1 addition & 2 deletions components/com_newsfeeds/views/category/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ public function display($tpl = null)
foreach ($this->items as $item)
{
$item->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id;
$temp = new Registry;
$temp->loadString($item->params);
$temp = new Registry($item->params);
$item->params = clone $this->params;
$item->params->merge($temp);
}
Expand Down
3 changes: 1 addition & 2 deletions components/com_newsfeeds/views/newsfeed/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ public function display($tpl = null)
// Get the newsfeed
$newsfeed = $item;

$temp = new Registry;
$temp->loadString($item->params);
$temp = new Registry($item->params);
$params->merge($temp);

try
Expand Down
3 changes: 1 addition & 2 deletions components/com_search/views/search/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ public function display($tpl = null)
// Because the application sets a default page title, we need to get it right from the menu item itself
if (is_object($menu))
{
$menu_params = new Registry;
$menu_params->loadString($menu->params);
$menu_params = new Registry($menu->params);

if (!$menu_params->get('page_title'))
{
Expand Down
3 changes: 1 addition & 2 deletions components/com_tags/views/tag/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ public function display($tpl = null)
// Prepare the data.
if (!empty($itemElement))
{
$temp = new Registry;
$temp->loadString($itemElement->params);
$temp = new Registry($itemElement->params);
$itemElement->params = clone $params;
$itemElement->params->merge($temp);
$itemElement->params = (array) json_decode($itemElement->params);
Expand Down
3 changes: 1 addition & 2 deletions components/com_tags/views/tags/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ public function display($tpl = null)
}

// Prepare the data.
$temp = new Registry;
$temp->loadString($itemElement->params);
$temp = new Registry($itemElement->params);
$itemElement->params = clone $params;
$itemElement->params->merge($temp);
$itemElement->params = (array) json_decode($itemElement->params);
Expand Down
2 changes: 1 addition & 1 deletion installation/application/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ public function loadSession(JSession $session = null)
if (!$session->get('registry') instanceof Registry)
{
// Registry has been corrupted somehow.
$session->set('registry', new Registry('session'));
$session->set('registry', new Registry);
}

// Set the session object.
Expand Down
2 changes: 1 addition & 1 deletion libraries/cms/application/cms.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function afterSessionStart()

if ($session->isNew())
{
$session->set('registry', new Registry('session'));
$session->set('registry', new Registry);
$session->set('user', new JUser);
}
}
Expand Down
11 changes: 3 additions & 8 deletions libraries/cms/application/site.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,7 @@ public function getParams($option = null)
// Get show_page_heading from com_menu global settings
$params[$hash]->def('show_page_heading', $temp->get('show_page_heading'));

$temp = new Registry;
$temp->loadString($menu->params);
$temp = new Registry($menu->params);
$params[$hash]->merge($temp);
$title = $menu->title;
}
Expand Down Expand Up @@ -484,9 +483,7 @@ public function getTemplate($params = false)

foreach ($templates as &$template)
{
$registry = new Registry;
$registry->loadString($template->params);
$template->params = $registry;
$template->params = new Registry($template->params);

// Create home element
if ($template->home == 1 && !isset($templates[0]) || $this->_language_filter && $template->home == $tag)
Expand Down Expand Up @@ -521,9 +518,7 @@ public function getTemplate($params = false)
{
$template = $tmpl;

$registry = new Registry;
$registry->loadString($template->params);
$template->params = $registry;
$template->params = new Registry($template->params);

break;
}
Expand Down
4 changes: 1 addition & 3 deletions libraries/cms/component/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ public static function getComponent($option, $strict = false)

if (is_string($result->params))
{
$temp = new Registry;
$temp->loadString(static::$components[$option]->params);
static::$components[$option]->params = $temp;
static::$components[$option]->params = new Registry(static::$components[$option]->params);
}

return $result;
Expand Down
3 changes: 1 addition & 2 deletions libraries/cms/editor/editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,7 @@ protected function _loadEditor($config = array())
return false;
}

$params = new Registry;
$params->loadString($plugin->params);
$params = new Registry($plugin->params);
$params->loadArray($config);
$plugin->params = $params;

Expand Down
3 changes: 1 addition & 2 deletions libraries/cms/installer/adapter/language.php
Original file line number Diff line number Diff line change
Expand Up @@ -670,8 +670,7 @@ public function uninstall($eid)

foreach ($users as $user)
{
$registry = new Registry;
$registry->loadString($user->params);
$registry = new Registry($user->params);

if ($registry->get($param_name) == $element)
{
Expand Down
4 changes: 1 addition & 3 deletions libraries/cms/library/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,7 @@ protected static function _load($element)
// Convert the params to an object.
if (is_string(static::$libraries[$element]->params))
{
$temp = new Registry;
$temp->loadString(static::$libraries[$element]->params);
static::$libraries[$element]->params = $temp;
static::$libraries[$element]->params = new Registry(static::$libraries[$element]->params);
}

return true;
Expand Down
4 changes: 1 addition & 3 deletions libraries/cms/menu/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ public function __construct($options = array())
// Decode the item params
try
{
$result = new Registry;
$result->loadString($item->params);
$item->params = $result;
$item->params = new Registry($item->params);
}
catch (RuntimeException $e)
{
Expand Down
3 changes: 1 addition & 2 deletions libraries/cms/module/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ public static function renderModule($module, $attribs = array())
$app->scope = $module->module;

// Get module parameters
$params = new Registry;
$params->loadString($module->params);
$params = new Registry($module->params);

// Get the template
$template = $app->getTemplate();
Expand Down
3 changes: 1 addition & 2 deletions libraries/cms/plugin/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ public function __construct(&$subject, $config = array())
}
else
{
$this->params = new Registry;
$this->params->loadString($config['params']);
$this->params = new Registry($config['params']);
}
}

Expand Down
Loading

0 comments on commit d13d0de

Please sign in to comment.