Fixing minor issue with widget api and removing homepage menu

This commit is contained in:
Julien Fastré 2016-09-23 12:30:58 +02:00
parent a3e7c60e01
commit 010c7652a6
6 changed files with 18 additions and 44 deletions

View File

@ -269,7 +269,7 @@ abstract class AbstractWidgetsCompilerPass implements CompilerPassInterface
return $this->cacheAndGetOrdering($place, $ordering + 1); return $this->cacheAndGetOrdering($place, $ordering + 1);
} else { } else {
// cache the ordering // cache the ordering
$this->cacheOrdering[$place] = $ordering; $this->cacheOrdering[$place][] = $ordering;
return $ordering; return $ordering;
} }

View File

@ -167,13 +167,18 @@ trait AddWidgetConfigurationTrait
->info("the ordering of the widget. May be a number with decimal") ->info("the ordering of the widget. May be a number with decimal")
->example("10.58") ->example("10.58")
->end() ->end()
->enumNode(WidgetsCompilerPass::WIDGET_CONFIG_ALIAS) ->scalarNode(WidgetsCompilerPass::WIDGET_CONFIG_ALIAS)
->values($this->getWidgetAliasesbyPlace($place, $containerBuilder)) // this node is scalar: when the configuration is build, the
->info("the widget alias (see config for your bundle)") // 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() ->isRequired()
->end() ->end()
; ;
// adding the possible config on each widget under the widget_alias // adding the possible config on each widget under the widget_alias
foreach ($this->filterWidgetByPlace($place) as $factory) { foreach ($this->filterWidgetByPlace($place) as $factory) {
$builder = new TreeBuilder(); $builder = new TreeBuilder();
@ -207,6 +212,10 @@ trait AddWidgetConfigurationTrait
* get the all possible aliases for the given place. This method * get the all possible aliases for the given place. This method
* search within service tags and widget factories * 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 type $place
* @param ContainerBuilder $containerBuilder * @param ContainerBuilder $containerBuilder
* @return type * @return type
@ -219,7 +228,7 @@ trait AddWidgetConfigurationTrait
foreach ($this->filterWidgetByPlace($place) as $factory) { foreach ($this->filterWidgetByPlace($place) as $factory) {
$result[] = $factory->getWidgetAlias(); $result[] = $factory->getWidgetAlias();
} }
// append the aliases added without factory // append the aliases added without factory
foreach ($containerBuilder foreach ($containerBuilder
->findTaggedServiceIds(WidgetsCompilerPass::WIDGET_SERVICE_TAG_NAME) ->findTaggedServiceIds(WidgetsCompilerPass::WIDGET_SERVICE_TAG_NAME)

View File

@ -1,29 +0,0 @@
{#
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
<info@champs-libres.coop> / <http://www.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/>.
#}
<div class="container">
<div class="grid-8 centered" style="text-align:center">
{% for route in routes %}
<a href="{{ path(route.key, args ) }}">
<div class="grid-3 sc-button blue" style="float: inherit;">
{{ route.label|trans }}
</div>
</a>
{% endfor %}
</div>
</div>

View File

@ -139,13 +139,7 @@
</div> </div>
<div class="homepage_widget"> <div class="homepage_widget">
{{ chill_delegated_block('homepage', {} ) }} {{ chill_widget('homepage', {} ) }}
</div>
<div style="padding-top:2em; padding-bottom:2em;">
{{ chill_menu('homepage', {
'layout': 'ChillMainBundle::Menu/homepage.html.twig',
}) }}
</div> </div>
{% endblock %} {% endblock %}
</div> </div>

View File

@ -2,7 +2,7 @@
namespace Chill\MainBundle\Templating\Widget; namespace Chill\MainBundle\Templating\Widget;
use Twig_Environment; use \Twig_Environment;
interface WidgetInterface interface WidgetInterface
{ {

View File

@ -112,7 +112,7 @@ class WidgetRenderingTwig extends \Twig_Extension
$widget = $a[0]; $widget = $a[0];
$config = $a[1]; $config = $a[1];
$content = $widget->render($env, $block, $context, $config); $content .= $widget->render($env, $block, $context, $config);
} }
// for old rendering events (deprecated) // for old rendering events (deprecated)