Prechádzať zdrojové kódy

Merged in olt_workflow (pull request #3)

Nuevo bundle para crear workflow.

Approved-by: Guillermo Espinoza <guillermo@interlink.com.ar>
Maximiliano Schvindt 8 rokov pred
rodič
commit
ee4849e6d5

+ 1 - 0
app/AppKernel.php

@@ -28,6 +28,7 @@ class AppKernel extends Kernel
             new Nelmio\CorsBundle\NelmioCorsBundle(),
             new Base\AdminBundle\BaseAdminBundle(),
             new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
+            new WorkflowBundle\WorkflowBundle(),
             new HWI\Bundle\OAuthBundle\HWIOAuthBundle(),
             new Base\OAuthClientBundle\BaseOAuthClientBundle()
         ];

+ 1 - 0
app/config/config.yml

@@ -7,6 +7,7 @@ imports:
     - { resource: "@FTTHBundle/Resources/config/services.yml" }
     - { resource: "@WebserviceBundle/Resources/config/services.yml" }
     - { resource: workflow.yml }
+    - { resource: "@WorkflowBundle/Resources/config/services.yml" }
     - { resource: "hwioauthbundle/parameters.yml" }
     - { resource: "@BaseOAuthClientBundle/Resources/config/services.yml" }
     - { resource: "@BaseOAuthClientBundle/Resources/config/hwioauthbundle/services.yml" }

+ 5 - 1
app/config/routing.yml

@@ -39,4 +39,8 @@ base_oauth_client:
     resource: "@BaseOAuthClientBundle/Resources/config/routing.yml"
     
 base_hwioauthbundle_oauth_client:
-    resource: "@BaseOAuthClientBundle/Resources/config/hwioauthbundle/routing.yml"
+    resource: "@BaseOAuthClientBundle/Resources/config/hwioauthbundle/routing.yml"
+
+workflow:
+    resource: "@WorkflowBundle/Resources/config/routing/admin.xml"
+    prefix:   /

+ 72 - 0
src/WorkflowBundle/Admin/WorkflowAdmin.php

@@ -0,0 +1,72 @@
+<?php
+
+namespace WorkflowBundle\Admin;
+
+use Base\AdminBundle\Admin\BaseAdmin;
+use Sonata\AdminBundle\Datagrid\DatagridMapper;
+use Sonata\AdminBundle\Datagrid\ListMapper;
+use Sonata\AdminBundle\Form\FormMapper;
+use Sonata\AdminBundle\Show\ShowMapper;
+
+class WorkflowAdmin extends BaseAdmin
+{
+
+    /**
+     * @param DatagridMapper $datagridMapper
+     */
+    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
+    {
+        $datagridMapper
+            ->add('name')
+            ->add('description')
+            ->add('template')
+        ;
+    }
+
+    /**
+     * @param ListMapper $listMapper
+     */
+    protected function configureListFields(ListMapper $listMapper)
+    {
+        $listMapper
+            ->add('name')
+            ->add('description')
+            ->add('template')
+            ->add('_action', null, array(
+                'actions' => array(
+                    'show' => array(),
+                    'edit' => array(),
+                    'delete' => array()
+                )
+            ))
+        ;
+    }
+
+    /**
+     * @param FormMapper $formMapper
+     */
+    protected function configureFormFields(FormMapper $formMapper)
+    {
+        $formMapper
+            ->add('name')
+            ->add('description')
+            ->add('template')
+        ;
+    }
+
+    /**
+     * @param ShowMapper $showMapper
+     */
+    protected function configureShowFields(ShowMapper $showMapper)
+    {
+        $showMapper
+            ->add('id')
+            ->add('name')
+            ->add('description')
+            ->add('created')
+            ->add('updated')
+            ->add('template')
+        ;
+    }
+
+}

+ 17 - 0
src/WorkflowBundle/Controller/DefaultController.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace WorkflowBundle\Controller;
+
+use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
+
+class DefaultController extends Controller
+{
+    /**
+     * @Route("/")
+     */
+    public function indexAction()
+    {
+        return $this->render('WorkflowBundle:Default:index.html.twig');
+    }
+}

+ 212 - 0
src/WorkflowBundle/Entity/Workflow.php

