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
2 changes: 1 addition & 1 deletion libraries/src/Document/Renderer/Html/ModulesRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function render($position, $params = [], $content = null)

// Dispatch onAfterRenderModules event
$event = new Module\AfterRenderModulesEvent('onAfterRenderModules', [
'subject' => $buffer,
'subject' => &$buffer, // TODO: Remove reference in Joomla 6, see AfterRenderModulesEvent::__constructor()
'attributes' => new ArrayProxy($params),
]);
$app->getDispatcher()->dispatch('onAfterRenderModules', $event);
Expand Down
13 changes: 11 additions & 2 deletions libraries/src/Event/Module/AfterRenderModulesEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ public function __construct($name, array $arguments = [])
if (!\array_key_exists('attributes', $this->arguments)) {
throw new \BadMethodCallException("Argument 'attributes' of event {$name} is required but has not been provided");
}

// For backward compatibility make sure the content is referenced
// TODO: Remove in Joomla 6
// @deprecated: Passing argument by reference is deprecated, and will not work in Joomla 6
if (key($arguments) === 0) {
$this->arguments['subject'] = &$arguments[0];
} elseif (\array_key_exists('subject', $arguments)) {
$this->arguments['subject'] = &$arguments['subject'];
}
}

/**
Expand Down Expand Up @@ -96,11 +105,11 @@ public function getContent(): string
*
* @param string $value The value to set
*
* @return self
* @return static
*
* @since 5.0.0
*/
public function setContent(string $value): self
public function updateContent(string $value): static
{
$this->arguments['subject'] = $value;

Expand Down
6 changes: 3 additions & 3 deletions libraries/src/Event/Module/ModuleEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ public function __construct($name, array $arguments = [])
$arguments = $this->reshapeArguments($arguments, $this->legacyArgumentsOrder);
}

if (!\array_key_exists('subject', $arguments)) {
parent::__construct($name, $arguments);

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

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