Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions libraries/src/Event/CoreEventAware.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ trait CoreEventAware
'onAjaxWebauthnInitcreate' => PlgSystemWebauthnAjaxInitCreate::class,
'onAjaxWebauthnLogin' => PlgSystemWebauthnAjaxLogin::class,
'onAjaxWebauthnSavelabel' => PlgSystemWebauthnAjaxSaveLabel::class,
// Plugin: System, Schemaorg
'onSchemaBeforeCompileHead' => Plugin\System\Schemaorg\BeforeCompileHeadEvent::class,
'onSchemaPrepareData' => Plugin\System\Schemaorg\PrepareDataEvent::class,
'onSchemaPrepareForm' => Plugin\System\Schemaorg\PrepareFormEvent::class,
'onSchemaPrepareSave' => Plugin\System\Schemaorg\PrepareSaveEvent::class,
// Extensions
'onBeforeExtensionBoot' => BeforeExtensionBootEvent::class,
'onAfterExtensionBoot' => AfterExtensionBootEvent::class,
Expand Down
102 changes: 102 additions & 0 deletions libraries/src/Event/Plugin/System/Schemaorg/BeforeCompileHeadEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?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.txt
*/

namespace Joomla\CMS\Event\Plugin\System\Schemaorg;

use Joomla\CMS\Event\AbstractImmutableEvent;
use Joomla\Registry\Registry;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
* Class for SchemaBeforeCompileHeadEvent event
* Example:
* new BeforeCompileHeadEvent('onSchemaBeforeCompileHead', ['subject' => $schema, 'context' => 'com_example.example']);
*
* @since __DEPLOY_VERSION__
*/
class BeforeCompileHeadEvent 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 {$name} is required but has not been provided");
}

if (!\array_key_exists('context', $arguments)) {
throw new \BadMethodCallException("Argument 'context' of event {$name} is required but has not been provided");
}

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

/**
* Setter for the subject argument.
*
* @param Registry $value The value to set
*
* @return Registry
*
* @since __DEPLOY_VERSION__
*/
protected function setSubject(Registry $value): Registry
{
return $value;
}

/**
* Setter for the context argument.
*
* @param string $value The value to set
*
* @return string
*
* @since __DEPLOY_VERSION__
*/
protected function setContext(string $value): string
{
return $value;
}

/**
* Getter for the schema argument.
*
* @return Registry
*
* @since __DEPLOY_VERSION__
*/
public function getSchema(): Registry
{
return $this->arguments['subject'];
}

/**
* Getter for the context argument.
*
* @return string
*
* @since __DEPLOY_VERSION__
*/
public function getContext(): string
{
return $this->arguments['context'];
}
}
101 changes: 101 additions & 0 deletions libraries/src/Event/Plugin/System/Schemaorg/PrepareDataEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?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.txt
*/

namespace Joomla\CMS\Event\Plugin\System\Schemaorg;

use Joomla\CMS\Event\AbstractImmutableEvent;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
* Class for SchemaPrepareDataEvent event
* Example:
* new PrepareDataEvent('onSchemaPrepareData', ['subject' => $data, 'context' => 'com_example.example']);
*
* @since __DEPLOY_VERSION__
*/
class PrepareDataEvent 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 {$name} is required but has not been provided");
}

if (!\array_key_exists('context', $arguments)) {
throw new \BadMethodCallException("Argument 'context' of event {$name} is required but has not been provided");
}

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

/**
* Setter for the subject argument.
*
* @param object $value The value to set
*
* @return object
*
* @since __DEPLOY_VERSION__
*/
protected function setSubject(object $value): object
{
return $value;
}

/**
* Setter for the context argument.
*
* @param string $value The value to set
*
* @return string
*
* @since __DEPLOY_VERSION__
*/
protected function setContext(string $value): string
{
return $value;
}

/**
* Getter for the data argument.
*
* @return object
*
* @since __DEPLOY_VERSION__
*/
public function getData(): object
{
return $this->arguments['subject'];
}

/**
* Getter for the context argument.
*
* @return string
*
* @since __DEPLOY_VERSION__
*/
public function getContext(): string
{
return $this->arguments['context'];
}
}
72 changes: 72 additions & 0 deletions libraries/src/Event/Plugin/System/Schemaorg/PrepareFormEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?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.txt
*/

namespace Joomla\CMS\Event\Plugin\System\Schemaorg;

use Joomla\CMS\Event\AbstractImmutableEvent;
use Joomla\CMS\Form\Form;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
* Class for SchemaPrepareFormEvent event
* Example:
* new PrepareFormEvent('onSchemaPrepareForm', ['subject' => $form]);
*
* @since __DEPLOY_VERSION__
*/
class PrepareFormEvent 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 {$name} is required but has not been provided");
}

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

/**
* Setter for the subject argument.
*
* @param Form $value The value to set
*
* @return Form
*
* @since __DEPLOY_VERSION__
*/
protected function setSubject(Form $value): Form
{
return $value;
}

/**
* Getter for the form argument.
*
* @return Form
*
* @since __DEPLOY_VERSION__
*/
public function getForm(): Form
{
return $this->arguments['subject'];
}
}
Loading