Back to StateBehaviorTrait class

Method setState

public mixed
setState
(mixed $property, mixed $value = null)
Method to set state variables.
Parameters
  • string $property The name of the property
  • mixed $value The value of the property to set or null
Returns
  • mixed The previous value of the property or null if not set
Since
  • 4.0.0

Method setState - Source code

/**
 * Method to set state variables.
 *
 * @param   string  $property  The name of the property
 * @param   mixed   $value     The value of the property to set or null
 *
 * @return  mixed  The previous value of the property or null if not set
 *
 * @since   4.0.0
 */
public function setState($property, $value = null)
{
    if ($this->state === null) {
        $this->state = new CMSObject();
    }
    return $this->state->set($property, $value);
}