CoreFiles by mySites.guru
BeforeLoadEvent.php62 lines, 1,695 bytes, from Joomla_5.0.0-alpha2-Alpha-Full_Package.zip
Raw History Compare with 5.0.0-alpha1
md5
65f16419fc24cc6e142c038bbfd8ad02
sha1
e3c128fd7e1a2ea00bbba3b2fbf25c1413310d93
sha256
0526bbdf8cdce78a83290747f0612a3b59a684ff63e3b9cc0e195de75a6c1e17
<?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.txt
 */

namespace Joomla\CMS\Event\Table;

use BadMethodCallException;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') 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 2 releases, Joomla 5.0.0-alpha1 to 5.0.0-alpha2. See them all, or every version of this file.