2017 © Pedro PelĂĄez
 

symfony-bundle binder-bundle

Reusable library

image

mpoiriert/binder-bundle

Reusable library

  • Wednesday, March 26, 2014
  • by mpoiriert
  • Repository
  • 1 Watchers
  • 0 Stars
  • 653 Installations
  • PHP
  • 0 Dependents
  • 1 Suggesters
  • 0 Forks
  • 1 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

binder-bundle

Build Status, (*1)

A Symfony bundle to use the binder library., (*2)

The main purpose is to hide the usage of the session to the user (developer)., (*3)

To use it in your application you must register 2 bundles since there is a dependency on nucleus-bundle., (*4)

<?php

// in AppKernel::registerBundles()
$bundles = array(
    // ...
    new Nucleus\Bundle\CoreBundle\NucleusCoreBundle(),
    new Nucleus\Bundle\BinderBundle\NucleusBinderBundle(),
    // ...
);

The system does use the kernel.terminate event to work. Don't forget to use the Symfony/Component/HttpKernel/TerminableInterface on your kernel., (*5)

In any service you can put a annotation above a property and this property will be automatically save to the session and restore on the next call., (*6)

<?php

class TheService
{
    /**
     * @\Nucleus\Binder\Bounding
     */
    protected $variable = 'default';

    public function getVariable()
    {
        return $this->variable;
    }

    public function setVariable($value)
    {
        $this->variable = $value;
    }

    //...
}

That's all !!, (*7)

The default value of the property will be use if the proper variable in not available in the Binder service., (*8)

By calling the TheService::setVariable() the value will be change and at the end of the request on kernel.terminate., (*9)

If you need to access the value of this variable in "AnotherService" you need to inject "TheService" in "AnotherService" and call the TheService::getVariable(). The service who have the Bounded property is in charge of all the access to it., (*10)

This approach also help for unit test since you don't need to use the session anymore. It also force to have a separation of concern in your service since no other service can change the value in the session by manipulating it directly since it's inner working are hidden., (*11)

The Versions

26/03 2014

dev-master

9999999-dev

Reusable library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Martin Poirier ThĂ©orĂȘt

library cookie session binding nucleus