Skip to content

Commit b5b7c6b

Browse files
author
MateuszKolankowski
committed
Merge branch '4.6'
2 parents 80a93b2 + b99a8a2 commit b5b7c6b

4 files changed

Lines changed: 326 additions & 10 deletions

File tree

phpstan-baseline.neon

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8460,6 +8460,12 @@ parameters:
84608460
count: 1
84618461
path: src/lib/MVC/Symfony/Routing/SimplifiedRequest.php
84628462

8463+
-
8464+
message: '#^Class Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\URLAlias referenced with incorrect case\: Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\UrlAlias\.$#'
8465+
identifier: class.nameCase
8466+
count: 1
8467+
path: src/lib/MVC/Symfony/Routing/UrlAliasRouter.php
8468+
84638469
-
84648470
message: '#^Method Ibexa\\Core\\MVC\\Symfony\\Security\\Authorization\\Attribute\:\:__construct\(\) has parameter \$function with no type specified\.$#'
84658471
identifier: missingType.parameter
@@ -10566,6 +10572,12 @@ parameters:
1056610572
count: 1
1056710573
path: src/lib/Persistence/Cache/UserPreferenceHandler.php
1056810574

10575+
-
10576+
message: '#^Return type \(Doctrine\\ORM\\Mapping\\ClassMetadataFactory\) of method Ibexa\\Core\\Persistence\\Doctrine\\SiteAccessAwareEntityManager\:\:getMetadataFactory\(\) should be compatible with return type \(Doctrine\\Persistence\\Mapping\\ClassMetadataFactory\<Doctrine\\Persistence\\Mapping\\ClassMetadata\<object\>\>\) of method Doctrine\\Persistence\\ObjectManager\:\:getMetadataFactory\(\)$#'
10577+
identifier: method.childReturnType
10578+
count: 2
10579+
path: src/lib/Persistence/Doctrine/SiteAccessAwareEntityManager.php
10580+
1056910581
-
1057010582
message: '#^Property Ibexa\\Core\\Persistence\\FieldTypeRegistry\:\:\$coreFieldTypes \(array\<Ibexa\\Contracts\\Core\\FieldType\\FieldType\>\) does not accept array\<Ibexa\\Core\\Persistence\\FieldType\>\.$#'
1057110583
identifier: assign.propertyType
@@ -17766,12 +17778,6 @@ parameters:
1776617778
count: 1
1776717779
path: src/lib/Repository/TrashService.php
1776817780

17769-
-
17770-
message: '#^Class Ibexa\\Contracts\\Core\\Persistence\\Content\\UrlAlias referenced with incorrect case\: Ibexa\\Contracts\\Core\\Persistence\\Content\\URLAlias\.$#'
17771-
identifier: class.nameCase
17772-
count: 7
17773-
path: src/lib/Repository/URLAliasService.php
17774-
1777517781
-
1777617782
message: '#^Method Ibexa\\Core\\Repository\\URLAliasService\:\:choosePrioritizedLanguageCode\(\) has parameter \$entries with no value type specified in iterable type array\.$#'
1777717783
identifier: missingType.iterableValue

src/bundle/Core/Resources/config/services.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,11 @@ services:
346346
- { name: console.command }
347347

348348
ibexa.doctrine.orm.entity_manager:
349-
class: Doctrine\ORM\EntityManager
350-
lazy: true
351-
factory: ['@ibexa.doctrine.orm.entity_manager_factory', 'getEntityManager']
349+
class: Ibexa\Core\Persistence\Doctrine\SiteAccessAwareEntityManager
350+
arguments:
351+
$entityManagerFactory: '@ibexa.doctrine.orm.entity_manager_factory'
352+
tags:
353+
- { name: 'kernel.reset', method: 'reset' }
352354

