CoreFiles by mySites.guru
WebAssetBeforeAttachEvent.php77 lines, 1,727 bytes, from Joomla_4.0.0-alpha12-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha11
md5
3aefd0ca2c026408728f26b87ae1ea95
sha1
18a95a101de7a1f399533bb3e1173c208334ab9b
sha256
2d5a9b8b1294f9df331b7ebeb47871947075f54faee34ba20dee2eebc1682665
<?php
/**
 * Joomla! Content Management System
 *
 * @copyright  Copyright (C) 2005 - 2019 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\Document\Document;
use Joomla\CMS\WebAsset\WebAssetManager;

/**
 * Event class for WebAsset events
 *
 * @since  4.0.0
 */
class WebAssetBeforeAttachEvent 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
		if (!\array_key_exists('document', $arguments) || !($arguments['document'] instanceof Document))
		{
			throw new BadMethodCallException("Argument 'document' of event $name is not of the expected type");
		}

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

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

		return $value;
	}

	/**
	 * Return target Document
	 *
	 * @return  Document
	 *
	 * @since   4.0.0
	 */
	public function getAsset(): Document
	{
		return $this->arguments['document'];
	}
}

No other release has this exact content. See every version of this file.