castopod/app/Libraries/ViewComponents/Helpers/view_components_helper.php
Yassine Doghri 94872f2338 feat(ui): create ViewComponents library to enable building class and view files components
- replace some helper components and forms with class components in the ui
- create viewcomponents
service and load the component function to be used in views
2021-12-29 11:54:22 +00:00

29 lines
782 B
PHP

<?php
declare(strict_types=1);
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
if (! function_exists('component')) {
/**
* Loads the specified class or view file component in the parameters
*
* @param array<string, array<string, mixed>> $properties
* @param array<string, array<string, mixed>> $attributes
*/
function component(string $name, array $properties = [], array $attributes = []): string
{
$componentLoader = service('viewcomponents');
$componentLoader->name = $name;
$componentLoader->properties = $properties;
$componentLoader->attributes = $attributes;
return $componentLoader->load();
}
}