CoreFiles by mySites.guru
AbstractEvent.php61 lines, 1,644 bytes, from Joomla_4.2.8-Stable-Full_Package.zip
Raw History Compare with 4.2.7
md5
d1d30e8bb96d15f1d62ee8e29cba5de0
sha1
c9ee5d642213f98c02348357d9e96bfbca5c8fb6
sha256
39bc5ebbc7b7277be0a99e2d776067ba3976f74915bb3258f96c3f4c4018653d
<?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;
use Joomla\CMS\Event\AbstractImmutableEvent;
use Joomla\CMS\Table\TableInterface;

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

/**
 * Event class for the Table's events
 *
 * @since  4.0.0
 */
abstract class AbstractEvent extends AbstractImmutableEvent
{
    /**
     * @param   string  $name       The event name.
     * @param   array   $arguments  The event arguments.
     *
     * @throws  BadMethodCallException
     *
     * @since   1.0
     */
    public function __construct($name, array $arguments = [])
    {
        if (!\array_key_exists('subject', $arguments)) {
            throw new BadMethodCallException("Argument 'subject' of event {$this->name} is required but has not been provided");
        }

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

    /**
     * Setter for the subject argument
     *
     * @param   TableInterface  $value  The value to set
     *
     * @return  TableInterface
     *
     * @throws  BadMethodCallException  If the argument is not of the expected type.
     */
    protected function setSubject($value)
    {
        if (!\is_object($value) || !($value instanceof TableInterface)) {
            throw new BadMethodCallException("Argument 'subject' of event {$this->name} is not of the expected type");
        }

        return $value;
    }
}

The same content is in 27 releases, Joomla 4.2.1 to 4.3.1. See them all, or every version of this file.