CoreFiles by mySites.guru
AbstractEvent.php64 lines, 1,505 bytes, from Joomla_4.0.0-alpha6-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha5
md5
d9d3aad204d5ad89d5cf328dee0f1015
sha1
f712783750a6d94587b841fe8c475a0475177f20
sha256
b2bfda6975e42258a5e8d8346c82f8295be732bacbd6a2989704d66aaa118cdc
<?php
/**
 * Joomla! Content Management System
 *
 * @copyright  Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE
 */

namespace Joomla\CMS\Event\WebAsset;

defined('JPATH_PLATFORM') or die;

use BadMethodCallException;
use Joomla\CMS\Event\AbstractImmutableEvent;
use Joomla\CMS\WebAsset\WebAssetRegistry;

/**
 * Event class for WebAsset events
 *
 * @since  4.0.0
 */
abstract class AbstractEvent extends AbstractImmutableEvent
{
	/**
	 * Constructor.
	 *
	 * @param   string  $name       The event name.
	 * @param   array   $arguments  The event arguments.
	 *
	 * @throws  BadMethodCallException
	 *
	 * @since   4.0.0
	 */
	public function __construct($name, array $arguments = array())
	{
		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   WebAssetRegistry  $value  The value to set
	 *
	 * @return  WebAssetRegistry
	 *
	 * @throws  BadMethodCallException  if the argument is not of the expected type
	 *
	 * @since   4.0.0
	 */
	protected function setSubject($value)
	{
		if (!$value || !($value instanceof WebAssetRegistry))
		{
			throw new BadMethodCallException("Argument 'subject' of event {$this->name} is not of the expected type");
		}

		return $value;
	}
}

The same content is in 2 releases, Joomla 4.0.0-alpha5 to 4.0.0-alpha6. See them all, or every version of this file.