CoreFiles by mySites.guru
State.php137 lines, 3,682 bytes, from Joomla_5.4.8-Stable-Full_Package.zip
Raw History Compare with 5.4.7
md5
14fb7a61645f048a9ada18804fd63018
sha1
990c18391f0e68edaf13d322067b054286739ed3
sha256
bce12cf03f7a1ba049e912d99a10cdd19636e32ff5580bd4ae41ced1044aef0c
<?php

/**
 * Joomla! Content Management System
 *
 * @copyright  (C) 2022 Open Source Matters, Inc. <https://www.joomla.org>
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\CMS\MVC\Model;

use Joomla\Registry\Registry;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
 * A simple state holder class. This class acts for transition from CMSObject to Registry
 * and should not be used directly. Instead of, use the Registry class.
 *
 * @since  5.0.0
 *
 * @deprecated  5.0.0 will be removed in 7.0, use the Registry directly
 */
class State extends Registry
{
    /**
    * Constructor
    *
    * @param  mixed  $data  The data to bind to the new Registry object.
    *
    * @since   5.0.0
    */
    public function __construct($data = null)
    {
        parent::__construct($data);

        // To speed up things
        $this->separator = null;
    }

    /**
     * Get a registry value.
     *
     * @param  string  $path     Registry path (e.g. joomla.content.showauthor)
     * @param  mixed   $default  Optional default value, returned if the internal value is null.
     *
     * @return  mixed  Value of entry or null
     *
     * @since   5.0.0
     */
    public function get($path, $default = null)
    {
        if (isset($this->data->$path) && empty($this->data->$path)) {
            @trigger_error(
                \sprintf('Instead of an empty value, the default value will be returned in 7.0 in %s::%s.', __METHOD__, __CLASS__),
                E_USER_DEPRECATED
            );
            return $this->data->$path;
        }

        return parent::get($path, $default);
    }

    /**
      * Returns an associative array of object properties.
      *
      * @return  array  The data array
      *
      * @since   5.0.0
      *
      * @deprecated  5.0.0 will be removed in 7.0, use toArray instead
      */
    public function getProperties()
    {
        return $this->toArray();
    }

    /**
     * Proxy for internal data access for the given name.
     *
     * @param   string  $name  The name of the element
     *
     * @return  mixed  The value of the element if set, null otherwise
     *
     * @since   5.0.0
     *
     * @deprecated  5.0.0 will be removed in 7.0
     *
     */
    public function __get($name)
    {
        @trigger_error(\sprintf('Direct property access will not be supported in 7.0 in %s::%s.', __METHOD__, __CLASS__), E_USER_DEPRECATED);

        return $this->get($name);
    }

    /**
     * Proxy for internal data storage for the given name and value.
     *
     * @param   string  $name   The name of the element
     * @param   string  $value  The value
     *
     * @return  void
     *
     * @since   5.0.0
     *
     * @deprecated  5.0.0 will be removed in 7.0
     *
     */
    public function __set($name, $value)
    {
        @trigger_error(\sprintf('Direct property access will not be supported in 7.0 in %s::%s.', __METHOD__, __CLASS__), E_USER_DEPRECATED);

        return $this->set($name, $value);
    }

    /**
     * Proxy for internal data check for a variable with the given key.
     *
     * @param   string  $name  The name of the element
     *
     * @return  bool    Returns if the internal data storage contains a key with the given
     *
     * @since   5.0.0
     *
     * @deprecated  5.0.0 will be removed in 7.0
     *
     */
    public function __isset($name)
    {
        @trigger_error(\sprintf('Direct property access will not be supported in 7.0 in %s::%s.', __METHOD__, __CLASS__), E_USER_DEPRECATED);

        return $this->exists($name);
    }
}

The same content is in 88 releases, Joomla 5.3.1-rc1 to 6.2.1-rc1. See them all, or every version of this file.