Back to Rules class

Method __construct

public
__construct
(mixed $input = '')
Constructor.
Parameters
  • mixed $input A JSON format string (probably from the database) or a nested array.
Since
  • 1.7.0
Class: Rules
Project: Joomla

Method __construct - Source code

/**
 * Constructor.
 *
 * The input array must be in the form: array('action' => array(-42 => true, 3 => true, 4 => false))
 * or an equivalent JSON encoded string, or an object where properties are arrays.
 *
 * @param   mixed  $input  A JSON format string (probably from the database) or a nested array.
 *
 * @since   1.7.0
 */
public function __construct($input = '')
{
    // Convert in input to an array.
    if (\is_string($input)) {
        $input = json_decode($input, true);
    } elseif (\is_object($input)) {
        $input = (array) $input;
    }
    if (\is_array($input)) {
        // Top level keys represent the actions.
        foreach ($input as $action => $identities) {
            $this->mergeAction($action, $identities);
        }
    }
}