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
340 changes: 2 additions & 338 deletions phpstan-baseline.neon

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/bundle/Resources/config/services/events.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ services:
Ibexa\AdminUi\EventListener\AdminExceptionListener:
arguments:
$siteAccessGroups: '%ibexa.site_access.groups%'
$kernelProjectDir: '%kernel.project_dir%'
$rootDir: '%kernel.project_dir%'
$kernelEnvironment: '%kernel.environment%'
$encoreTagRenderer: '@webpack_encore.tag_renderer'
$entrypointLookupCollection: '@webpack_encore.entrypoint_lookup_collection'
Expand Down
20 changes: 6 additions & 14 deletions src/lib/Component/Content/ContentEditMetaFieldsComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,18 @@
use Ibexa\Core\Repository\Values\ContentType\FieldDefinition;
use Twig\Environment;

class ContentEditMetaFieldsComponent implements ComponentInterface
final readonly class ContentEditMetaFieldsComponent implements ComponentInterface
{
private const NO_CONTENT = '';

private Environment $twig;

private ConfigResolverInterface $configResolver;
private const string NO_CONTENT = '';

public function __construct(
Environment $twig,
ConfigResolverInterface $configResolver
private Environment $twig,
private ConfigResolverInterface $configResolver
) {
$this->twig = $twig;
$this->configResolver = $configResolver;
}

/**
* @param array<string, mixed> $parameters
*
* @return string
*/
public function render(array $parameters = []): string
{
Expand Down Expand Up @@ -84,8 +76,8 @@ private function getMetaFieldDefinitionCollection(ContentType $contentType): Fie
'admin_ui_forms.content_edit.meta_field_groups_list'
);

return $contentType->fieldDefinitions->filter(
static fn (FieldDefinition $field): bool => in_array($field->fieldGroup, $metaFieldGroups, true),
return $contentType->getFieldDefinitions()->filter(
static fn (FieldDefinition $field): bool => in_array($field->getFieldGroup(), $metaFieldGroups, true),
);
}

Expand Down
41 changes: 16 additions & 25 deletions src/lib/Component/Content/PreviewUnavailableTwigComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,17 @@
use Ibexa\Contracts\TwigComponents\ComponentInterface;
use Twig\Environment;

class PreviewUnavailableTwigComponent implements ComponentInterface
final readonly class PreviewUnavailableTwigComponent implements ComponentInterface
{
private Environment $twig;

/** @var \Ibexa\AdminUi\Siteaccess\NonAdminSiteaccessResolver */
private SiteaccessResolverInterface $siteaccessResolver;

private LocationService $locationService;

/**
* @param \Twig\Environment $twig
* @param \Ibexa\AdminUi\Siteaccess\NonAdminSiteaccessResolver $siteaccessResolver
* @param \Ibexa\Contracts\Core\Repository\LocationService $locationService
*/
public function __construct(
Environment $twig,
SiteaccessResolverInterface $siteaccessResolver,
LocationService $locationService
private Environment $twig,
private SiteaccessResolverInterface $siteaccessResolver,
private LocationService $locationService
) {
$this->twig = $twig;
$this->siteaccessResolver = $siteaccessResolver;
$this->locationService = $locationService;
}

/**
* @param array $parameters
*
* @return string
* @param array<mixed> $parameters
*/
public function render(array $parameters = []): string
{
Expand All @@ -56,9 +39,17 @@ public function render(array $parameters = []): string
$versionNo = $content->getVersionInfo()->versionNo;

// nonpublished content should use parent location instead because location doesn't exist yet
if (!$content->contentInfo->published && null === $content->contentInfo->mainLocationId) {
$parentLocations = $this->locationService->loadParentLocationsForDraftContent($content->getVersionInfo());
$contentInfo = $content->getContentInfo();
if (!$contentInfo->isPublished() && null === $contentInfo->getMainLocationId()) {
$parentLocations = $this->locationService->loadParentLocationsForDraftContent(
$content->getVersionInfo()
);

$location = reset($parentLocations);
if ($location === false) {
return '';
}

$versionNo = null;
}

Expand All @@ -68,7 +59,7 @@ public function render(array $parameters = []): string
$versionNo,
$language->languageCode
);
} catch (UnauthorizedException $e) {
} catch (UnauthorizedException) {
$siteaccesses = [];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,14 @@
use Ibexa\Contracts\TwigComponents\ComponentInterface;
use Twig\Environment;

final class ContentTypeEditMetaFieldsComponent implements ComponentInterface
final readonly class ContentTypeEditMetaFieldsComponent implements ComponentInterface
{
private const NO_CONTENT = '';

private ContentTypeFieldTypesResolverInterface $contentTypeFieldTypesResolver;

private Environment $twig;
private const string NO_CONTENT = '';

public function __construct(
ContentTypeFieldTypesResolverInterface $contentTypeFieldTypesResolver,
Environment $twig
private ContentTypeFieldTypesResolverInterface $contentTypeFieldTypesResolver,
private Environment $twig
) {
$this->contentTypeFieldTypesResolver = $contentTypeFieldTypesResolver;
$this->twig = $twig;
}

/**
Expand Down
33 changes: 11 additions & 22 deletions src/lib/Component/Event/RenderGroupEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,54 +15,43 @@
* @deprecated 4.6.19 The {@see \Ibexa\AdminUi\Component\Event\RenderGroupEvent} class is deprecated, will be removed in 6.0.
* Use {@see \Ibexa\Contracts\TwigComponents\Event\RenderGroupEvent} instead
*/
class RenderGroupEvent extends Event
final class RenderGroupEvent extends Event
{
public const NAME = 'ezplatform_admin_ui.component.render_group';

private Registry $registry;

private string $groupName;

private array $parameters;
public const string NAME = 'ezplatform_admin_ui.component.render_group';

/**
* @param \Ibexa\AdminUi\Component\Registry $registry
* @param string $groupName
* @param array $parameters
* @param array<string, mixed> $parameters
*/
public function __construct(Registry $registry, string $groupName, array $parameters = [])
{
$this->registry = $registry;
$this->groupName = $groupName;
$this->parameters = $parameters;
public function __construct(
private readonly Registry $registry,
private readonly string $groupName,
private readonly array $parameters = []
) {
}

/**
* @return string
*/
public function getGroupName(): string
{
return $this->groupName;
}

/**
* @return array
* @return \Ibexa\Contracts\TwigComponents\ComponentInterface[]
*/
public function getComponents(): array
{
return $this->registry->getComponents($this->getGroupName());
}

/**
* @param array $components
* @param \Ibexa\Contracts\TwigComponents\ComponentInterface[] $components
*/
public function setComponents(array $components): void
{
$this->registry->setComponents($this->getGroupName(), $components);
}

/**
* @return array
* @return array<string, mixed>
*/
public function getParameters(): array
{
Expand Down
40 changes: 9 additions & 31 deletions src/lib/Component/Event/RenderSingleEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,60 +16,38 @@
* @deprecated 4.6.19 The {@see \Ibexa\AdminUi\Component\Event\RenderSingleEvent} class is deprecated, will be removed in 6.0.
* Use {@see \Ibexa\Contracts\TwigComponents\Event\RenderSingleEvent} instead
*/
class RenderSingleEvent extends Event
final class RenderSingleEvent extends Event
{
public const NAME = 'ezplatform_admin_ui.component.render_single';

private Registry $registry;

private string $groupName;

private string $serviceId;

private array $parameters;
public const string NAME = 'ezplatform_admin_ui.component.render_single';

/**
* @param \Ibexa\AdminUi\Component\Registry $registry
* @param string $groupName
* @param array $parameters
* @param array<string, mixed> $parameters
*/
public function __construct(Registry $registry, string $groupName, string $serviceId, array $parameters = [])
{
$this->registry = $registry;
$this->groupName = $groupName;
$this->serviceId = $serviceId;
$this->parameters = $parameters;
public function __construct(
private readonly Registry $registry,
private readonly string $groupName,
private readonly string $serviceId,
private readonly array $parameters = []
) {
}

/**
* @return string
*/
public function getGroupName(): string
{
return $this->groupName;
}

/**
* @return string
*/
public function getName(): string
{
return $this->serviceId;
}

/**
* @return \Ibexa\Contracts\TwigComponents\ComponentInterface
*/
public function getComponent(): ComponentInterface
{
$group = $this->registry->getComponents($this->getGroupName());

return $group[$this->serviceId];
}

/**
* @param \Ibexa\Contracts\TwigComponents\ComponentInterface $component
*/
public function setComponent(ComponentInterface $component): void
{
$this->registry->addComponent($this->getGroupName(), $this->getName(), $component);
Expand Down
12 changes: 3 additions & 9 deletions src/lib/Component/EventSubscriber/RenderEventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,12 @@
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

final class RenderEventSubscriber implements EventSubscriberInterface
final readonly class RenderEventSubscriber implements EventSubscriberInterface
{
private Registry $registry;

private EventDispatcherInterface $eventDispatcher;

public function __construct(
EventDispatcherInterface $eventDispatcher,
Registry $registry
private EventDispatcherInterface $eventDispatcher,
private Registry $registry
) {
$this->registry = $registry;
$this->eventDispatcher = $eventDispatcher;
}

public static function getSubscribedEvents(): array
Expand Down
36 changes: 8 additions & 28 deletions src/lib/Component/LinkComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,20 @@
* @deprecated 4.6.19 The {@see \Ibexa\AdminUi\Component\LinkComponent} class is deprecated, will be removed in 6.0.
* Use {@see \Ibexa\TwigComponents\Component\LinkComponent} instead
*/
class LinkComponent implements ComponentInterface
readonly class LinkComponent implements ComponentInterface
{
protected Environment $twig;

protected string $href;

protected string $type;

protected string $rel;

protected ?string $crossorigin;

protected ?string $integrity;

public function __construct(
Environment $twig,
string $href,
string $type = 'text/css',
string $rel = 'stylesheet',
?string $crossorigin = null,
?string $integrity = null
protected Environment $twig,
protected string $href,
protected string $type = 'text/css',
protected string $rel = 'stylesheet',
protected ?string $crossorigin = null,
protected ?string $integrity = null
) {
$this->twig = $twig;
$this->href = $href;
$this->type = $type;
$this->rel = $rel;
$this->crossorigin = $crossorigin;
$this->integrity = $integrity;
}

/**
* @param array $parameters
*
* @return string
* @param array<mixed> $parameters
*/
public function render(array $parameters = []): string
{
Expand Down
14 changes: 4 additions & 10 deletions src/lib/Component/Registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@
* @deprecated 4.6.19 The {@see \Ibexa\AdminUi\Component\Registry} class is deprecated, will be removed in 6.0.
* Use {@see \Ibexa\TwigComponents\Component\Registry} instead
*/
class Registry
readonly class Registry
{
/**
* @var string[]
*/
private const COMPONENTS_WHITELIST =
private const array COMPONENTS_WHITELIST =
[
'action-configuration-tabs',
'attribute-definition-block',
Expand Down Expand Up @@ -80,13 +77,10 @@ class Registry
'user-profile-blocks',
];

private const GROUP_PREFIX = 'admin-ui-';

protected TwigComponentsRegistry $inner;
private const string GROUP_PREFIX = 'admin-ui-';

public function __construct(TwigComponentsRegistry $inner)
public function __construct(protected TwigComponentsRegistry $inner)
{
$this->inner = $inner;
}

public function addComponent(string $group, string $serviceId, ComponentInterface $component): void
Expand Down
Loading
Loading