2017 © Pedro Peláez
 

bundle symfony-control

image

tmilos/symfony-control

  • Thursday, February 4, 2016
  • by tmilos
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

symfony-control

License Build Status Coverage Status, (*1)

Symfony bundle implementing the Twig control tag. Easy rendering of blocks with ability to pass specified parameters trough new control twig tag., (*2)

Installation

Require tmilos/symfony-control with composer, (*3)

``` bash require tmilos/symfony-control, (*4)


Add the bundle to your AppKernel ``` php class AppKernel { public function registerBundles() { $bundles = array( // ... new Tmilos\ControlBundle\TmilosControlBundle(), // ... ); } }

Control twig tag

``` twig {% control BLOCK_NAME with EXPRESSION %}, (*5)


It will display specified BLOCK_NAME with specified EXPRESSION put as the value of the ``control`` variable available only in that block scope. ## property twig function ``` twig {{ property(object, 'path.to.property') }}

Returns value of the object's property, (*6)

Wrapper around Symfony\Component\PropertyAccess\PropertyAccessor::getValue(), (*7)

has_property twig function

``` twig {{ has_property(object, 'path.to.property') }}, (*8)


Returns bool Wrapper around ``Symfony\Component\PropertyAccess\PropertyAccessor::isReadable()`` ## Usage Example ``` twig {# table.html.twig #} {% block table %}
{% for col in control.columns %} {% endfor {% for row in control.rows %} {% for col in control.columns %} {% endfor %} {% endfor
{{ col|trans }}
{{ has_property(row, col) ? property(row, col) : block(col) }}
{% endblock %}

``` twig {# index.html.twig #}, (*9)

{% extends 'base.html.twig' %}, (*10)

{% use 'table.html.twig' %}, (*11)

{% block body %} {% control table with { columns: ['name', 'user.email', 'special_column'], rows: entities } %} {% endblock %}, (*12)

{% block special_column %} edit {% endblock %} ```, (*13)

The Versions