vendor/se7enxweb/admin-ui/src/lib/Component/Registry.php line 122

Open in your IDE?
  1. <?php
  2. /**
  3. * @copyright Copyright (C) Ibexa AS. All rights reserved.
  4. * @license For full copyright and license information view LICENSE file distributed with this source code.
  5. */
  6. declare(strict_types=1);
  7. namespace Ibexa\AdminUi\Component;
  8. use Ibexa\Contracts\TwigComponents\ComponentInterface;
  9. use Ibexa\TwigComponents\Component\Registry as TwigComponentsRegistry;
  10. /**
  11. * @deprecated 4.6.19 The {@see \Ibexa\AdminUi\Component\Registry} class is deprecated, will be removed in 6.0.
  12. * Use {@see \Ibexa\TwigComponents\Component\Registry} instead
  13. */
  14. class Registry
  15. {
  16. /**
  17. * @var string[]
  18. */
  19. private const COMPONENTS_WHITELIST =
  20. [
  21. 'action-configuration-tabs',
  22. 'attribute-definition-block',
  23. 'attribute-definition-options-block',
  24. 'attribute-group-block',
  25. 'calendar-widget-before',
  26. 'catalog-block',
  27. 'content-create-form-after',
  28. 'content-create-form-before',
  29. 'content-edit-form-after',
  30. 'content-edit-form-before',
  31. 'content-edit-sections',
  32. 'content-form-create-header-actions',
  33. 'content-form-edit-header-actions',
  34. 'content-tree-after',
  35. 'content-tree-before',
  36. 'content-type-edit-sections',
  37. 'content-type-tab-groups',
  38. 'customer-group-block',
  39. 'dashboard-all-tab-groups',
  40. 'dashboard-blocks',
  41. 'dashboard-my-tab-groups',
  42. 'discount-block',
  43. 'discount-condition-code-summary',
  44. 'discount-condition-code-usage-summary',
  45. 'discount-condition-summary',
  46. 'form-content-add-translation-body',
  47. 'global-search',
  48. 'global-search-autocomplete-templates',
  49. 'header-user-menu-middle',
  50. 'image-edit-actions-after',
  51. 'infobar-options-before',
  52. 'layout-content-after',
  53. 'link-manager-block',
  54. 'location-view-content-alerts',
  55. 'location-view-tab-groups',
  56. 'location-view-tabs-after',
  57. 'login-form-after',
  58. 'login-form-before',
  59. 'order-details-summary-grid',
  60. 'order-details-summary-stats',
  61. 'payment-method-tabs',
  62. 'product-block',
  63. 'product-create-form-after',
  64. 'product-create-form-header-actions',
  65. 'product-edit-form-after',
  66. 'product-edit-form-header-actions',
  67. 'product-type-block',
  68. 'script-body',
  69. 'script-head',
  70. 'shipment-summary-grid',
  71. 'shipping-method-block',
  72. 'stylesheet-body',
  73. 'stylesheet-head',
  74. 'systeminfo-tab-groups',
  75. 'user-menu',
  76. 'user-profile-blocks',
  77. ];
  78. private const GROUP_PREFIX = 'admin-ui-';
  79. protected TwigComponentsRegistry $inner;
  80. public function __construct(TwigComponentsRegistry $inner)
  81. {
  82. $this->inner = $inner;
  83. }
  84. public function addComponent(string $group, string $serviceId, ComponentInterface $component): void
  85. {
  86. $this->triggerDeprecation();
  87. $group = $this->prefixGroupIfNeeded($group);
  88. $this->inner->addComponent($group, $serviceId, $component);
  89. }
  90. /**
  91. * @return \Ibexa\Contracts\TwigComponents\ComponentInterface[]
  92. */
  93. public function getComponents(string $group): array
  94. {
  95. $this->triggerDeprecation();
  96. $group = $this->prefixGroupIfNeeded($group);
  97. return $this->inner->getComponents($group);
  98. }
  99. /**
  100. * @param \Ibexa\Contracts\TwigComponents\ComponentInterface[] $components
  101. */
  102. public function setComponents(string $group, array $components)
  103. {
  104. $this->triggerDeprecation();
  105. $group = $this->prefixGroupIfNeeded($group);
  106. $this->inner->setComponents($group, $components);
  107. }
  108. private function triggerDeprecation(): void
  109. {
  110. trigger_deprecation(
  111. 'ibexa/admin-ui',
  112. '4.6.19',
  113. sprintf(
  114. 'The %s is deprecated, will be removed in 5.0. Use %s instead',
  115. self::class,
  116. TwigComponentsRegistry::class
  117. )
  118. );
  119. }
  120. private function prefixGroupIfNeeded(string $group): string
  121. {
  122. if (in_array($group, self::COMPONENTS_WHITELIST, true)) {
  123. return self::GROUP_PREFIX . $group;
  124. }
  125. return $group;
  126. }
  127. }
  128. class_alias(Registry::class, 'EzSystems\EzPlatformAdminUi\Component\Registry');