-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document event: BeforeCompileHeadEvent
- Loading branch information
Showing
4 changed files
with
98 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
/** | ||
* Joomla! Content Management System | ||
* | ||
* @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org> | ||
* @license GNU General Public License version 2 or later; see LICENSE | ||
*/ | ||
|
||
namespace Joomla\CMS\Event\Document; | ||
|
||
use Joomla\CMS\Document\Document; | ||
use Joomla\CMS\Event\AbstractImmutableEvent; | ||
|
||
// phpcs:disable PSR1.Files.SideEffects | ||
\defined('JPATH_PLATFORM') or die; | ||
// phpcs:enable PSR1.Files.SideEffects | ||
|
||
/** | ||
* Event class for Document events | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
abstract class AbstractEvent extends AbstractImmutableEvent | ||
{ | ||
/** | ||
* Constructor. | ||
* | ||
* @param string $name The event name. | ||
* @param array $arguments The event arguments. | ||
* | ||
* @throws \BadMethodCallException | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
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 Document $value The value to set | ||
* | ||
* @return Document | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
protected function setSubject(Document $value): Document | ||
{ | ||
return $value; | ||
} | ||
|
||
/** | ||
* Returns associated Document instance. | ||
* | ||
* @return Document | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
public function getDocument(): Document | ||
{ | ||
return $this->getArgument('subject'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
/** | ||
* Joomla! Content Management System | ||
* | ||
* @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org> | ||
* @license GNU General Public License version 2 or later; see LICENSE | ||
*/ | ||
|
||
namespace Joomla\CMS\Event\Document; | ||
|
||
// phpcs:disable PSR1.Files.SideEffects | ||
\defined('JPATH_PLATFORM') or die; | ||
// phpcs:enable PSR1.Files.SideEffects | ||
|
||
/** | ||
* Event class for onBeforeCompileHead event | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
class BeforeCompileHeadEvent extends AbstractEvent | ||
{} |