mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-10-31 09:18:24 +00:00 
			
		
		
		
	adding a widget "add a person" on homepage, replacing the homepage menu
We use the new widget api to add a widget "add a person" on homepage. The homepage menu is deprecated.
This commit is contained in:
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -7,3 +7,4 @@ parameters.yml | ||||
| Resources/node_modules/ | ||||
| Tests/Fixtures/App/app/config/parameters.yml | ||||
|  | ||||
| /nbproject/private/ | ||||
| @@ -89,6 +89,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac | ||||
|     public function prepend(ContainerBuilder $container)  | ||||
|     { | ||||
|         $this->prependRoleHierarchy($container); | ||||
|         $this->prependHomepageWidget($container); | ||||
|                  | ||||
|         $bundles = $container->getParameter('kernel.bundles'); | ||||
|         //add ChillMain to assetic-enabled bundles | ||||
| @@ -125,6 +126,31 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac | ||||
|         )); | ||||
|     } | ||||
|      | ||||
|     /** | ||||
|      *  | ||||
|      * Add a widget "add a person" on the homepage, automatically | ||||
|      *  | ||||
|      * @param \Chill\PersonBundle\DependencyInjection\containerBuilder $container | ||||
|      */ | ||||
|     protected function prependHomepageWidget(containerBuilder $container) | ||||
|     { | ||||
|         $container->prependExtensionConfig('chill_main', array( | ||||
|             'widgets' => array( | ||||
|                 'homepage' => array( | ||||
|                     array( | ||||
|                         'widget_alias' => 'add_person', | ||||
|                         'order' => 2 | ||||
|                     ) | ||||
|                 ) | ||||
|             ) | ||||
|         )); | ||||
|     } | ||||
|      | ||||
|     /** | ||||
|      * Add role hierarchy. | ||||
|      *  | ||||
|      * @param ContainerBuilder $container | ||||
|      */ | ||||
|     protected function prependRoleHierarchy(ContainerBuilder $container) | ||||
|     { | ||||
|         $container->prependExtensionConfig('security', array( | ||||
|   | ||||
| @@ -8,6 +8,6 @@ services: | ||||
|     # this widget is defined by the PersonListWidgetFactory | ||||
|              | ||||
|     chill_person.widget.add_person: | ||||
|         class: Chill\PersonBundle\Widget\AddPersonWidget | ||||
|         class: Chill\PersonBundle\Widget\AddAPersonWidget | ||||
|         tags: | ||||
|             - { name: chill_widget, alias: add_person, place: homepage } | ||||
							
								
								
									
										8
									
								
								Resources/views/Widget/homepage_add_a_person.html.twig
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								Resources/views/Widget/homepage_add_a_person.html.twig
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| <div class="grid-8 centered" style="text-align:center; margin-top: 1.5em;"> | ||||
|     <a href="{{ path('chill_person_new') }}"> | ||||
|         <div class="grid-3 sc-button blue" style="float: inherit;"> | ||||
|             {{ 'Add a person'|trans }} | ||||
|         </div> | ||||
|     </a> | ||||
| </div> | ||||
|              | ||||
							
								
								
									
										28
									
								
								Widget/AddAPersonWidget.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								Widget/AddAPersonWidget.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,28 @@ | ||||
| <?php | ||||
|  | ||||
| /* | ||||
|  * To change this license header, choose License Headers in Project Properties. | ||||
|  * To change this template file, choose Tools | Templates | ||||
|  * and open the template in the editor. | ||||
|  */ | ||||
|  | ||||
| namespace Chill\PersonBundle\Widget; | ||||
|  | ||||
| use Chill\MainBundle\Templating\Widget\WidgetInterface; | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * Add a button "add a person" | ||||
|  * | ||||
|  * @author julien | ||||
|  */ | ||||
| class AddAPersonWidget implements WidgetInterface | ||||
| { | ||||
|     public function render( | ||||
|             \Twig_Environment $env,  | ||||
|             $place,  | ||||
|             array $context,  | ||||
|             array $config) { | ||||
|         return $env->render("ChillPersonBundle:Widget:homepage_add_a_person.html.twig"); | ||||
|    } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user