Skip to content

Commit

Permalink
Merge branch '5.1-dev' into loader
Browse files Browse the repository at this point in the history
  • Loading branch information
Quy committed Feb 28, 2024
2 parents ef94d64 + af73758 commit 457642b
Show file tree
Hide file tree
Showing 48 changed files with 463 additions and 162 deletions.
2 changes: 1 addition & 1 deletion libraries/src/Form/Field/CalendarField.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ protected function getInput()
$this->value = '';
}

return $this->getRenderer($this->layout)->render($this->getLayoutData());
return $this->getRenderer($this->layout)->render($this->collectLayoutData());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/Field/CheckboxesField.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ protected function getInput()
throw new \UnexpectedValueException(sprintf('%s has no layout assigned.', $this->name));
}

return $this->getRenderer($this->layout)->render($this->getLayoutData());
return $this->getRenderer($this->layout)->render($this->collectLayoutData());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/Field/ColorField.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ protected function getInput()
}

// Trim the trailing line in the layout file
return rtrim($this->getRenderer($this->layout)->render($this->getLayoutData()), PHP_EOL);
return rtrim($this->getRenderer($this->layout)->render($this->collectLayoutData()), PHP_EOL);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/Field/ComboField.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected function getInput()
throw new \UnexpectedValueException(sprintf('%s has no layout assigned.', $this->name));
}

return $this->getRenderer($this->layout)->render($this->getLayoutData());
return $this->getRenderer($this->layout)->render($this->collectLayoutData());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/Field/ContenthistoryField.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,6 @@ protected function getInput()
throw new \UnexpectedValueException(sprintf('%s has no layout assigned.', $this->name));
}

