2017 © Pedro Peláez
 

symfony-bundle disable-bundle

Symfony2 bundle for disable controllers with annotations.

image

aferrandini/disable-bundle

Symfony2 bundle for disable controllers with annotations.

  • Friday, March 28, 2014
  • by aferrandini
  • Repository
  • 0 Watchers
  • 4 Stars
  • 193 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

DisableBundle

This Bundle has been created to show how to create a custom Annotation in deSymfony 2013 Conference., (*1)

You will find more information about Annotations at Annotations: it’s not a part of my program, but it’s my program., (*2)

This bundle provides an easy way to disable an Action or a Controller. You will be able to disable directly, after a date/time, until a date/time or by a date/time range. You also be able to show a disabled message or redirect the request to another route., (*3)

Build Status SensioLabsInsight, (*4)

Installation

Step 1: Install vendors

Symfony 2.0.x: bin/vendors.php method

If you're using the bin/vendors.php method to manage your vendor libraries, add the following entries to the deps in the root of your project file:, (*5)

[FerrandiniDisableBundle]
    git=http://github.com/aferrandini/DisableBundle.git
    target=/bundles/Ferrandini/Bundle/DisableBundle

Next, update your vendors by running:, (*6)

``` bash $ ./bin/vendors, (*7)


Finally, add the following entry to your autoloader: ``` php <?php // app/autoload.php $loader->registerNamespaces(array( // ... 'Ferrandini' => __DIR__.'/../vendor/bundles', ));

Symfony >=2.1.x: Composer

Composer is a project dependency manager for PHP. You have to list your dependencies in a composer.json file:, (*8)

``` json { "require": { "aferrandini/disable-bundle": "dev-master" } }, (*9)

To actually install DisableBundle in your project, download the composer binary and run it:

``` bash
wget http://getcomposer.org/composer.phar
# or
curl -O http://getcomposer.org/composer.phar

php composer.phar install

Step 2: Enable the bundle

Finally, enable the bundle in the kernel:, (*10)

``` php <?php // app/AppKernel.php, (*11)

public function registerBundles() { $bundles = array( // ..., (*12)

    new Ferrandini\Bundle\DisableBundle\FerrandiniDisableBundle(),
);

}, (*13)


## Usage This Bundle provides an easy way to disable a Controller or an Action as you can see in the following examples. ### Disabling a Controller ``` php <?php namespace Foo\Bundle\FooBundle\Controller; use Ferrandini\Bundle\DisableBundle\Annotations\Disable; /** * @Disable() */ class FooController { }

Disabling an Action

``` php <?php, (*14)

namespace Foo\Bundle\FooBundle\Controller;, (*15)

use Ferrandini\Bundle\DisableBundle\Annotations\Disable;, (*16)

class FooController {, (*17)

/**
 * @Disable()
 */
public function fooAction()
{
    // ...
}

}, (*18)


### Disabling with custom message ``` php <?php namespace Foo\Bundle\FooBundle\Controller; use Ferrandini\Bundle\DisableBundle\Annotations\Disable; /** * @Disable(message="This controller has been disabled with DisableBundle") */ class FooController { }

Disabling by date/time

The date/time has to be defined as a PHP supported date and time format. You can see the supported formats in Supported Date and Time Formats, (*19)

Disabling until a date/time

``` php <?php, (*20)

namespace Foo\Bundle\FooBundle\Controller;, (*21)

use Ferrandini\Bundle\DisableBundle\Annotations\Disable;, (*22)

/** * @Disable(until="2013-11-11 11:11") */ class FooController {, (*23)

}, (*24)


#### Disabling after a date/time ``` php <?php namespace Foo\Bundle\FooBundle\Controller; use Ferrandini\Bundle\DisableBundle\Annotations\Disable; /** * @Disable(after="2013-11-11 11:11") */ class FooController { }

Disabling by date/time range

``` php <?php, (*25)

namespace Foo\Bundle\FooBundle\Controller;, (*26)

use Ferrandini\Bundle\DisableBundle\Annotations\Disable;, (*27)

/** * @Disable(until="2013-06-11", after="2013-11-11") */ class FooController {, (*28)

}, (*29)


### Disabling and redirect to route The route should be a defined route name in the routing configuration. ``` php <?php namespace Foo\Bundle\FooBundle\Controller; use Ferrandini\Bundle\DisableBundle\Annotations\Disable; /** * @Disable(redirect="_welcome") */ class FooController { }

Disabling with a custom response status code

``` php <?php, (*30)

namespace Foo\Bundle\FooBundle\Controller;, (*31)

use Ferrandini\Bundle\DisableBundle\Annotations\Disable;, (*32)

/** * @Disable(statusCode=404) */ class FooController {, (*33)

} ```, (*34)

The Versions

28/03 2014

dev-master

9999999-dev https://github.com/aferrandini/DisableBundle

Symfony2 bundle for disable controllers with annotations.

  Sources   Download

MIT

The Requires

 

annotation disable

23/07 2013

v1.0

1.0.0.0 https://github.com/aferrandini/DisableBundle

Symfony2 bundle for disable controllers with annotations.

  Sources   Download

MIT

The Requires

 

annotation disable