2017 © Pedro Peláez
 

symfony-bundle action-bundle

Provide configuration based generic actions.

image

colin/action-bundle

Provide configuration based generic actions.

  • Sunday, February 22, 2015
  • by maximecolin
  • Repository
  • 1 Watchers
  • 2 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

ColinActionBundle

This bundle provides configuration based engine to declare generic actions with routes. The bundle come with 5 generic CRUD actions (Create, Read, Update, Delete, List) which can be configured for all your entity., (*1)

You can also add your own generic actions or extends existant ones., (*2)

Configuration

colin_action:
    configurations:
        list:   Colin\Bundle\ActionBundle\Configuration\ListActionConfiguration
        create: Colin\Bundle\ActionBundle\Configuration\CreateActionConfiguration
        update: Colin\Bundle\ActionBundle\Configuration\UpdateActionConfiguration
        delete: Colin\Bundle\ActionBundle\Configuration\DeleteActionConfiguration
        read:   Colin\Bundle\ActionBundle\Configuration\ReadActionConfiguration
    actions:
        admin:
            dummy:
                create:
                    type: create
                    configs:
                        #path:         /dummy/create
                        entity_class: Acme\DemoBundle\Entity\Dummy
                        form_type:    Acme\DemoBundle\Form\Type\DummyType
                        template:     AcmeDemoBundle:Dummy:create.html.twig
                        host:         photo.%domain%
                update:
                    type: update
                    configs:
                        #path: ~
                        entity_class: Acme\DemoBundle\Entity\Dummy
                        form_type:    Acme\DemoBundle\Form\Type\DummyType
                        template:     AcmeDemoBundle:Dummy:create.html.twig
                        host:         photo.%domain%
                read:
                    type: read
                    configs:
                        #path: ~
                        entity_class: Acme\DemoBundle\Entity\Dummy
                        template:     AcmeDemoBundle:Dummy:read.html.twig
                        host:         photo.%domain%
                list:
                    type: list
                    configs:
                        #path: ~
                        entity_class: Acme\DemoBundle\Entity\Dummy
                        template:     AcmeDemoBundle:Dummy:list.html.twig
                        host:         photo.%domain%

This config will generate 5 actions and routes to administrate the Dummy entity., (*3)

Create your own generic action

Create your action as service

<?php

namespace Demo\AcmeBundle\Action;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class MyAction
{
    public function execute(Request $request)
    {
        return new Response();
    }
}
services:
    acme_demo.action.my:
        class: Demo\AcmeBundle\Action\MyAction
        abstract: true
        arguments:

Create your action configuration

<?php

namespace Acme\DemoBundle\Configuration;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\DependencyInjection\DefinitionDecorator;

class MyActionConfiguration extends Configuration
{
    public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder();
        $rootNode = $treeBuilder->root('configs');

        $rootNode
            ->children()
                // Put your configuration here
            ->end();

        return $treeBuilder;
    }

    public function getDefinition()
    {
        $definition = new DefinitionDecorator('colin_action.action.create');
        $definition->replaceArgument(4, $this->configs);

        return $definition;
    }
}

In config.yml, (*4)

colin_action:
    configurations:
        # ...
        my_action: Acme\DemoBundle\Configuration\MyActionConfiguration

Utilisez votre nouvelle action

In config.yml, (*5)

colin_action:
    actions:
        # ...
        admin:
            dummy:
                foobar:
                    type: my_action
                    configs:
                        # ...

The Versions

22/02 2015

dev-master

9999999-dev https://github.com/maximecolin/ColinActionBundle

Provide configuration based generic actions.

  Sources   Download

MIT

The Requires

 

bundle crud symfony admin action colin maximecolin