vendor/ibexa/core/src/lib/MVC/Symfony/SiteAccess.php line 15

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. namespace Ibexa\Core\MVC\Symfony;
  7. use Ibexa\Contracts\Core\Repository\Values\ValueObject;
  8. use JsonSerializable;
  9. /**
  10. * Base struct for a siteaccess representation.
  11. */
  12. class SiteAccess extends ValueObject implements JsonSerializable
  13. {
  14. public const DEFAULT_MATCHING_TYPE = 'default';
  15. /**
  16. * Name of the siteaccess.
  17. *
  18. * @var string
  19. */
  20. public $name;
  21. /** @var \Ibexa\Core\MVC\Symfony\SiteAccessGroup[] */
  22. public $groups = [];
  23. /**
  24. * The matching type that has been used to discover the siteaccess.
  25. * Contains the matcher class FQN, or 'default' if fell back to the default siteaccess.
  26. *
  27. * @var string
  28. */
  29. public $matchingType;
  30. /**
  31. * The matcher instance that has been used to discover the siteaccess.
  32. *
  33. * @var \Ibexa\Core\MVC\Symfony\SiteAccess\Matcher
  34. */
  35. public $matcher;
  36. /**
  37. * The name of the provider from which Site Access comes.
  38. *
  39. * @var string|null
  40. */
  41. public $provider;
  42. public function __construct(
  43. string $name,
  44. string $matchingType = self::DEFAULT_MATCHING_TYPE,
  45. $matcher = null,
  46. ?string $provider = null,
  47. array $groups = []
  48. ) {
  49. $this->name = $name;
  50. $this->matchingType = $matchingType;
  51. $this->matcher = $matcher;
  52. $this->provider = $provider;
  53. $this->groups = $groups;
  54. }
  55. public function __toString()
  56. {
  57. return "$this->name (matched by '$this->matchingType')";
  58. }
  59. public function jsonSerialize(): array
  60. {
  61. $matcher = is_object($this->matcher) ? get_class($this->matcher) : null;
  62. return [
  63. 'name' => $this->name,
  64. 'matchingType' => $this->matchingType,
  65. 'matcher' => $matcher,
  66. 'provider' => $this->provider,
  67. 'groups' => $this->groups,
  68. ];
  69. }
  70. }
  71. class_alias(SiteAccess::class, 'eZ\Publish\Core\MVC\Symfony\SiteAccess');