2017 © Pedro Peláez
 

symfony-bundle widget-bundle

Provide simple widget management

image

elendev/widget-bundle

Provide simple widget management

  • Monday, March 13, 2017
  • by Elendev
  • Repository
  • 1 Watchers
  • 4 Stars
  • 289 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 12 Versions
  • 1 % Grown

The README.md

ElendevWidgetBundle

The ElendevWidgetBundle allow to add widgets (independent HTML code) into existing templates withouth dependencies., (*1)

Installation

The ElendevWidgetBundle is available through composer. You just have to add elendev/widget-bundle into your composer.json., (*2)

Configuration

elendev_widget:
    enable_annotations:   true # false : disable annotation support
    scan_services:        true # false : don't check annotations on services
    scan_widget_directory:  true # false : don't scan Widget directory
    widget_directory:     'Widget' # name of the widget directory at bundle's root
    hinclude:
        force: none                 # Force use of hinclude
                                    # none       : use widgets to load synchronous widget, widgets_async to load them asynchronously
                                    # enabled    : force widgets method to load asynchronously using hinclude
                                    # disabled   : force widgets_asynch method to load synchronously

Register a new widget

A widget is a service method returning simple HTML code. You only have to tag your service method with :, (*3)

tags:
        - {name: elendev.widget, tag: your_tagname, method: method_name, priority: optional_integer_priority}

Annotations are also available, you can annotate any method of a service or of a class in widget_directory sub-directory., (*4)

namespace Acme\DemoBundle\Widget;
use Elendev\WidgetBundle\Annotation\Widget;

class MyTestWidget {
    /**
    * @Widget(tag="main", priority=99)
    */
    public function myYoupiWidget(){
        return "This is a simple widget";
    }
}

The value of widget is by default the tag value. Widgets in widget_directory sub-directory are instanciated as services and support the ContainerAwareInterface interface (container is automatically injected)., (*5)

Use Twig's extension widget method

To include widgets in a view you only have to call this method :, (*6)

{{ widgets('your_tagname') }}, (*7)

It's possible to use hinclude :, (*8)

{{ widgets_async('your_tagname') }}, (*9)

BE CAREFUL : only scalar parameters can be passed to widgets_async method. To enable hinclude, please refer to symfony's documentation : http://symfony.com/doc/current/book/templating.html#asynchronous-content-with-hinclude-js., (*10)

You can add multiple widgets emplacements in your project, specifieds by their tagname., (*11)

Some widget's emplacements can provide parameters. You can add as much parameters as you need to widgets call, they will be passed to the widget., (*12)

#services.yml
services:
    my_service:
        class: Some/Class/MyWidgets
            tags:

- {name: elendev.widget, method: memberDatas, tag: member_profile}

{# Template twig #}

{{ widgets('member_profile', member) }}

//PHP code
class MyWidgets{
    public function memberDatas(Member $member){
        return 'some templates';
    }
}

The Versions

13/03 2017

dev-master

9999999-dev http://blog.elendev.com

Provide simple widget management

  Sources   Download

Apache2

The Requires

 

The Development Requires

by Jonas Renaudot

widget twing filter

13/03 2017

0.4.1

0.4.1.0 http://blog.elendev.com

Provide simple widget management

  Sources   Download

Apache2

The Requires

 

The Development Requires

by Jonas Renaudot

widget twing filter

14/11 2016

0.4.0

0.4.0.0 http://blog.elendev.com

Provide simple widget management

  Sources   Download

Apache2

The Requires

 

The Development Requires

by Jonas Renaudot

widget twing filter

27/01 2015

0.3.2

0.3.2.0 http://blog.elendev.com

Provide simple widget management

  Sources   Download

Apache2

The Requires

 

The Development Requires

by Jonas Renaudot

widget twing filter

11/08 2014

0.3.1

0.3.1.0 http://blog.elendev.com

Provide simple widget management

  Sources   Download

Apache2

The Requires

 

The Development Requires

by Jonas Renaudot

widget twing filter

08/04 2014

0.3.0

0.3.0.0 http://blog.elendev.com

Provide simple widget management

  Sources   Download

Apache2

The Requires

 

The Development Requires

by Jonas Renaudot

widget twing filter

18/01 2014

0.2.1

0.2.1.0 http://blog.elendev.com

Provide simple widget management

  Sources   Download

Apache2

The Requires

 

The Development Requires

by Jonas Renaudot

widget twing filter

16/01 2014

0.2.0

0.2.0.0 http://blog.elendev.com

Provide simple widget management

  Sources   Download

Apache2

The Requires

 

The Development Requires

by Jonas Renaudot

widget twing filter

30/12 2013

0.1.3

0.1.3.0 http://blog.elendev.com

Provide simple widget management

  Sources   Download

Apache2

The Requires

 

The Development Requires

by Jonas Renaudot

widget twing filter

08/09 2013

0.1.2

0.1.2.0 http://blog.elendev.com

Provide simple widget management

  Sources   Download

Apache2

The Requires

 

The Development Requires

by Jonas Renaudot

widget twing filter

27/02 2013

0.1.1

0.1.1.0 http://blog.elendev.com

Provide simple widget management

  Sources   Download

Apache2

The Requires

 

The Development Requires

by Jonas Renaudot

widget twing filter

19/02 2013

0.1.0

0.1.0.0 http://blog.elendev.com

Provide simple widget management

  Sources   Download

Apache2

The Requires

 

The Development Requires

by Jonas Renaudot

widget twing filter