353355
ibexa.doctrine.orm.entity_manager_factory:
354356
class: Ibexa\Bundle\Core\Entity\EntityManagerFactory
Lines changed: 308 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,308 @@
1+
<?php
2+
3+
/**
4+
* @copyright Copyright (C) Ibexa AS. All rights reserved.
5+
* @license For full copyright and license information view LICENSE file distributed with this source code.
6+
*/
7+
declare(strict_types=1);
8+
9+
namespace Ibexa\Core\Persistence\Doctrine;
10+
11+
use Doctrine\DBAL\Connection;
12+
use Doctrine\ORM\Cache;
13+
use Doctrine\ORM\Configuration;
14+
use Doctrine\ORM\EntityManagerInterface;
15+
use Doctrine\ORM\EntityRepository;
16+
use Doctrine\ORM\Internal\Hydration\AbstractHydrator;
17+
use Doctrine\ORM\Mapping\ClassMetadata;
18+
use Doctrine\ORM\Mapping\ClassMetadataFactory;
19+
use Doctrine\ORM\NativeQuery;
20+
use Doctrine\ORM\Proxy\ProxyFactory;
21+
use Doctrine\ORM\Query;
22+
use Doctrine\ORM\Query\Expr;
23+
use Doctrine\ORM\Query\FilterCollection;
24+
use Doctrine\ORM\Query\ResultSetMapping;
25+
use Doctrine\ORM\QueryBuilder;
26+
use Doctrine\ORM\UnitOfWork;
27+
use Ibexa\Bundle\Core\Entity\EntityManagerFactory;
28+
use Ibexa\Contracts\Core\MVC\EventSubscriber\ConfigScopeChangeSubscriber;
29+
use Ibexa\Core\MVC\Symfony\Event\ScopeChangeEvent;
30+
use Symfony\Contracts\Service\ResetInterface;
31+
32+
/**
33+
* @internal
34+
*/
35+
final class SiteAccessAwareEntityManager implements EntityManagerInterface, ConfigScopeChangeSubscriber, ResetInterface
36+
{
37+
private EntityManagerFactory $entityManagerFactory;
38+
39+
private ?EntityManagerInterface $resolvedEntityManager = null;
40+
41+
public function __construct(EntityManagerFactory $entityManagerFactory)
42+
{
43+
$this->entityManagerFactory = $entityManagerFactory;
44+
}
45+
46+
public function onConfigScopeChange(ScopeChangeEvent $event): void
47+
{
48+
$this->resolvedEntityManager = null;
49+
}
50+
51+
public function reset(): void
52+
{
53+
$this->resolvedEntityManager = null;
54+
}
55+
56+
private function getWrapped(): EntityManagerInterface
57+
{
58+
return $this->resolvedEntityManager ??= $this->entityManagerFactory->getEntityManager();
59+
}
60+
61+
public function getConnection(): Connection
62+
{
63+
return $this->getWrapped()->getConnection();
64+
}
65+
66+
public function getExpressionBuilder(): Expr
67+
{
68+
return $this->getWrapped()->getExpressionBuilder();
69+
}
70+
71+
public function beginTransaction(): void
72+
{
73+
$this->getWrapped()->beginTransaction();
74+
}
75+
76+
public function transactional($func)
77+
{
78+
return $this->getWrapped()->transactional($func);
79+
}
80+
81+
/**
82+
* @return mixed
83+
*/
84+
public function wrapInTransaction(callable $func)
85+
{
86+
return $this->getWrapped()->wrapInTransaction($func);
87+
}
88+
89+
public function commit(): void
90+
{
91+
$this->getWrapped()->commit();
92+
}
93+
94+
public function rollback(): void
95+
{
96+
$this->getWrapped()->rollback();
97+
}
98+
99+
public function createQuery($dql = ''): Query
100+
{
101+
return $this->getWrapped()->createQuery($dql);
102+
}
103+
104+
public function createNamedQuery($name): Query
105+
{
106+
return $this->getWrapped()->createNamedQuery($name);
107+
}
108+
109+
public function createNativeQuery($sql, ResultSetMapping $rsm): NativeQuery
110+
{
111+
return $this->getWrapped()->createNativeQuery($sql, $rsm);
112+
}
113+
114+
public function createNamedNativeQuery($name): NativeQuery
115+
{
116+
return $this->getWrapped()->createNamedNativeQuery($name);
117+
}
118+
119+
public function createQueryBuilder(): QueryBuilder
120+
{
121+
return $this->getWrapped()->createQueryBuilder();
122+
}
123+
124+
/**
125+
* @template T of object
126+
*
127+
* @param class-string<T> $entityName
128+
*
129+
* @return T|null
130+
*/
131+
public function getReference($entityName, $id): ?object
132+
{
133+
return $this->getWrapped()->getReference($entityName, $id);
134+
}
135+
136+
/**
137+
* @template T of object
138+
*
139+
* @param class-string<T> $entityName
140+
*
141+
* @return T|null
142+
*/
143+
public function getPartialReference($entityName, $identifier): ?object
144+
{
145+
return $this->getWrapped()->getPartialReference($entityName, $identifier);
146+
}
147+
148+
public function close(): void
149+
{
150+
$this->getWrapped()->close();
151+
}
152+
153+
/**
154+
* @template T of object
155+
*
156+
* @param T $entity
157+
* @param bool $deep
158+
*
159+
* @return T
160+
*/
161+
public function copy($entity, $deep = false): object
162+
{
163+
/** @var T */
164+
return $this->getWrapped()->copy($entity, $deep);
165+
}
166+
167+
public function lock($entity, $lockMode, $lockVersion = null): void
168+
{
169+
$this->getWrapped()->lock($entity, $lockMode, $lockVersion);
170+
}
171+
172+
public function getEventManager(): \Doctrine\Common\EventManager
173+
{
174+
return $this->getWrapped()->getEventManager();
175+
}
176+
177+
public function getConfiguration(): Configuration
178+
{
179+
return $this->getWrapped()->getConfiguration();
180+
}
181+
182+
public function isOpen(): bool
183+
{
184+
return $this->getWrapped()->isOpen();
185+
}
186+
187+
public function getUnitOfWork(): UnitOfWork
188+
{
189+
return $this->getWrapped()->getUnitOfWork();
190+
}
191+
192+
public function getHydrator($hydrationMode): AbstractHydrator
193+
{
194+
return $this->getWrapped()->getHydrator($hydrationMode);
195+
}
196+
197+
public function newHydrator($hydrationMode): AbstractHydrator
198+
{
199+
return $this->getWrapped()->newHydrator($hydrationMode);
200+
}
201+
202+
public function getProxyFactory(): ProxyFactory
203+
{
204+
return $this->getWrapped()->getProxyFactory();
205+
}
206+
207+
public function getFilters(): FilterCollection
208+
{
209+
return $this->getWrapped()->getFilters();
210+
}
211+
212+
public function isFiltersStateClean(): bool
213+
{
214+
return $this->getWrapped()->isFiltersStateClean();
215+
}
216+
217+
public function hasFilters(): bool
218+
{
219+
return $this->getWrapped()->hasFilters();
220+
}
221+
222+
public function getCache(): ?Cache
223+
{
224+
return $this->getWrapped()->getCache();
225+
}
226+
227+
public function find($className, $id): ?object
228+
{
229+
return $this->getWrapped()->find($className, $id);
230+
}
231+
232+
public function persist(object $object): void
233+
{
234+
$this->getWrapped()->persist($object);
235+
}
236+
237+
public function remove(object $object): void
238+
{
239+
$this->getWrapped()->remove($object);
240+
}
241+
242+
public function clear(): void
243+
{
244+
$this->getWrapped()->clear();
245+
}
246+
247+
public function detach(object $object): void
248+
{
249+
$this->getWrapped()->detach($object);
250+
}
251+
252+
public function refresh(object $object, ?int $lockMode = null): void
253+
{
254+
$this->getWrapped()->refresh($object, $lockMode);
255+
}
256+
257+
public function flush(): void
258+
{
259+
$this->getWrapped()->flush();
260+
}
261+
262+
/**
263+
* @template T of object
264+
*
265+
* @param class-string<T> $className
266+
*
267+
* @return EntityRepository<T>
268+
*/
269+
public function getRepository($className): EntityRepository
270+
{
271+
return $this->getWrapped()->getRepository($className);
272+
}
273+
274+
/**
275+
* @template T of object
276+
*
277+
* @param class-string<T> $className
278+
*
279+
* @return ClassMetadata<T>
280+
*/
281+
public function getClassMetadata($className): ClassMetadata
282+
{
283+
return $this->getWrapped()->getClassMetadata($className);
284+
}
285+
286+
public function getMetadataFactory(): ClassMetadataFactory
287+
{
288+
return $this->getWrapped()->getMetadataFactory();
289+
}
290+
291+
public function initializeObject(object $obj): void
292+
{
293+
$this->getWrapped()->initializeObject($obj);
294+
}
295+
296+
/**
297+
* @param mixed $value
298+
*/
299+
public function isUninitializedObject($value): bool
300+
{
301+
return $this->getWrapped()->isUninitializedObject($value);
302+
}
303+
304+
public function contains(object $object): bool
305+
{
306+
return $this->getWrapped()->contains($object);
307+
}
308+
}

src/lib/Repository/URLAliasService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
namespace Ibexa\Core\Repository;
1010

1111
use Exception;
12-
use Ibexa\Contracts\Core\Persistence\Content\URLAlias as SPIURLAlias;
12+
use Ibexa\Contracts\Core\Persistence\Content\UrlAlias as SPIURLAlias;
1313
use Ibexa\Contracts\Core\Persistence\Content\UrlAlias\Handler;
1414
use Ibexa\Contracts\Core\Repository\Exceptions\ForbiddenException;
1515
use Ibexa\Contracts\Core\Repository\LanguageResolver;

0 commit comments

Comments
 (0)