API16

JRegistry/merge: Difference between revisions

From Joomla! Documentation

Doxiki (talk | contribs)
New page: ===Description=== Merge a JRegistry object into this one <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki>]</...
 
Doxiki (talk | contribs)
No edit summary
Line 17: Line 17:
!Description
!Description
|-
|-
|  
| &$source
|  
|  
|  Source  object ot merge  
|  Source  object ot merge  

Revision as of 10:18, 30 March 2010

Description

Merge a JRegistry object into this one

[Edit Descripton]

Template:Description:JRegistry/merge

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;
}

[Edit See Also] Template:SeeAlso:JRegistry/merge

Examples

<CodeExamplesForm />