API16

JRules/ toString: Difference between revisions

From Joomla! Documentation

Doxiki (talk | contribs)
New page: ===Description=== Magic method to convert the object to JSON string representation. <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>[[Description:JRules/__toString...
 
m preparing for archive only
 
(One intermediate revision by the same user not shown)
Line 2: Line 2:
Magic method to convert the object to JSON string representation.
Magic method to convert the object to JSON string representation.


<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JRules/__toString|Edit Descripton]]<nowiki>]</nowiki>
</span>


{{Description:JRules/__toString}}
 
 


===Syntax===
===Syntax===
Line 35: Line 33:
</source>
</source>


<span class="editsection" style="font-size:76%;">
 
<nowiki>[</nowiki>[[SeeAlso:JRules/__toString|Edit See Also]]<nowiki>]</nowiki>
 
</span>
{{SeeAlso:JRules/__toString}}


===Examples===
===Examples===
<CodeExamplesForm />
=== Code Examples ===
<dpl>
<dpl>
  noresultsheader=\n
  noresultsheader=\n
  category=__toString
  category=__toString
  category=JRules
  category=JRules
  category=CodeExample
  namespace=CodeExample
  category=MethodExample
  category=MethodExample
  include=*
  include=*
  format= ,,,
  format= ,,,
</dpl>
</dpl>

Latest revision as of 02:02, 25 March 2017

Description

Magic method to convert the object to JSON string representation.



Syntax

__toString()


Returns

string

Defined in

libraries/joomla/access/rules.php

Importing

jimport( 'joomla.access.rules' );

Source Body

public function __toString()
{
        $temp = array();
        foreach ($this->_data as $name => $rule)
        {
                // Convert the action to JSON, then back into an array otherwise
                // re-encoding will quote the JSON for the identities in the action.
                $temp[$name] = json_decode((string) $rule);
        }
        return json_encode($temp);
}



Examples

Code Examples