return $this->getRenderer($this->layout)->render($this->getLayoutData());
return $this->getRenderer($this->layout)->render($this->collectLayoutData());
}
}
2 changes: 1 addition & 1 deletion libraries/src/Form/Field/EmailField.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class EmailField extends TextField
protected function getInput()
{
// Trim the trailing line in the layout file
return rtrim($this->getRenderer($this->layout)->render($this->getLayoutData()), PHP_EOL);
return rtrim($this->getRenderer($this->layout)->render($this->collectLayoutData()), PHP_EOL);
}
/**
* Method to get the data to be passed to the layout for rendering.
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/Field/FileField.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function setup(\SimpleXMLElement $element, $value, $group = null)
*/
protected function getInput()
{
return $this->getRenderer($this->layout)->render($this->getLayoutData());
return $this->getRenderer($this->layout)->render($this->collectLayoutData());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/Field/GroupedlistField.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ protected function getGroups()
*/
protected function getInput()
{
$data = $this->getLayoutData();
$data = $this->collectLayoutData();

// Get the field groups.
$data['groups'] = (array) $this->getGroups();
Expand Down
25 changes: 0 additions & 25 deletions libraries/src/Form/Field/HiddenField.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,4 @@ class HiddenField extends FormField
* @since 3.7
*/
protected $layout = 'joomla.form.field.hidden';

/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.7.0
*/
protected function getInput()
{
// Trim the trailing line in the layout file
return rtrim($this->getRenderer($this->layout)->render($this->getLayoutData()), PHP_EOL);
}

/**
* Method to get the data to be passed to the layout for rendering.
*
* @return array
*
* @since 3.7
*/
protected function getLayoutData()
{
return parent::getLayoutData();
}
}
2 changes: 1 addition & 1 deletion libraries/src/Form/Field/ListField.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ListField extends FormField
*/
protected function getInput()
{
$data = $this->getLayoutData();
$data = $this->collectLayoutData();

$data['options'] = (array) $this->getOptions();

Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/Field/MediaField.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ protected function getInput()
throw new \UnexpectedValueException(sprintf('%s has no layout assigned.', $this->name));
}

return $this->getRenderer($this->layout)->render($this->getLayoutData());
return $this->getRenderer($this->layout)->render($this->collectLayoutData());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/Field/MeterField.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public function setup(\SimpleXMLElement $element, $value, $group = null)
protected function getInput()
{
// Trim the trailing line in the layout file
return rtrim($this->getRenderer($this->layout)->render($this->getLayoutData()), PHP_EOL);
return rtrim($this->getRenderer($this->layout)->render($this->collectLayoutData()), PHP_EOL);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/Field/ModalSelectField.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ protected function getInput()
}

// Get the layout data
$data = $this->getLayoutData();
$data = $this->collectLayoutData();

// Load the content title here to avoid a double DB Query
$data['valueTitle'] = $this->getValueTitle();
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/Field/ModuleorderField.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function setup(\SimpleXMLElement $element, $value, $group = null)
*/
protected function getInput()
{
return $this->getRenderer($this->layout)->render($this->getLayoutData());
return $this->getRenderer($this->layout)->render($this->collectLayoutData());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/Field/NumberField.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ protected function getInput()
}

// Trim the trailing line in the layout file
return rtrim($this->getRenderer($this->layout)->render($this->getLayoutData()), PHP_EOL);
return rtrim($this->getRenderer($this->layout)->render($this->collectLayoutData()), PHP_EOL);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/Field/PasswordField.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public function setup(\SimpleXMLElement $element, $value, $group = null)
protected function getInput()
{
// Trim the trailing line in the layout file
return rtrim($this->getRenderer($this->layout)->render($this->getLayoutData()), PHP_EOL);
return rtrim($this->getRenderer($this->layout)->render($this->collectLayoutData()), PHP_EOL);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/Field/RadiobasicField.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class RadiobasicField extends ListField
*/
protected function getInput()
{
return $this->getRenderer($this->layout)->render($this->getLayoutData());
return $this->getRenderer($this->layout)->render($this->collectLayoutData());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/Field/RangeField.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class RangeField extends NumberField
*/
protected function getInput()
{
return $this->getRenderer($this->layout)->render($this->getLayoutData());
return $this->getRenderer($this->layout)->render($this->collectLayoutData());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/Field/RulesField.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ protected function getInput()
$this->groups = $this->getUserGroups();

// Trim the trailing line in the layout file
return trim($this->getRenderer($this->layout)->render($this->getLayoutData()));
return trim($this->getRenderer($this->layout)->render($this->collectLayoutData()));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/Field/SubformField.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public function setup(\SimpleXMLElement $element, $value, $group = null)
protected function getInput()
{
// Prepare data for renderer
$data = $this->getLayoutData();
$data = $this->collectLayoutData();
$tmpl = null;
$control = $this->name;

Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/Field/TagField.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function __construct()
*/
protected function getInput()
{
$data = $this->getLayoutData();
$data = $this->collectLayoutData();

if (!\is_array($this->value) && !empty($this->value)) {
if ($this->value instanceof TagsHelper) {
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/Field/TelephoneField.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class TelephoneField extends TextField
protected function getInput()
{
// Trim the trailing line in the layout file
return rtrim($this->getRenderer($this->layout)->render($this->getLayoutData()), PHP_EOL);
return rtrim($this->getRenderer($this->layout)->render($this->collectLayoutData()), PHP_EOL);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/Field/TextField.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ protected function getInput()
}
}

return $this->getRenderer($this->layout)->render($this->getLayoutData());
return $this->getRenderer($this->layout)->render($this->collectLayoutData());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/Field/TextareaField.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function setup(\SimpleXMLElement $element, $value, $group = null)
protected function getInput()
{
// Trim the trailing line in the layout file
return rtrim($this->getRenderer($this->layout)->render($this->getLayoutData()), PHP_EOL);
return rtrim($this->getRenderer($this->layout)->render($this->collectLayoutData()), PHP_EOL);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/Field/TimeField.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function __get($name)
*/
protected function getInput()
{
return $this->getRenderer($this->layout)->render($this->getLayoutData());
return $this->getRenderer($this->layout)->render($this->collectLayoutData());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/Field/UrlField.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class UrlField extends TextField
protected function getInput()
{
// Trim the trailing line in the layout file
return rtrim($this->getRenderer($this->layout)->render($this->getLayoutData()), PHP_EOL);
return rtrim($this->getRenderer($this->layout)->render($this->collectLayoutData()), PHP_EOL);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/Field/UserField.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ protected function getInput()
throw new \UnexpectedValueException(sprintf('%s has no layout assigned.', $this->name));
}

return $this->getRenderer($this->layout)->render($this->getLayoutData());
return $this->getRenderer($this->layout)->render($this->collectLayoutData());
}

/**
Expand Down
35 changes: 31 additions & 4 deletions libraries/src/Form/FormField.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,14 @@ abstract class FormField implements DatabaseAwareInterface, CurrentUserInterface
*/
protected $layout;

/**
* Cached data for layout rendering
*
* @var array
* @since __DEPLOY_VERSION__
*/
protected $layoutData = [];

/**
* Layout to render the form field
*
Expand Down Expand Up @@ -768,7 +776,7 @@ protected function getInput()
throw new \UnexpectedValueException(sprintf('%s has no layout assigned.', $this->name));
}

return $this->getRenderer($this->layout)->render($this->getLayoutData());
return $this->getRenderer($this->layout)->render($this->collectLayoutData());
}

/**
Expand Down Expand Up @@ -806,7 +814,7 @@ protected function getLabel()
return '';
}

$data = $this->getLayoutData();
$data = $this->collectLayoutData();

// Forcing the Alias field to display the tip below
$position = ((string) $this->element['name']) === 'alias' ? ' data-bs-placement="bottom" ' : '';
Expand Down Expand Up @@ -976,7 +984,7 @@ public function renderDataAttributes()
*/
public function render($layoutId, $data = [])
{
$data = array_merge($this->getLayoutData(), $data);
$data = array_merge($this->collectLayoutData(), $data);

return $this->getRenderer($layoutId)->render($data);
}
Expand Down Expand Up @@ -1047,7 +1055,7 @@ public function renderField($options = [])
'options' => $options,
];

$data = array_merge($this->getLayoutData(), $data);
$data = array_merge($this->collectLayoutData(), $data);

return $this->getRenderer($this->renderLayout)->render($data);
}
Expand Down Expand Up @@ -1331,6 +1339,25 @@ protected function getLayoutData()
return $options;
}

/**
* Method to get the data to be passed to the layout for rendering.
* The data is cached in memory.
*
* @return array
*
* @since __DEPLOY_VERSION__
*/
protected function collectLayoutData(): array
{
if ($this->layoutData) {
return $this->layoutData;
}

$this->layoutData = $this->getLayoutData();

return $this->layoutData;
}

/**
* Allow to override renderer include paths in child fields
*
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/TUF/DatabaseStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Tuf\Metadata\StorageBase;

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

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/TUF/TufFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
use Tuf\Loader\SizeCheckingLoader;

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

/**
Expand Down
7 changes: 6 additions & 1 deletion modules/mod_breadcrumbs/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,12 @@
/** @var WebAssetManager $wa */
$wa = $app->getDocument()->getWebAssetManager();
$prettyPrint = JDEBUG ? JSON_PRETTY_PRINT : 0;
$wa->addInline('script', json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | $prettyPrint), [], ['type' => 'application/ld+json']);
$wa->addInline(
'script',
json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | $prettyPrint),
['name' => 'inline.mod_breadcrumbs-schemaorg'],
['type' => 'application/ld+json']
);
}
?>
</nav>
21 changes: 0 additions & 21 deletions modules/mod_feed/mod_feed.php

This file was deleted.

0 comments on commit 457642b

Please sign in to comment.