Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

Publish/Core/Base/Container/ApiLoader/RepositoryFactory.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\Base\Container\ApiLoader;
8
9 use eZ\Publish\Core\Repository\Helper\RelationProcessor;
10 use eZ\Publish\Core\Repository\Values\User\UserReference;
11 use eZ\Publish\Core\Search\Common\BackgroundIndexer;
12 use eZ\Publish\SPI\Persistence\Handler as PersistenceHandler;
13 use eZ\Publish\SPI\Search\Handler as SearchHandler;
14 use eZ\Publish\SPI\Limitation\Type as SPILimitationType;
15 use eZ\Publish\API\Repository\Repository;
16 use Symfony\Component\DependencyInjection\ContainerAwareInterface;
17 use Symfony\Component\DependencyInjection\ContainerAwareTrait;
18 use eZ\Publish\Core\Base\Exceptions\InvalidArgumentException;
19
20 class RepositoryFactory implements ContainerAwareInterface
21 {
22 use ContainerAwareTrait;
23
25 private $repositoryClass;
26
32 protected $fieldTypeCollectionFactory;
33
39 protected $fieldTypeNameableCollectionFactory;
40
46 protected $roleLimitations = [];
47
53 protected $policyMap = [];
54
55 public function __construct(
56 $repositoryClass,
57 FieldTypeCollectionFactory $fieldTypeCollectionFactory,
58 FieldTypeNameableCollectionFactory $fieldTypeNameableCollectionFactory,
59 array $policyMap
60 ) {
61 $this->repositoryClass = $repositoryClass;
62 $this->fieldTypeCollectionFactory = $fieldTypeCollectionFactory;
63 $this->fieldTypeNameableCollectionFactory = $fieldTypeNameableCollectionFactory;
64 $this->policyMap = $policyMap;
65 }
66
79 public function buildRepository(
80 PersistenceHandler $persistenceHandler,
81 SearchHandler $searchHandler,
82 BackgroundIndexer $backgroundIndexer,
83 RelationProcessor $relationProcessor
84 ) {
85 $repository = new $this->repositoryClass(
86 $persistenceHandler,
87 $searchHandler,
88 $backgroundIndexer,
89 $relationProcessor,
90 [
91 'fieldType' => $this->fieldTypeCollectionFactory->getFieldTypes(),
92 'nameableFieldTypes' => $this->fieldTypeNameableCollectionFactory->getNameableFieldTypes(),
93 'role' => [
94 'limitationTypes' => $this->roleLimitations,
95 'policyMap' => $this->policyMap,
96 ],
97 'languages' => $this->container->getParameter('languages'),
98 ],
99 new UserReference($this->container->getParameter('anonymous_user_id'))
100 );
101
102 return $repository;
103 }
104
111 public function registerLimitationType($limitationName, SPILimitationType $limitationType)
112 {
113 $this->roleLimitations[$limitationName] = $limitationType;
114 }
115
126 public function buildService(Repository $repository, $serviceName)
127 {
128 $methodName = 'get' . $serviceName . 'Service';
129 if (!method_exists($repository, $methodName)) {
130 throw new InvalidArgumentException($serviceName, 'No such service');
131 }
132
133 return $repository->$methodName();
134 }
135 }
eZ\Publish\Core\Base\Container\ApiLoader\FieldTypeCollectionFactory
Definition: FieldTypeCollectionFactory.php:13
eZ\Publish\Core\Base\Container\ApiLoader\FieldTypeNameableCollectionFactory
Definition: FieldTypeNameableCollectionFactory.php:14
eZ\Publish\Core\Base\Container\ApiLoader\RepositoryFactory
Definition: Publish/Core/Base/Container/ApiLoader/RepositoryFactory.php:21
eZ\Publish\Core\Base\Container\ApiLoader\RepositoryFactory\$fieldTypeNameableCollectionFactory
$fieldTypeNameableCollectionFactory
Definition: Publish/Core/Base/Container/ApiLoader/RepositoryFactory.php:39
eZ\Publish\Core\Base\Container\ApiLoader\RepositoryFactory\$fieldTypeCollectionFactory
$fieldTypeCollectionFactory
Definition: Publish/Core/Base/Container/ApiLoader/RepositoryFactory.php:32
eZ\Publish\Core\Base\Container\ApiLoader\RepositoryFactory\registerLimitationType
registerLimitationType($limitationName, SPILimitationType $limitationType)
Registers a limitation type for the RoleService.
Definition: Publish/Core/Base/Container/ApiLoader/RepositoryFactory.php:111
eZ\Publish\Core\Base\Container\ApiLoader\RepositoryFactory\$repositoryClass
$repositoryClass
Definition: Publish/Core/Base/Container/ApiLoader/RepositoryFactory.php:25
eZ\Publish\Core\Base\Container\ApiLoader\RepositoryFactory\buildService
buildService(Repository $repository, $serviceName)
Returns a service based on a name string (content => contentService, etc).
Definition: Publish/Core/Base/Container/ApiLoader/RepositoryFactory.php:126
eZ\Publish\Core\Base\Container\ApiLoader\RepositoryFactory\__construct
__construct( $repositoryClass, FieldTypeCollectionFactory $fieldTypeCollectionFactory, FieldTypeNameableCollectionFactory $fieldTypeNameableCollectionFactory, array $policyMap)
Definition: Publish/Core/Base/Container/ApiLoader/RepositoryFactory.php:55
eZ\Publish\Core\Base\Container\ApiLoader\RepositoryFactory\buildRepository
buildRepository(PersistenceHandler $persistenceHandler, SearchHandler $searchHandler, BackgroundIndexer $backgroundIndexer, RelationProcessor $relationProcessor)
Builds the main repository, heart of eZ Publish API.
Definition: Publish/Core/Base/Container/ApiLoader/RepositoryFactory.php:79
eZ\Publish\Core\Base\Container\ApiLoader\RepositoryFactory\$policyMap
$policyMap
Definition: Publish/Core/Base/Container/ApiLoader/RepositoryFactory.php:53
eZ\Publish\Core\Base\Container\ApiLoader\RepositoryFactory\$roleLimitations
$roleLimitations
Definition: Publish/Core/Base/Container/ApiLoader/RepositoryFactory.php:46
eZ\Publish\Core\Base\Exceptions\InvalidArgumentException
Invalid Argument Type Exception implementation.
Definition: Core/Base/Exceptions/InvalidArgumentException.php:20
eZ\Publish\Core\Repository\Helper\RelationProcessor
RelationProcessor is an internal service used for handling field relations upon Content creation or u...
Definition: Repository/Helper/RelationProcessor.php:25
eZ\Publish\Core\Repository\Values\User\UserReference
This class represents a user reference for use in sessions and Repository.
Definition: Core/Repository/Values/User/UserReference.php:17
eZ\Publish\API\Repository\Repository
Repository interface.
Definition: API/Repository/Repository.php:16
eZ\Publish\Core\Search\Common\BackgroundIndexer
Interface for performing indexing in background.
Definition: BackgroundIndexer.php:21
eZ\Publish\SPI\Limitation\Type
This interface represent the Limitation Type.
Definition: SPI/Limitation/Type.php:22
eZ\Publish\SPI\Persistence\Handler
The main handler for Storage Engine.
Definition: SPI/Persistence/Handler.php:15
eZ\Publish\SPI\Search\Handler
The Search handler retrieves sets of of Content objects, based on a set of criteria.
Definition: SPI/Search/Handler.php:20
eZ\Publish\Core\Base\Container\ApiLoader
Definition: FieldTypeCollectionFactory.php:7
eZ\Publish\Core\Search\Common\BackgroundIndexer
Definition: NullIndexer.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.