From 010c7652a68de8439d32dc37b2a5dc4889edb0ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 23 Sep 2016 12:30:58 +0200 Subject: [PATCH] Fixing minor issue with widget api and removing homepage menu --- .../Widget/AbstractWidgetsCompilerPass.php | 2 +- .../Widget/AddWidgetConfigurationTrait.php | 19 ++++++++---- Resources/views/Menu/homepage.html.twig | 29 ------------------- Resources/views/layout.html.twig | 8 +---- Templating/Widget/WidgetInterface.php | 2 +- Templating/Widget/WidgetRenderingTwig.php | 2 +- 6 files changed, 18 insertions(+), 44 deletions(-) delete mode 100644 Resources/views/Menu/homepage.html.twig diff --git a/DependencyInjection/Widget/AbstractWidgetsCompilerPass.php b/DependencyInjection/Widget/AbstractWidgetsCompilerPass.php index f0a1205e9..d26e09293 100644 --- a/DependencyInjection/Widget/AbstractWidgetsCompilerPass.php +++ b/DependencyInjection/Widget/AbstractWidgetsCompilerPass.php @@ -269,7 +269,7 @@ abstract class AbstractWidgetsCompilerPass implements CompilerPassInterface return $this->cacheAndGetOrdering($place, $ordering + 1); } else { // cache the ordering - $this->cacheOrdering[$place] = $ordering; + $this->cacheOrdering[$place][] = $ordering; return $ordering; } diff --git a/DependencyInjection/Widget/AddWidgetConfigurationTrait.php b/DependencyInjection/Widget/AddWidgetConfigurationTrait.php index 04c0088ba..81e91c53e 100644 --- a/DependencyInjection/Widget/AddWidgetConfigurationTrait.php +++ b/DependencyInjection/Widget/AddWidgetConfigurationTrait.php @@ -167,13 +167,18 @@ trait AddWidgetConfigurationTrait ->info("the ordering of the widget. May be a number with decimal") ->example("10.58") ->end() - ->enumNode(WidgetsCompilerPass::WIDGET_CONFIG_ALIAS) - ->values($this->getWidgetAliasesbyPlace($place, $containerBuilder)) - ->info("the widget alias (see config for your bundle)") + ->scalarNode(WidgetsCompilerPass::WIDGET_CONFIG_ALIAS) + // this node is scalar: when the configuration is build, the + // tagged services are not available. But when the config reference + // is build, the services are avaialble => we add the possible aliases + // in the info. + ->info("the widget alias (see your installed bundles config). " + . "Possible values are (maybe incomplete) : ". + \implode(", ", $this->getWidgetAliasesbyPlace($place, $containerBuilder))) ->isRequired() ->end() ; - + // adding the possible config on each widget under the widget_alias foreach ($this->filterWidgetByPlace($place) as $factory) { $builder = new TreeBuilder(); @@ -207,6 +212,10 @@ trait AddWidgetConfigurationTrait * get the all possible aliases for the given place. This method * search within service tags and widget factories * + * **Note** that services are not available when the config is build: the whole + * aliases will be checked in compiler pass, or when the command + * `config:dump-reference` is runned. + * * @param type $place * @param ContainerBuilder $containerBuilder * @return type @@ -219,7 +228,7 @@ trait AddWidgetConfigurationTrait foreach ($this->filterWidgetByPlace($place) as $factory) { $result[] = $factory->getWidgetAlias(); } - + // append the aliases added without factory foreach ($containerBuilder ->findTaggedServiceIds(WidgetsCompilerPass::WIDGET_SERVICE_TAG_NAME) diff --git a/Resources/views/Menu/homepage.html.twig b/Resources/views/Menu/homepage.html.twig deleted file mode 100644 index 92cfdf590..000000000 --- a/Resources/views/Menu/homepage.html.twig +++ /dev/null @@ -1,29 +0,0 @@ -{# - * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, - / - * - * 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 . -#} - -
-
- {% for route in routes %} - -
- {{ route.label|trans }} -
-
- {% endfor %} -
-
\ No newline at end of file diff --git a/Resources/views/layout.html.twig b/Resources/views/layout.html.twig index e8c8db00e..0104cd661 100644 --- a/Resources/views/layout.html.twig +++ b/Resources/views/layout.html.twig @@ -139,13 +139,7 @@
- {{ chill_delegated_block('homepage', {} ) }} -
- -
- {{ chill_menu('homepage', { - 'layout': 'ChillMainBundle::Menu/homepage.html.twig', - }) }} + {{ chill_widget('homepage', {} ) }}
{% endblock %} diff --git a/Templating/Widget/WidgetInterface.php b/Templating/Widget/WidgetInterface.php index 76af9af56..82a74aabf 100644 --- a/Templating/Widget/WidgetInterface.php +++ b/Templating/Widget/WidgetInterface.php @@ -2,7 +2,7 @@ namespace Chill\MainBundle\Templating\Widget; -use Twig_Environment; +use \Twig_Environment; interface WidgetInterface { diff --git a/Templating/Widget/WidgetRenderingTwig.php b/Templating/Widget/WidgetRenderingTwig.php index e0ce1884b..083921778 100644 --- a/Templating/Widget/WidgetRenderingTwig.php +++ b/Templating/Widget/WidgetRenderingTwig.php @@ -112,7 +112,7 @@ class WidgetRenderingTwig extends \Twig_Extension $widget = $a[0]; $config = $a[1]; - $content = $widget->render($env, $block, $context, $config); + $content .= $widget->render($env, $block, $context, $config); } // for old rendering events (deprecated)