Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
592056f
ContentPrepareEvent
Fedik Jul 25, 2023
1995a33
AfterTitle, BeforeDisplay, AfterDisplay
Fedik Jul 25, 2023
ede41c3
Fix category params
Fedik Jul 25, 2023
36d8057
phpcs
Fedik Jul 25, 2023
276d860
PrepareForm
Fedik Jul 25, 2023
c070269
PrepareForm
Fedik Jul 25, 2023
7348762
PrepareForm
Fedik Jul 25, 2023
63f1b96
PrepareForm
Fedik Jul 25, 2023
416b885
ContentPrepareData
Fedik Jul 25, 2023
5acdf15
ContentNormaliseRequestData
Fedik Jul 25, 2023
ea220f3
Params b/c compatibility
Fedik Jul 26, 2023
876badf
ContentBeforeSaveEvent
Fedik Jul 26, 2023
fd7f9a9
ContentAfterSave
Fedik Jul 26, 2023
3d7bb4f
Fixes for ContentBeforeSave
Fedik Jul 26, 2023
8feb26f
ContentSaveEvent
Fedik Jul 26, 2023
93d6c61
ContentDeleteEvent
Fedik Jul 26, 2023
de10615
ChangeStateEvent
Fedik Jul 26, 2023
c888f2e
BeforeValidateData
Fedik Jul 26, 2023
e46283c
Fix Data referencing
Fedik Jul 26, 2023
8696272
Fix params
Fedik Jul 26, 2023
dcc7054
Re-arange
Fedik Jul 26, 2023
7b536b2
Re-arange
Fedik Jul 26, 2023
19f9a2b
Descriptions with example
Fedik Jul 26, 2023
c0596ab
Descriptions with example
Fedik Jul 26, 2023
4e67381
Plugin system/fields partial
Fedik Jul 26, 2023
aef153b
Proxy interface, ArrayProxy class
Fedik Jul 27, 2023
1e477e3
ObjectProxy class
Fedik Jul 27, 2023
1eecbc7
Iterating own iterator
Fedik Jul 27, 2023
e17e974
Cleanup
Fedik Jul 27, 2023
b317289
Proxy Test
Fedik Jul 27, 2023
3e18ca7
Merge branch '5.0-dev' into content-events
Fedik Jul 27, 2023
38af7d5
Merge branch 'proxy-class' into content-events
Fedik Jul 27, 2023
2d86862
Proxy event data
Fedik Jul 27, 2023
26eb8f2
Dates
Fedik Jul 27, 2023
0134790
testing test
Fedik Jul 28, 2023
6866d42
Revert "testing test"
Fedik Jul 28, 2023
ef10d2b
testing test
Fedik Jul 28, 2023
db0277e
testing test
Fedik Jul 28, 2023
f22221e
testing test
Fedik Jul 28, 2023
762baee
testing test
Fedik Jul 28, 2023
f4b2f18
testing test
Fedik Jul 28, 2023
25fee21
testing test
Fedik Jul 28, 2023
538565f
testing test
Fedik Jul 28, 2023
cf0be84
testing test
Fedik Jul 28, 2023
1769788
testing test
Fedik Jul 28, 2023
d41e53e
testing test
Fedik Jul 28, 2023
87b43a6
testing test
Fedik Jul 28, 2023
429774f
testing test
Fedik Jul 28, 2023
0b94fc5
testing test
Fedik Jul 28, 2023
fcaba73
testing test
Fedik Jul 28, 2023
fa12d96
testing test
Fedik Jul 28, 2023
01a0f96
testing test
Fedik Jul 28, 2023
1e6942f
testing test
Fedik Jul 28, 2023
48fc17f
testing test
Fedik Jul 28, 2023
9f9cb05
testing test
Fedik Jul 28, 2023
61c8d16
testing test
Fedik Jul 28, 2023
413f857
testing test
Fedik Jul 28, 2023
e05d81e
testing test
Fedik Jul 28, 2023
fea0f4f
testing test
Fedik Jul 28, 2023
c75a44d
testing test
Fedik Jul 28, 2023
e48e0c0
testing test drone system
Fedik Jul 28, 2023
a819701
Revert "testing test drone system"
Fedik Jul 28, 2023
bfa4525
testing test
Fedik Jul 29, 2023
95b1a96
testing test
Fedik Jul 29, 2023
de60af5
testing test
Fedik Jul 29, 2023
8878acf
testing test
Fedik Jul 29, 2023
4a6064f
testing test
Fedik Jul 29, 2023
47291f0
Revert "testing test"
Fedik Jul 29, 2023
8e530da
testing test
Fedik Jul 29, 2023
0e4ce93
Schemaorg plg
Fedik Jul 29, 2023
a03ff75
Fix mixed events
Fedik Jul 29, 2023
555a4e8
Fix mixed events
Fedik Jul 29, 2023
441c7e0
Better reshape
Fedik Jul 29, 2023
4b40348
fixes
Fedik Jul 31, 2023
ec9bf80
RenderModuleEvent
Fedik Jul 31, 2023
0de8cf7
RenderModuleEvent
Fedik Aug 1, 2023
e768fca
ModuleListEvent
Fedik Aug 1, 2023
f6d0b83
ModuleListEvent
Fedik Aug 1, 2023
d37e4db
ModuleListEvent
Fedik Aug 1, 2023
11e57fe
Examples
Fedik Aug 1, 2023
6220e42
b/c for get/set arguments
Fedik Aug 1, 2023
2f837a5
CategoryChangeState
Fedik Aug 5, 2023
8908052
Simplify
Fedik Aug 5, 2023
e591064
Merge branch '5.0-dev' into content-events
Fedik Aug 5, 2023
50cfe0b
Merge branch '5.0-dev' into content-events
Fedik Aug 5, 2023
f1b9bf3
Updates
Fedik Aug 5, 2023
6e481d0
Reorder
Fedik Aug 5, 2023
3beb20d
Merge branch 'content-events' into module-events
Fedik Aug 5, 2023
4f9942e
Merge branch '5.0-dev' into module-events
HLeithner Aug 14, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Joomla\CMS\Association\AssociationServiceInterface;
use Joomla\CMS\Categories\CategoryServiceInterface;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Event\Model\AfterCategoryChangeStateEvent;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Helper\TagsHelper;
Expand Down Expand Up @@ -740,10 +741,14 @@ public function publish(&$pks, $value = 1)
$extension = Factory::getApplication()->getInput()->get('extension');

