CoreFiles by mySites.guru
WebAssetBeforeAttachEvent.php77 lines, 1,725 bytes, from Joomla_4.0.0-alpha8-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha7
md5
7d3c509b875fac861ff39037f8e6fce9
sha1
1d9e930ca4caf18ab0f1331129bed9f88cf590f4
sha256
8945b773df4013eddccbad6e99fee87decc1158dbdc6739f96554dcac9a95bfc
<?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'];
	}
}

The same content is in 5 releases, Joomla 4.0.0-alpha7 to 4.0.0-alpha11. See them all, or every version of this file.