CoreFiles by mySites.guru
WebAssetStateChangedEvent.php87 lines, 1,742 bytes, from Joomla_4.0.0-alpha6-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha5
md5
3ef0d8931ca69edba336e100338b2c1f
sha1
9ccd66adca7f7922a229a6388bab2321e0bea0d0
sha256
99ce965bd7f9da4a7feb7c436fe2780569655721c79422430d274fcaeff5232c
<?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.txt
 */

namespace Joomla\CMS\Event\WebAsset;

defined('JPATH_PLATFORM') or die;

use BadMethodCallException;
use Joomla\CMS\WebAsset\WebAssetItem;

/**
 * Event class for WebAsset events
 *
 * @since  4.0.0
 */
class WebAssetStateChangedEvent extends AbstractEvent
{
	/**
	 * 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())
	{
		// Check for required arguments
		foreach (array('asset', 'oldState', 'newState') as $argument)
		{
			if (!array_key_exists($argument, $arguments))
			{
				throw new BadMethodCallException("Argument '$argument' is required for event $name");
			}
		}

		if (!($arguments['asset'] instanceof WebAssetItem))
		{
			throw new BadMethodCallException("Argument 'asset' of event $name is not of the expected type");
		}

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

	/**
	 * Return affected Asset object
	 *
	 * @return  WebAssetItem
	 *
	 * @since   4.0.0
	 */
	public function getAsset(): WebAssetItem
	{
		return $this->arguments['asset'];
	}

	/**
	 * Get previous state of the asset
	 *
	 * @return  int
	 *
	 * @since   4.0.0
	 */
	public function getOldState(): int
	{
		return (int) $this->arguments['oldState'];
	}

	/**
	 * Get new state of the asset
	 *
	 * @return  int
	 *
	 * @since   4.0.0
	 */
	public function getNewState(): int
	{
		return (int) $this->arguments['newState'];
	}
}

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.