// Include the content plugins for the change of category state event.
PluginHelper::importPlugin('content');
PluginHelper::importPlugin('content', null, true, $this->getDispatcher());

// Trigger the onCategoryChangeState event.
Factory::getApplication()->triggerEvent('onCategoryChangeState', [$extension, $pks, $value]);
$this->getDispatcher()->dispatch('onCategoryChangeState', new AfterCategoryChangeStateEvent('onCategoryChangeState', [
'context' => $extension,
'subject' => $pks,
'value' => $value,
]));

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace Joomla\Component\Mails\Administrator\Controller;

use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Factory;
use Joomla\CMS\Event\Model;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\FormController;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
Expand Down Expand Up @@ -192,9 +192,13 @@ public function save($key = null, $urlVar = null)

// Send an object which can be modified through the plugin event
$objData = (object) $data;
$this->app->triggerEvent(
$this->getDispatcher()->dispatch(
'onContentNormaliseRequestData',
[$this->option . '.' . $this->context, $objData, $form]
new Model\NormaliseRequestDataEvent('onContentNormaliseRequestData', [
'context' => $this->option . '.' . $this->context,
'data' => $objData,
'subject' => $form,
])
);
$data = (array) $objData;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace Joomla\Component\Scheduler\Administrator\Traits;

use Joomla\CMS\Event\Model;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Language\Text;
Expand Down Expand Up @@ -97,8 +98,8 @@ protected function endRoutine(ExecuteTaskEvent $event, int $exitCode): void
* `onContentPrepareForm` event through {@see SubscriberInterface::getSubscribedEvents()} and will take care
* of injecting the fields without additional logic in the plugin class.
*
* @param EventInterface|Form $context The onContentPrepareForm event or the Form object.
* @param mixed $data The form data, required when $context is a {@see Form} instance.
* @param Model\PrepareFormEvent|Form $context The onContentPrepareForm event or the Form object.
* @param mixed $data The form data, required when $context is a {@see Form} instance.
*
* @return boolean True if the form was successfully enhanced or the context was not relevant.
*
Expand All @@ -107,10 +108,9 @@ protected function endRoutine(ExecuteTaskEvent $event, int $exitCode): void
*/
public function enhanceTaskItemForm($context, $data = null): bool
{
if ($context instanceof EventInterface) {
/** @var Form $form */
$form = $context->getArgument('0');
$data = $context->getArgument('1');
if ($context instanceof Model\PrepareFormEvent) {
$form = $context->getForm();
$data = $context->getData();
} elseif ($context instanceof Form) {
$form = $context;
} else {
Expand Down
10 changes: 4 additions & 6 deletions administrator/components/com_users/src/Model/CaptiveModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Date\Date;
use Joomla\CMS\Event\Module;
use Joomla\CMS\Event\MultiFactor\Captive;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
Expand All @@ -21,7 +22,6 @@
use Joomla\Component\Users\Administrator\DataShape\CaptiveRenderOptions;
use Joomla\Component\Users\Administrator\Helper\Mfa as MfaHelper;
use Joomla\Component\Users\Administrator\Table\MfaTable;
use Joomla\Event\Event;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
Expand Down Expand Up @@ -334,24 +334,22 @@ public function getMethodImage(string $name): string
* the way this event is handled, taking its return into account. For now, we just abuse the mutable event
* properties - a feature of the event objects we discussed in the Joomla! 4 Working Group back in August 2015.
*
* @param Event $event The Joomla! event object
* @param Module\AfterModuleListEvent $event The Joomla! event object
*
* @return void
* @throws \Exception
*
* @since 4.2.0
*/
public function onAfterModuleList(Event $event): void
public function onAfterModuleList(Module\AfterModuleListEvent $event): void
{
$modules = $event->getArgument(0);
$modules = $event->getModules();

if (empty($modules)) {
return;
}

$this->filterModules($modules);

$event->setArgument(0, $modules);
}

/**
Expand Down
41 changes: 27 additions & 14 deletions components/com_content/src/View/Article/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace Joomla\Component\Content\Site\View\Article;

use Joomla\CMS\Categories\Categories;
use Joomla\CMS\Event\Content;
use Joomla\CMS\Factory;
use Joomla\CMS\Helper\TagsHelper;
use Joomla\CMS\Language\Associations;
Expand All @@ -23,7 +24,6 @@
use Joomla\CMS\Uri\Uri;
use Joomla\Component\Content\Site\Helper\AssociationHelper;
use Joomla\Component\Content\Site\Helper\RouteHelper;
use Joomla\Event\Event;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
Expand Down Expand Up @@ -173,7 +173,7 @@ public function display($tpl = null)
}
}

$offset = $this->state->get('list.offset');
$offset = (int) $this->state->get('list.offset');

// Check the view access to the article (the model has already computed the values).
if ($item->params->get('access-view') == false && ($item->params->get('show_noauth', '0') == '0')) {
Expand Down Expand Up @@ -223,18 +223,31 @@ public function display($tpl = null)
}

// Process the content plugins.
PluginHelper::importPlugin('content');
$this->dispatchEvent(new Event('onContentPrepare', ['com_content.article', &$item, &$item->params, $offset]));

$item->event = new \stdClass();
$results = Factory::getApplication()->triggerEvent('onContentAfterTitle', ['com_content.article', &$item, &$item->params, $offset]);
$item->event->afterDisplayTitle = trim(implode("\n", $results));

$results = Factory::getApplication()->triggerEvent('onContentBeforeDisplay', ['com_content.article', &$item, &$item->params, $offset]);
$item->event->beforeDisplayContent = trim(implode("\n", $results));

$results = Factory::getApplication()->triggerEvent('onContentAfterDisplay', ['com_content.article', &$item, &$item->params, $offset]);
$item->event->afterDisplayContent = trim(implode("\n", $results));
PluginHelper::importPlugin('content', null, true, $this->getDispatcher());

$contentEventArguments = [
'context' => 'com_content.article',
'subject' => $item,
'params' => $item->params,
'page' => $offset,
];

$this->dispatchEvent(new Content\ContentPrepareEvent('onContentPrepare', $contentEventArguments));

// Extra content from events
$item->event = new \stdClass();
$contentEvents = [
'afterDisplayTitle' => new Content\AfterTitleEvent('onContentAfterTitle', $contentEventArguments),
'beforeDisplayContent' => new Content\BeforeDisplayEvent('onContentBeforeDisplay', $contentEventArguments),
'afterDisplayContent' => new Content\AfterDisplayEvent('onContentAfterDisplay', $contentEventArguments),
];

foreach ($contentEvents as $resultKey => $event) {
$this->dispatchEvent($event);
$results = $event['result'];

$item->event->{$resultKey} = $results ? trim(implode("\n", $results)) : '';
}

// Escape strings for HTML output
$this->pageclass_sfx = htmlspecialchars($this->item->params->get('pageclass_sfx', ''));
Expand Down
9 changes: 7 additions & 2 deletions components/com_users/src/Controller/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace Joomla\Component\Users\Site\Controller;

use Joomla\CMS\Event\Model;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Router\Route;
Expand Down Expand Up @@ -105,9 +106,13 @@ public function save()

// Send an object which can be modified through the plugin event
$objData = (object) $requestData;
$app->triggerEvent(
$this->getDispatcher()->dispatch(
'onContentNormaliseRequestData',
['com_users.user', $objData, $form]
new Model\NormaliseRequestDataEvent('onContentNormaliseRequestData', [
'context' => 'com_users.user',
'data' => $objData,
'subject' => $form,
])
);
$requestData = (array) $objData;

Expand Down
10 changes: 9 additions & 1 deletion libraries/src/Document/Renderer/Html/ModulesRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
namespace Joomla\CMS\Document\Renderer\Html;

use Joomla\CMS\Document\DocumentRenderer;
use Joomla\CMS\Event\Module;
use Joomla\CMS\Factory;
use Joomla\CMS\Helper\ModuleHelper;
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Proxy\ArrayProxy;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
Expand Down Expand Up @@ -57,7 +59,13 @@ public function render($position, $params = [], $content = null)
$buffer .= $moduleHtml;
}

$app->triggerEvent('onAfterRenderModules', [&$buffer, &$params]);
// Dispatch onAfterRenderModules event
$event = new Module\AfterRenderModulesEvent('onAfterRenderModules', [
'subject' => $buffer,
'attributes' => new ArrayProxy($params),
]);
$app->getDispatcher()->dispatch('onAfterRenderModules', $event);
$buffer = $event->getContent();

return $buffer;
}
Expand Down
2 changes: 0 additions & 2 deletions libraries/src/Event/AbstractEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ public function __construct(string $name, array $arguments = [])
{
parent::__construct($name, $arguments);

$this->arguments = [];

foreach ($arguments as $argumentName => $value) {
$this->setArgument($argumentName, $value);
}
Expand Down
31 changes: 31 additions & 0 deletions libraries/src/Event/Content/AfterDisplayEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?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\Content;

use Joomla\CMS\Event\Result\ResultAware;
use Joomla\CMS\Event\Result\ResultAwareInterface;
use Joomla\CMS\Event\Result\ResultTypeStringAware;

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

/**
* Class for Content event.
* Example:
* new AfterDisplayEvent('onEventName', ['context' => 'com_example.example', 'subject' => $contentObject, 'params' => $params, 'page' => $pageNum]);
*
* @since __DEPLOY_VERSION__
*/
class AfterDisplayEvent extends ContentPrepareEvent implements ResultAwareInterface
{
use ResultAware;
use ResultTypeStringAware;
}
31 changes: 31 additions & 0 deletions libraries/src/Event/Content/AfterTitleEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?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\Content;

use Joomla\CMS\Event\Result\ResultAware;
use Joomla\CMS\Event\Result\ResultAwareInterface;
use Joomla\CMS\Event\Result\ResultTypeStringAware;

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

/**
* Class for Content event.
* Example:
* new AfterTitleEvent('onEventName', ['context' => 'com_example.example', 'subject' => $contentObject, 'params' => $params, 'page' => $pageNum]);
*
* @since __DEPLOY_VERSION__
*/
class AfterTitleEvent extends ContentPrepareEvent implements ResultAwareInterface
{
use ResultAware;
use ResultTypeStringAware;
}
31 changes: 31 additions & 0 deletions libraries/src/Event/Content/BeforeDisplayEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?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\Content;

use Joomla\CMS\Event\Result\ResultAware;
use Joomla\CMS\Event\Result\ResultAwareInterface;
use Joomla\CMS\Event\Result\ResultTypeStringAware;

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

/**
* Class for Content event.
* Example:
* new BeforeDisplayEvent('onEventName', ['context' => 'com_example.example', 'subject' => $contentObject, 'params' => $params, 'page' => $pageNum]);
*
* @since __DEPLOY_VERSION__
*/
class BeforeDisplayEvent extends ContentPrepareEvent implements ResultAwareInterface
{
use ResultAware;
use ResultTypeStringAware;
}
Loading