API16

JRules/ toString: Difference between revisions

From Joomla! Documentation

m clean up
m preparing for archive only
 
Line 4: Line 4:




{{subst:Description:JRules/__toString}}
 


===Syntax===
===Syntax===
Line 34: Line 34:




{{subst: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