mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
Merge branch 'sf4' of framagit.org:Chill-project/Chill-Main into sf4
This commit is contained in:
commit
9b4a71ef8b
@ -6,7 +6,7 @@ use Symfony\Component\HttpKernel\Bundle\Bundle;
|
|||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Chill\MainBundle\DependencyInjection\SearchableServicesCompilerPass;
|
use Chill\MainBundle\DependencyInjection\SearchableServicesCompilerPass;
|
||||||
use Chill\MainBundle\DependencyInjection\ConfigConsistencyCompilerPass;
|
use Chill\MainBundle\DependencyInjection\ConfigConsistencyCompilerPass;
|
||||||
use Chill\MainBundle\DependencyInjection\TimelineCompilerClass;
|
use Chill\MainBundle\DependencyInjection\CompilerPass\TimelineCompilerClass;
|
||||||
use Chill\MainBundle\DependencyInjection\RoleProvidersCompilerPass;
|
use Chill\MainBundle\DependencyInjection\RoleProvidersCompilerPass;
|
||||||
use Chill\MainBundle\DependencyInjection\CompilerPass\ExportsCompilerPass;
|
use Chill\MainBundle\DependencyInjection\CompilerPass\ExportsCompilerPass;
|
||||||
use Chill\MainBundle\DependencyInjection\CompilerPass\WidgetsCompilerPass;
|
use Chill\MainBundle\DependencyInjection\CompilerPass\WidgetsCompilerPass;
|
||||||
|
@ -120,6 +120,7 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
|||||||
$loader->load('services/phonenumber.yml');
|
$loader->load('services/phonenumber.yml');
|
||||||
$loader->load('services/cache.yml');
|
$loader->load('services/cache.yml');
|
||||||
$loader->load('services/templating.yml');
|
$loader->load('services/templating.yml');
|
||||||
|
$loader->load('services/timeline.yml');
|
||||||
|
|
||||||
$this->configureCruds($container, $config['cruds'], $loader);
|
$this->configureCruds($container, $config['cruds'], $loader);
|
||||||
}
|
}
|
||||||
|
@ -17,28 +17,28 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Chill\MainBundle\DependencyInjection;
|
namespace Chill\MainBundle\DependencyInjection\CompilerPass;
|
||||||
|
|
||||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add services taggued with `name: chill.timeline` to
|
* Add services taggued with `name: chill.timeline` to
|
||||||
* timeline_builder service definition
|
* timeline_builder service definition
|
||||||
*
|
*
|
||||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
|
||||||
*/
|
*/
|
||||||
class TimelineCompilerClass implements CompilerPassInterface
|
class TimelineCompilerClass implements CompilerPassInterface
|
||||||
{
|
{
|
||||||
public function process(ContainerBuilder $container)
|
public function process(ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
if (!$container->hasDefinition('chill.main.timeline_builder')) {
|
if (!$container->hasDefinition('chill_main.timeline_builder')) {
|
||||||
throw new \LogicException('service chill.main.timeline_builder '
|
throw new \LogicException('service chill_main.timeline_builder '
|
||||||
. 'is not defined.');
|
. 'is not defined.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$definition = $container->getDefinition(
|
$definition = $container->getDefinition(
|
||||||
'chill.main.timeline_builder'
|
'chill_main.timeline_builder'
|
||||||
);
|
);
|
||||||
|
|
||||||
$taggedServices = $container->findTaggedServiceIds(
|
$taggedServices = $container->findTaggedServiceIds(
|
||||||
@ -56,7 +56,7 @@ class TimelineCompilerClass implements CompilerPassInterface
|
|||||||
|
|
||||||
$definition->addMethodCall(
|
$definition->addMethodCall(
|
||||||
'addProvider',
|
'addProvider',
|
||||||
array($attributes["context"], $id)
|
array($attributes["context"], $id, new Reference($id))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -40,14 +40,6 @@ services:
|
|||||||
chill.main.search_provider:
|
chill.main.search_provider:
|
||||||
class: Chill\MainBundle\Search\SearchProvider
|
class: Chill\MainBundle\Search\SearchProvider
|
||||||
public: true
|
public: true
|
||||||
|
|
||||||
chill.main.timeline_builder:
|
|
||||||
class: Chill\MainBundle\Timeline\TimelineBuilder
|
|
||||||
arguments:
|
|
||||||
- "@doctrine.orm.entity_manager"
|
|
||||||
public: true
|
|
||||||
calls:
|
|
||||||
- [ setContainer, ["@service_container"]]
|
|
||||||
|
|
||||||
chill.main.validator.role_scope_scope_presence:
|
chill.main.validator.role_scope_scope_presence:
|
||||||
class: Chill\MainBundle\Validation\Validator\RoleScopeScopePresence
|
class: Chill\MainBundle\Validation\Validator\RoleScopeScopePresence
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
services:
|
services:
|
||||||
chill_main.paginator_factory:
|
chill_main.paginator_factory:
|
||||||
class: Chill\MainBundle\Pagination\PaginatorFactory
|
class: Chill\MainBundle\Pagination\PaginatorFactory
|
||||||
public: true # TODO sf4 check if service is public or if container is must be loaded via __constuct
|
|
||||||
arguments:
|
arguments:
|
||||||
- "@request_stack"
|
- "@request_stack"
|
||||||
- "@router"
|
- "@router"
|
||||||
|
7
Resources/config/services/timeline.yml
Normal file
7
Resources/config/services/timeline.yml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
services:
|
||||||
|
chill_main.timeline_builder:
|
||||||
|
class: Chill\MainBundle\Timeline\TimelineBuilder
|
||||||
|
arguments:
|
||||||
|
- "@doctrine.orm.entity_manager"
|
||||||
|
calls:
|
||||||
|
- [ setContainer, ["@service_container"]]
|
@ -40,17 +40,29 @@ class TimelineBuilder implements ContainerAwareInterface
|
|||||||
*/
|
*/
|
||||||
private $em;
|
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)
|
public function __construct(EntityManagerInterface $em)
|
||||||
{
|
{
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @var string references to providers services
|
|
||||||
*/
|
|
||||||
private $providers = array();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return an HTML string with timeline
|
* return an HTML string with timeline
|
||||||
*
|
*
|
||||||
@ -108,9 +120,10 @@ class TimelineBuilder implements ContainerAwareInterface
|
|||||||
* @param string $context the context of the service
|
* @param string $context the context of the service
|
||||||
* @param string $id the
|
* @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)
|
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) {
|
foreach($this->providersByContext[$context] as $providerId) {
|
||||||
$providers[] = $this->container->get($providerId);
|
$providers[] = $this->providers[$providerId];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $providers;
|
return $providers;
|
||||||
@ -144,12 +163,6 @@ class TimelineBuilder implements ContainerAwareInterface
|
|||||||
*/
|
*/
|
||||||
private function buildUnionQuery($context, array $args)
|
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
|
//append SELECT queries with UNION keyword between them
|
||||||
$union = '';
|
$union = '';
|
||||||
foreach($this->getProvidersByContext($context) as $provider) {
|
foreach($this->getProvidersByContext($context) as $provider) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user