DownloadADR-001: ?????????? ??????????? EntityFactory ? EntityPersister
| ???? | ???????? |
|-----------------|--------------------------------------------------|
| ?????? | Proposed |
| ???? | 2026-05-05 |
| ????? | Ruslan Kabirov |
| ?????????? ????? | Persistence/EntityPersister.php, Entity/EntityFactory.php, Entity/ValueObjectAwareEntityFactory.php, AdaptiveEntityManager.php |
????????
? ??????? ?????????? EntityPersister ?????????? ??????????? ???????? ??? ???????? ?????????? EntityFactory:
class EntityPersister
{
private static EntityFactory $entityFactory;
public static function setEntityFactory(EntityFactory $factory): void
{
self::$entityFactory = $factory;
}
}
??? ????????, ??? ??? ?????????? EntityPersister ? ?????? ?????? PHP-???????? ????????? ???? ? ??? ?? ?????? EntityFactory. ??? ????????????? PHP-FPM (???? ?????? ? ???? ???????) ??? ?? ??????? ???????, ????????? ?????? ?????? ???????? ? ??????? ?????????.
?????? ? ???????????????? long-running runtime-?? (Swoole, RoadRunner, ReactPHP, FrankenPHP) ???? ??????? ??????????? ????????? ???????? ???????????????. ???? ? ????? ???????? ????????? ??? ?????????? AdaptiveEntityManager ? ??????? ?????????????? ValueObject (????????, ?????? ValueObjectConverterRegistry), ?????? setEntityFactory() ??????????? ??????? ??????? ?????????. ????????? ? ???????????? ?????????? ?????????, ??????? ????? ??????????? ??? ?????????? ????? ??????.
README ??????? ???? ???????? ??? ??? known limitation, ?? ?? ?????????? ???? ???????.
???????
???????? ??????????? ???????? EntityFactory ?? ???????? ????? ????????? EntityPersister. ?????? EntityPersister ???????? ??????????? ??????? ??? ???????? ????? EntityPersisterFactory.
??
class EntityPersister
{
private static EntityFactory $entityFactory;
public static function setEntityFactory(EntityFactory $factory): void
{
self::$entityFactory = $factory;
}
public function someMethod(): void
{
$entity = self::$entityFactory->createEntity(...);
}
}
?????
class EntityPersister
{
private EntityFactory $entityFactory;
public function __construct(
// ... other params
EntityFactory $entityFactory,
) {
$this->entityFactory = $entityFactory;
}
public function someMethod(): void
{
$entity = $this->entityFactory->createEntity(...);
}
}
EntityPersisterFactory ??? ???????? ??????? ?????????? ???????? ??? ??????????????? ??????? ?????????. ????? ????? EntityFactory ? ValueObjectAwareEntityFactory ???????? ?? ???????? ???????????, ??????? ???????? ??? ?????????? ?? ???????????? AdaptiveEntityManager.
???????????
?????????????
-
???????? ??????????: ?????? `AdaptiveEntityManager` ???????? ?? ????? `EntityFactory`, ??? ????????? ??? long-running ?????????.
-
?????????????: ? ?????? ????? ????????? `EntityPersister` ? ???-???????? ??? ???????? ???????? ????? ???????.
-
??????? ????????????: ??????????? ?? `EntityFactory` ????? ? ????????????, ? ?? ?????? ? ??????????? ??????.
-
?????????? known limitation: ????????????????? ??????????? ????????? ?????????.
?????????????
-
?????? ??????: ?????? `EntityPersister` ?????? ??????????? ?????? ?? ???????. ??? ???????????? ???? (?????? ?? ??????, ?? ?????), ?? ????????? ??????????? ?????? ??????.
-
?????????????: ???????? `EntityPersister::setEntityFactory()` ? breaking change. ??????????? major ??? minor version bump ? ??????????????? changelog-???????.
-
??? ?????????????: ????? `setEntityFactory()` ??? ???????? EM ????? ??????, ? ??????????? `EntityPersister` ?????????. ??? ???????? `EntityPersisterFactory` ? ???? ?????, ??? ?????????? ?????????.
???? ????????
-
???????? `EntityFactory` ??? ???????? ???????????? `EntityPersister`.
-
???????? `EntityPersisterFactory` ? ?????????? ??????? ??? ???????? ??????????.
-
??????? `static $entityFactory` ? `setEntityFactory()`.
-
???????? ??? ?????, ???????????? `setEntityFactory()`.
-
???????? ?????????????? ???? ? ????? EM ? ????? ????????.
-
????????? ??? minor release ? ???????? BC break ? changelog.
????????????
???????????? 1: Per-process singleton ? reset-??
???????? ????? reset() ??? ??????? ??????????? ??????? ????? ????????? ? long-running runtime. ??? ?????? Doctrine ORM (EntityManager::clear()).
?????: ????????? ??????????????? ?? ???????????? ? ????? ??????? reset(), ??????? ????? ??????. ??????????? ????????? ??-???????? ???????????.
???????????? 2: Registry ???????
??????? EntityFactoryRegistry, ??????? ?????? ??????? ?? ????? (????????, ?? ???? ???????????? EM), ? ?????????? ???? ? EntityPersister.
?????: ????????? ??? ???? ?????????? ??????, ?? ?????? ??????????????? ???????? ?????????? ?????????, ????????? ???.
|