JRegistry/merge: Difference between revisions
From Joomla! Documentation
m clean up |
m preparing for archive only |
||
Line 4: | Line 4: | ||
===Syntax=== | ===Syntax=== | ||
Line 54: | Line 54: | ||
===Examples=== | ===Examples=== | ||
=== Code Examples === | |||
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=merge | category=merge | ||
category=JRegistry | category=JRegistry | ||
namespace=CodeExample | |||
category=MethodExample | category=MethodExample | ||
include=* | include=* | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> |
Latest revision as of 02:00, 25 March 2017
Description
Merge a JRegistry object into this one
Syntax
merge(&$source)
Parameter Name | Default Value | Description |
---|---|---|
&$source | Source object ot merge |
Returns
boolean True on success
Defined in
libraries/joomla/registry/registry.php
Importing
jimport( 'joomla.registry.registry' );
Source Body
public function merge(&$source)
{
if ($source instanceof JRegistry) {
$sns = $source->getNameSpaces();
foreach ($sns as $ns) {
if (!isset($this->_registry[$ns])) {
// If namespace does not exist, make it and load the data
$this->makeNameSpace($ns);
}
// Load the variables into the registry's default namespace.
foreach ($source->toArray($ns) as $k => $v) {
if ($v != null) {
$this->_registry[$ns]['data']->$k = $v;
}
}
}
return true;
}
return false;
}
Examples
Code Examples