CoreFiles by mySites.guru
BeforeLoadEvent.php62 lines, 1,699 bytes, from Joomla_4.2.9-Stable-Full_Package.zip
Raw History Compare with 4.2.8
md5
4469caee7662a019c93eba9ff1428f58
sha1
ed6dced24ef4544a0a23279cc5789db3e2f8fce7
sha256
96d0fab27ef25af53be61e7b48be6b6a94a3611920e878e6f9a65ba52490d2df
<?php

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

namespace Joomla\CMS\Event\Table;

use BadMethodCallException;

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

/**
 * Event class for JTable's onBeforeLoad event
 *
 * @since  4.0.0
 */
class BeforeLoadEvent extends AbstractEvent
{
    /**
     * Constructor.
     *
     * Mandatory arguments:
     * subject  JTableInterface The table we are operating on
     * keys     mixed           The optional primary key value to load the row by, or an array of fields to match.
     * reset    boolean         True to reset the default values before loading the new row.
     *
     * @param   string  $name       The event name.
     * @param   array   $arguments  The event arguments.
     *
     * @throws  BadMethodCallException
     */
    public function __construct($name, array $arguments = [])
    {
        if (!\array_key_exists('keys', $arguments)) {
            throw new BadMethodCallException("Argument 'keys' is required for event $name");
        }

        if (!\array_key_exists('reset', $arguments)) {
            throw new BadMethodCallException("Argument 'reset' is required for event $name");
        }

        parent::__construct($name, $arguments);
    }

    /**
     * Setter for the reset attribute
     *
     * @param   mixed  $value  The value to set
     *
     * @return  boolean  Normalised value
     */
    protected function setReset($value)
    {
        return $value ? true : false;
    }
}

The same content is in 16 releases, Joomla 4.2.7-rc1 to 4.3.1. See them all, or every version of this file.