mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-04 05:44:58 +00:00
make timeline & paginator service private
This commit is contained in:
@@ -40,17 +40,29 @@ class TimelineBuilder implements ContainerAwareInterface
|
||||
*/
|
||||
private $em;
|
||||
|
||||
/**
|
||||
* Record provider
|
||||
*
|
||||
* This array has the structure `[ 'service id' => $service ]`
|
||||
*
|
||||
* @var TimelineProviderInterface[]
|
||||
*/
|
||||
private $providers = [];
|
||||
|
||||
/**
|
||||
* Record provider and their context
|
||||
*
|
||||
* This array has the structure `[ 'context' => [ 'service id' ] ]`
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $providersByContext = [];
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
{
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string references to providers services
|
||||
*/
|
||||
private $providers = array();
|
||||
|
||||
/**
|
||||
* return an HTML string with timeline
|
||||
*
|
||||
@@ -108,9 +120,10 @@ class TimelineBuilder implements ContainerAwareInterface
|
||||
* @param string $context the context of the service
|
||||
* @param string $id the
|
||||
*/
|
||||
public function addProvider($context, $id)
|
||||
public function addProvider($context, $id, TimelineProviderInterface $provider)
|
||||
{
|
||||
$this->providers[$context][] = $id;
|
||||
$this->providersByContext[$context][] = $id;
|
||||
$this->providers[$id] = $provider;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,10 +134,16 @@ class TimelineBuilder implements ContainerAwareInterface
|
||||
*/
|
||||
public function getProvidersByContext($context)
|
||||
{
|
||||
$providers = array();
|
||||
//throw an exception if no provider have been defined for this context
|
||||
if (!array_key_exists($context, $this->providersByContext)) {
|
||||
throw new \LogicException(sprintf('No builders have been defined for "%s"'
|
||||
. ' context', $context));
|
||||
}
|
||||
|
||||
$providers = [];
|
||||
|
||||
foreach($this->providers[$context] as $providerId) {
|
||||
$providers[] = $this->container->get($providerId);
|
||||
foreach($this->providersByContext[$context] as $providerId) {
|
||||
$providers[] = $this->providers[$providerId];
|
||||
}
|
||||
|
||||
return $providers;
|
||||
@@ -144,12 +163,6 @@ class TimelineBuilder implements ContainerAwareInterface
|
||||
*/
|
||||
private function buildUnionQuery($context, array $args)
|
||||
{
|
||||
//throw an exception if no provider have been defined for this context
|
||||
if (!array_key_exists($context, $this->providers)) {
|
||||
throw new \LogicException(sprintf('No builders have been defined for "%s"'
|
||||
. ' context', $context));
|
||||
}
|
||||
|
||||
//append SELECT queries with UNION keyword between them
|
||||
$union = '';
|
||||
foreach($this->getProvidersByContext($context) as $provider) {
|
||||
|
Reference in New Issue
Block a user