Kaynağa Gözat

Agregado de VlanProfile y ONUProfile al web service

gabriel 6 yıl önce
ebeveyn
işleme
7a9dfe603c

+ 8 - 0
app/config/routing.yml

@@ -118,3 +118,11 @@ ftth_onu_template:
     resource: "@FTTHBundle/Controller/ONUTemplateController.php"
     type:     annotation
     prefix:   /
+ftth_onu_profile_api:
+    resource: "@FTTHBundle/Controller/REST/ONUProfileRESTController.php"
+    type:   rest
+    prefix:   /api
+ftth_vlan_profile_api:
+    resource: "@FTTHBundle/Controller/REST/VLanProfileRESTController.php"
+    type:   rest
+    prefix:   /api

+ 53 - 0
src/FTTHBundle/Controller/REST/ONUProfileRESTController.php

@@ -0,0 +1,53 @@
+<?php
+
+namespace FTTHBundle\Controller\REST;
+
+use FOS\RestBundle\Controller\Annotations\RouteResource;
+use FTTHBundle\Form\ONUProfileType;
+use WebserviceBundle\Controller\RESTController;
+use Symfony\Component\HttpFoundation\Request;
+
+/**
+ * ONUProfile controller.
+ * @RouteResource("ONUProfile")
+ */
+class ONUProfileRESTController extends RESTController
+{
+    
+    /**
+     * @return string Retorna el nombre de la Entity de trabajo.
+     */
+    public function getRepository()
+    {
+        return 'FTTHBundle:ONUProfile';
+    }
+
+    /**
+     * @return string Retorna el tipo de la clase.
+     */
+    public function getFormEntityType()
+    {
+        return get_class(new ONUProfileType());
+    }
+
+    public function postAction(Request $request)
+    {
+        return FOSView::create("Not implemented.", Codes::HTTP_INTERNAL_SERVER_ERROR);
+    }
+
+    public function putAction(Request $request, $entity = null)
+    {
+        return FOSView::create("Not implemented.", Codes::HTTP_INTERNAL_SERVER_ERROR);
+    }
+
+    public function patchAction(Request $request, $entity)
+    {
+        return FOSView::create("Not implemented.", Codes::HTTP_INTERNAL_SERVER_ERROR);
+    }
+
+    public function deleteAction(Request $request, $entity)
+    {
+        return FOSView::create("Not implemented.", Codes::HTTP_INTERNAL_SERVER_ERROR);
+    }
+
+}

+ 53 - 0
src/FTTHBundle/Controller/REST/VLanProfileRESTController.php

@@ -0,0 +1,53 @@
+<?php
+
+namespace FTTHBundle\Controller\REST;
+
+use FOS\RestBundle\Controller\Annotations\RouteResource;
+use FTTHBundle\Form\VLanProfileType;
+use WebserviceBundle\Controller\RESTController;
+use Symfony\Component\HttpFoundation\Request;
+
+/**
+ * VLanProfile controller.
+ * @RouteResource("VLanProfile")
+ */
+class VLanProfileRESTController extends RESTController
+{
+    
+    /**
+     * @return string Retorna el nombre de la Entity de trabajo.
+     */
+    public function getRepository()
+    {
+        return 'FTTHBundle:VLanProfile';
+    }
+
+    /**
+     * @return string Retorna el tipo de la clase.
+     */
+    public function getFormEntityType()
+    {
+        return get_class(new VLanProfileType());
+    }
+
+    public function postAction(Request $request)
+    {
+        return FOSView::create("Not implemented.", Codes::HTTP_INTERNAL_SERVER_ERROR);
+    }
+
+    public function putAction(Request $request, $entity = null)
+    {
+        return FOSView::create("Not implemented.", Codes::HTTP_INTERNAL_SERVER_ERROR);
+    }
+
+    public function patchAction(Request $request, $entity)
+    {
+        return FOSView::create("Not implemented.", Codes::HTTP_INTERNAL_SERVER_ERROR);
+    }
+
+    public function deleteAction(Request $request, $entity)
+    {
+        return FOSView::create("Not implemented.", Codes::HTTP_INTERNAL_SERVER_ERROR);
+    }
+
+}

+ 63 - 0
src/FTTHBundle/Form/ONUProfileType.php

@@ -0,0 +1,63 @@
+<?php
+
+namespace FTTHBundle\Form;
+
+use Symfony\Component\Form\AbstractType;
+use Symfony\Component\Form\FormBuilderInterface;
+use Symfony\Component\OptionsResolver\OptionsResolver;
+
+use Symfony\Component\Form\Extension\Core\Type\TextType;
+
+use Symfony\Component\Form\FormEvent;
+use Symfony\Component\Form\FormEvents;
+
+use FTTHBundle\Form\ServicePortType;
+
+class ONUProfileType extends AbstractType
+{
+
+    protected $webservice = null;
+
+    public function setWebService($ws)
+    {
+        $this->webservice = $ws;
+    }
+
+    protected $em = null;
+
+    public function setEntityManager($em)
+    {
+        $this->em = $em;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function buildForm(FormBuilderInterface $builder, array $options)
+    {
+        $builder->add('id')
+            ->add('name')
+            ->add('value')
+	    ->add('usedByDefault')
+	    ->add('tenancyId');
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function configureOptions(OptionsResolver $resolver)
+    {
+        $resolver->setDefaults(array(
+            'data_class' => 'FTTHBundle\Entity\ONUProfile',
+            'csrf_protection' => false
+        ));
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getBlockPrefix()
+    {
+        return 'ftthbundle_onu_profile';
+    }
+}

+ 2 - 0
src/FTTHBundle/Form/ONUType.php

@@ -42,6 +42,8 @@ class ONUType extends AbstractType
             ->add('profile')
             ->add('model')
             ->add('nap')
+            ->add('vlanProfile')
+            ->add('onuProfile')
             ->add('ponSerialNumber')
             ->add('ponSerialNumberAux')
             ->add('clientId')

+ 63 - 0
src/FTTHBundle/Form/VLanProfileType.php

@@ -0,0 +1,63 @@
+<?php
+
+namespace FTTHBundle\Form;
+
+use Symfony\Component\Form\AbstractType;
+use Symfony\Component\Form\FormBuilderInterface;
+use Symfony\Component\OptionsResolver\OptionsResolver;
+
+use Symfony\Component\Form\Extension\Core\Type\TextType;
+
+use Symfony\Component\Form\FormEvent;
+use Symfony\Component\Form\FormEvents;
+
+use FTTHBundle\Form\ServicePortType;
+
+class VLanProfileType extends AbstractType
+{
+
+    protected $webservice = null;
+
+    public function setWebService($ws)
+    {
+        $this->webservice = $ws;
+    }
+
+    protected $em = null;
+
+    public function setEntityManager($em)
+    {
+        $this->em = $em;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function buildForm(FormBuilderInterface $builder, array $options)
+    {
+        $builder->add('id')
+            ->add('name')
+            ->add('value')
+            ->add('usedByDefault')
+            ->add('tenancyId');
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function configureOptions(OptionsResolver $resolver)
+    {
+        $resolver->setDefaults(array(
+            'data_class' => 'FTTHBundle\Entity\VLanProfile',
+            'csrf_protection' => false
+        ));
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getBlockPrefix()
+    {
+        return 'ftthbundle_vlan_profile';
+    }
+}