mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 02:23:51 +00:00
replacing delegated_block api by widget api
This commit is contained in:
@@ -1,5 +1,22 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014-2016 Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
@@ -7,20 +24,43 @@ use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
use Symfony\Component\DependencyInjection\Loader;
|
||||
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
|
||||
use Chill\MainBundle\DependencyInjection\Widget\Factory\WidgetFactoryInterface;
|
||||
use Chill\MainBundle\DependencyInjection\Configuration;
|
||||
|
||||
/**
|
||||
* This is the class that loads and manages your bundle configuration
|
||||
*
|
||||
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
|
||||
* This class load config for chillMainExtension.
|
||||
*/
|
||||
class ChillMainExtension extends Extension implements PrependExtensionInterface
|
||||
class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
||||
Widget\HasWidgetFactoriesExtensionInterface
|
||||
{
|
||||
/**
|
||||
* widget factory
|
||||
*
|
||||
* @var WidgetFactoryInterface[]
|
||||
*/
|
||||
protected $widgetFactories = array();
|
||||
|
||||
public function addWidgetFactory(WidgetFactoryInterface $factory)
|
||||
{
|
||||
$this->widgetFactories[] = $factory;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return WidgetFactoryInterface[]
|
||||
*/
|
||||
public function getWidgetFactories()
|
||||
{
|
||||
return $this->widgetFactories;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
$configuration = new Configuration();
|
||||
// configuration for main bundle
|
||||
$configuration = $this->getConfiguration($configs, $container);
|
||||
$config = $this->processConfiguration($configuration, $configs);
|
||||
|
||||
$container->setParameter('chill_main.installation_name',
|
||||
@@ -34,14 +74,25 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface
|
||||
|
||||
$container->setParameter('chill_main.pagination.item_per_page',
|
||||
$config['pagination']['item_per_page']);
|
||||
|
||||
// add the key 'widget' without the key 'enable'
|
||||
$container->setParameter('chill_main.widgets',
|
||||
array('homepage' => $config['widgets']['homepage']));
|
||||
|
||||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||
$loader->load('services.yml');
|
||||
$loader->load('services/logger.yml');
|
||||
$loader->load('services/repositories.yml');
|
||||
$loader->load('services/pagination.yml');
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getConfiguration(array $config, ContainerBuilder $container)
|
||||
{
|
||||
return new Configuration($this->widgetFactories, $container);
|
||||
}
|
||||
|
||||
|
||||
public function prepend(ContainerBuilder $container)
|
||||
{
|
||||
$bundles = $container->getParameter('kernel.bundles');
|
||||
@@ -57,7 +108,8 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface
|
||||
|
||||
//add installation_name and date_format to globals
|
||||
$chillMainConfig = $container->getExtensionConfig($this->getAlias());
|
||||
$config = $this->processConfiguration(new Configuration(), $chillMainConfig);
|
||||
$config = $this->processConfiguration($this
|
||||
->getConfiguration($chillMainConfig, $container), $chillMainConfig);
|
||||
$twigConfig = array(
|
||||
'globals' => array(
|
||||
'installation' => array(
|
||||
|
Reference in New Issue
Block a user