2017 © Pedro Peláez
 

symfony-bundle before-after-bundle

Symfony 2/3 Bundle to allow a before and after method which executes for each action

image

expertcoder/before-after-bundle

Symfony 2/3 Bundle to allow a before and after method which executes for each action

  • Tuesday, April 24, 2018
  • by expertcoder
  • Repository
  • 1 Watchers
  • 2 Stars
  • 98 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 7 % Grown

The README.md

Freelance Banner, (*1)

BeforeAfterBundle

Symfony 2/3 Bundle. If you want some code to execute before or after every action in particular controller, this bundle provides a very simple way to do this., (*2)

Installation

Add to composer, (*3)

composer require expertcoder/before-after-bundle

Add to AppKernal.php, (*4)

  public function registerBundles()
    {
        $bundles = [
            ....
            new ExpertCoder\BeforeAfterBundle\ExpertCoderBeforeAfterBundle(),
        ];

Usage

In any controller, where you would like to have some code run before each action, simply have that controller implement ExpertCoder\BeforeAfterBundle\Other\ExecuteBeforeInterface. Any code inside executeBefore() will run before the code inside the action method which is been invoked., (*5)

Example

use ExpertCoder\BeforeAfterBundle\Other\ExecuteBeforeInterface;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;

class DefaultController extends Controller implements ExecuteBeforeInterface
{
    public function executeBefore(FilterControllerEvent $event)
    {
        /* code here will execute before the code inside homeAction() */
    }

    /**
     * @Template()
     * @Route("/home")
     */
    public function homeAction(Request $request)
    {
        // ....

        return array();
    }

TODO

  • executeAfter functionallity
  • http://symfony.com/doc/current/cookbook/event_dispatcher/before_after_filters.html
  • https://github.com/symfony/symfony/issues/1975

The Versions

24/04 2018

dev-master

9999999-dev https://github.com/expertcoder/before-after-bundle

Symfony 2/3 Bundle to allow a before and after method which executes for each action

  Sources   Download

The Requires

  • php >=5.3.3

 

by Samual Anthony