@@ -0,0 +1,212 @@
+<?php
+
+namespace WorkflowBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+use Gedmo\Mapping\Annotation as Gedmo;
+use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
+use Symfony\Component\Validator\Constraints as Assert;
+use Doctrine\Common\Persistence\Event\LifecycleEventArgs;
+
+/**
+ * Workflow
+ *
+ * @ORM\Entity
+ * @ORM\HasLifecycleCallbacks
+ * @UniqueEntity(fields={"name", "tenancyId"}, message="errors.duplicate_key")
+ * @ORM\Table(uniqueConstraints={@ORM\UniqueConstraint(name="unique_idx", columns={"name", "tenancy_id"})})
+ */
+class Workflow
+{
+    /**
+     * @var int
+     *
+     * @ORM\Column(name="id", type="integer", nullable=false)
+     * @ORM\Id
+     * @ORM\GeneratedValue(strategy="AUTO")
+     */
+    private $id;
+    
+    /**
+     * @var string
+     *
+     * @ORM\Column(type="string", length=100, nullable=false)
+     */
+    protected $name;
+    
+    /**
+     * @var string
+     *
+     * @ORM\Column(type="string", length=350, nullable=true)
+     */
+    protected $description;
+    
+    /**
+     * @var text
+     *
+     * @ORM\Column(type="text", nullable=false)
+     */
+    protected $template;
+    
+    /**
+     * @Gedmo\Timestampable(on="create")
+     * @ORM\Column(type="datetime")
+     */
+    protected $created;
+
+    /**
+     * @Gedmo\Timestampable(on="update")
+     * @ORM\Column(type="datetime")
+     */
+    protected $updated;
+
+    /**
+     * @var int
+     *
+     * @ORM\Column(type="integer", nullable=false, options={"default":1})
+     */
+    protected $tenancyId = 1;
+    
+    /**
+     * Get id
+     *
+     * @return int
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * Set name
+     *
+     * @param string $name
+     *
+     * @return Workflow
+     */
+    public function setName($name)
+    {
+        $this->name = $name;
+
+        return $this;
+    }
+
+    /**
+     * Get name
+     *
+     * @return string
+     */
+    public function getName()
+    {
+        return $this->name;
+    }
+
+    /**
+     * Set description
+     *
+     * @param string $description
+     *
+     * @return Workflow
+     */
+    public function setDescription($description)
+    {
+        $this->description = $description;
+
+        return $this;
+    }
+
+    /**
+     * Get description
+     *
+     * @return string
+     */
+    public function getDescription()
+    {
+        return $this->description;
+    }
+
+    /**
+     * Set template
+     *
+     * @param text $template
+     *
+     * @return Workflow
+     */
+    public function setTemplate($template)
+    {
+        $this->template = $template;
+
+        return $this;
+    }
+
+    /**
+     * Get template
+     *
+     * @return text
+     */
+    public function getTemplate()
+    {
+        return $this->template;
+    }
+
+    /**
+     * Get created
+     *
+     * @return \DateTime
+     */
+    public function getCreated()
+    {
+        return $this->created;
+    }
+
+    /**
+     * Get updated
+     *
+     * @return \DateTime
+     */
+    public function getUpdated()
+    {
+        return $this->updated;
+    }
+
+    /**
+     * Set tenancyId
+     *
+     * @param int $tenancyId
+     *
+     * @return Workflow
+     */
+    public function setTenancyId($tenancyId)
+    {
+        $this->tenancyId = $tenancyId;
+
+        return $this;
+    }
+
+    /**
+     * Get tenancyId
+     *
+     * @return int
+     */
+    public function getTenancyId()
+    {
+        return $this->tenancyId;
+    }
+
+    /**  
+     *  @ORM\PostPersist 
+     */
+    public function postPersist(LifecycleEventArgs $event) 
+    {
+        //Code
+    }
+
+    /**  
+     *  @ORM\PreUpdate 
+     */
+    public function postUpdate(LifecycleEventArgs $event) 
+    {
+        //Code
+    }
+    
+}

+ 7 - 0
src/WorkflowBundle/Resources/config/routing/admin.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<routes xmlns="http://symfony.com/schema/routing"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
+    
+</routes>

+ 8 - 0
src/WorkflowBundle/Resources/config/services.yml

@@ -0,0 +1,8 @@
+services:
+    workflow.admin.onu:
+        class: WorkflowBundle\Admin\WorkflowAdmin
+        arguments: [~, WorkflowBundle\Entity\Workflow, SonataAdminBundle:CRUD]
+        tags:
+            - { name: sonata.admin, manager_type: orm, group: Workflow, label: Workflow, label_catalogue: WorkflowBundle, label_translator_strategy: sonata.admin.label.strategy.underscore }
+        calls:    
+            - [setTranslationDomain, [WorkflowBundle]]

+ 37 - 0
src/WorkflowBundle/Resources/translations/WorkflowBundle.es.yml

@@ -0,0 +1,37 @@
+filter:
+    label_id: Id
+    label_name: Nombre
+    label_description: Descripción
+    label_template: Template
+    label__action: Acciones
+    label_created: Creado
+    label_updated: Actualizado
+breadcrumb:
+    link_workflow_list: Listado Workflows
+    link_workflow_create: Crear Workflow
+    link_workflow_delete: Eliminar Workflow
+form:
+    label_id: Id
+    label_name: Nombre
+    label_description: Descripción
+    label_template: Template
+    label__action: Acciones
+    label_created: Creado
+    label_updated: Actualizado
+list:
+    label_id: Id
+    label_name: Nombre
+    label_description: Descripción
+    label_template: Template
+    label__action: Acciones
+    label_created: Creado
+    label_updated: Actualizado
+show:
+    label_id: Id
+    label_name: Nombre
+    label_description: Descripción
+    label_template: Template
+    label__action: Acciones
+    label_created: Creado
+    label_updated: Actualizado
+   

+ 1 - 0
src/WorkflowBundle/Resources/views/Default/index.html.twig

@@ -0,0 +1 @@
+Hello World!

+ 9 - 0
src/WorkflowBundle/WorkflowBundle.php

@@ -0,0 +1,9 @@
+<?php
+
+namespace WorkflowBundle;
+
+use Symfony\Component\HttpKernel\Bundle\Bundle;
+
+class WorkflowBundle extends Bundle
+{
+}