mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-03-03 12:39:42 +00:00
Add support for associating entities with stored objects in the ChillDocStore bundle
- Introduced `AssociatedEntityToStoredObjectInterface` and `AssociatedEntityToStoredObjectRepository` for linking stored objects to specific entities. - Registered `AssociatedEntityToStoredObjectInterface` with autoconfiguration and added custom repository logic. - Updated `ChillDocStoreBundle` to tag repositories implementing the new interface for streamlined usage.
This commit is contained in:
@@ -16,6 +16,7 @@ use Chill\DocStoreBundle\GenericDoc\GenericDocForAccompanyingPeriodProviderInter
|
||||
use Chill\DocStoreBundle\GenericDoc\GenericDocForPersonProviderInterface;
|
||||
use Chill\DocStoreBundle\GenericDoc\GenericDocNormalizerInterface;
|
||||
use Chill\DocStoreBundle\GenericDoc\Twig\GenericDocRendererInterface;
|
||||
use Chill\DocStoreBundle\Repository\AssociatedEntityToStoredObjectInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
||||
@@ -31,6 +32,8 @@ class ChillDocStoreBundle extends Bundle
|
||||
->addTag('chill_doc_store.generic_doc_renderer');
|
||||
$container->registerForAutoconfiguration(GenericDocNormalizerInterface::class)
|
||||
->addTag('chill_doc_store.generic_doc_metadata_normalizer');
|
||||
$container->registerForAutoconfiguration(AssociatedEntityToStoredObjectInterface::class)
|
||||
->addTag('chill_doc_store.associated_entity_to_stored_object_repository');
|
||||
|
||||
$container->addCompilerPass(new StorageConfigurationCompilerPass());
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@ namespace Chill\DocStoreBundle\Repository;
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
|
||||
/**
|
||||
* Interface to add to repository to find an entity related to a stored object.
|
||||
*
|
||||
* @template T of object
|
||||
*/
|
||||
interface AssociatedEntityToStoredObjectInterface
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\DocStoreBundle\Repository;
|
||||
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
|
||||
/**
|
||||
* Search across repositories to find an entity related to a stored object.
|
||||
*/
|
||||
class AssociatedEntityToStoredObjectRepository
|
||||
{
|
||||
/**
|
||||
* @param list<AssociatedEntityToStoredObjectInterface> $repositories
|
||||
*/
|
||||
public function __construct(private array $repositories) {}
|
||||
|
||||
public function findAssociatedEntityToStoredObject(StoredObject $storedObject): ?object
|
||||
{
|
||||
foreach ($this->repositories as $repository) {
|
||||
$result = $repository->findAssociatedEntityToStoredObject($storedObject);
|
||||
if (null !== $result) {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,16 @@ services:
|
||||
|
||||
Chill\DocStoreBundle\Repository\:
|
||||
resource: "../Repository/"
|
||||
exclude:
|
||||
- '../Repository/AssociatedEntityToStoredObjectRepository.php'
|
||||
- '../Repository/AssociatedEntityToStoredObjectInterface.php'
|
||||
tags:
|
||||
- { name: doctrine.repository_service }
|
||||
|
||||
Chill\DocStoreBundle\Repository\AssociatedEntityToStoredObjectRepository:
|
||||
arguments:
|
||||
$repositories: !tagged_iterator chill_doc_store.associated_entity_to_stored_object_repository
|
||||
|
||||
Chill\DocStoreBundle\Security\Authorization\:
|
||||
resource: "./../Security/Authorization"
|
||||
|
||||
@@ -27,6 +34,9 @@ services:
|
||||
Chill\DocStoreBundle\Service\:
|
||||
resource: '../Service/'
|
||||
|
||||
Chill\DocStoreBundle\Audit\:
|
||||
resource: '../Audit/'
|
||||
|
||||
Chill\DocStoreBundle\GenericDoc\Manager:
|
||||
arguments:
|
||||
$providersForAccompanyingPeriod: !tagged_iterator chill_doc_store.generic_doc_accompanying_period_provider
|
||||
|
||||
Reference in New Issue
Block a user