Пример #1
0
 public function load(ObjectManager $manager)
 {
     $service = new Service();
     $service->setName('E-Commerce');
     $service->setDescription('Listos para comerciar. Publicidad acerca de seguridad. Lorem ipsun pruebas, texto aleatorio y sin sentido.');
     $service->setIcon('shopping-cart');
     $manager->persist($service);
     $service = new Service();
     $service->setName('Web Design');
     $service->setDescription('Detalles referente al diseño web. Publicidad acerca de seguridad. Lorem ipsun pruebas, texto aleatorio y sin sentido.');
     $service->setIcon('laptop');
     $manager->persist($service);
     $service = new Service();
     $service->setName('Seguridad');
     $service->setDescription('Publicidad acerca de seguridad. Lorem ipsun pruebas, texto aleatorio y sin sentido.');
     $service->setIcon('lock');
     $manager->persist($service);
     $serviceSection = new ServiceSection();
     $serviceSection->setName('Servicios');
     $serviceSection->setTextDescription('Una descripción de nuestros servicios. Puede ser más de una línea');
     $manager->persist($serviceSection);
     $homeSection = new HomeSection();
     $homeSection->setPageName('CodeXAvant Studio');
     $homeSection->setFirstHeader('Una buena experiencia');
     $homeSection->setSecondHeader('Un excelente recuerdo');
     $homeSection->setButtonLabel('Conozca más');
     $homeSection->setCopyRight('Copyright © Your Website 2014');
     $manager->persist($homeSection);
     $teamSection = new TeamSection();
     $teamSection->setTeamHeader('Conozca Nuestro Equipo');
     $teamSection->setDescription('Nuestro equipo está compuesto por un versátil grupo');
     $manager->persist($teamSection);
     $teamMember = new TeamMember();
     $teamMember->setName('DaVinci OneWay');
     $teamMember->setPosition('Diseñador');
     $teamMember->setImage('highway_nights-100x100.jpg');
     $teamMember->setUpdatedAt(new \DateTime());
     $manager->persist($teamMember);
     $teamMember = new TeamMember();
     $teamMember->setName('King Athur');
     $teamMember->setPosition('CEO');
     $teamMember->setImage('wall_bsod-200x200.jpg');
     $teamMember->setUpdatedAt(new \DateTime());
     $manager->persist($teamMember);
     $teamMember = new TeamMember();
     $teamMember->setName('Philip ByteCode');
     $teamMember->setPosition('Programador');
     $teamMember->setImage('LitleH-100.jpg');
     $teamMember->setUpdatedAt(new \DateTime());
     $manager->persist($teamMember);
     $manager->flush();
 }
Пример #2
0
 /**
  * @Route("/{serviceSlug}.html", name="service_show")
  * @ParamConverter("serviceGroup", class="AppBundle:ServiceGroup", options={"mapping" : {"serviceGroupSlug" = "slug"}})
  * @ParamConverter("service", class="AppBundle:Service", options={"mapping" : {"serviceSlug" = "slug"}})
  */
 public function showAction(ServiceGroup $serviceGroup, Service $service)
 {
     $additional = array();
     $articles = array();
     if ($service->getServiceGroup() == $serviceGroup && $service->isVisible()) {
         //точное совпадение ВСЕХ тэгов
         if ($service->getTags()->toArray()) {
             $articles = $service->getTags()->first()->getArticles()->toArray();
             //ХОТЯ БЫ ОДИН тэг совпадает
             foreach ($service->getTags() as $tag) {
                 //остаются только совпадающие элементы массивов (пересечение массивов)
                 $articles = array_intersect($articles, $tag->getArticles()->filter(function ($service) {
                     return $service->isVisible() == 1;
                 })->toArray());
                 //массивы складываются, т.е. "собираются" все статьи, имеющие хотя бы один общий с услугой тэг
                 $additional = array_merge($additional, $tag->getArticles()->filter(function ($service) {
                     return $service->isVisible() == 1;
                 })->toArray());
             }
             //убрать те статьи, которые уже есть в точном совпадении
             $additional = array_diff($additional, $articles);
         }
         return $this->render('service/show.html.twig', array('service' => $service, 'articles' => array_unique($articles), 'additional' => $additional));
     } else {
         throw $this->createNotFoundException('Такая страница не существует!');
     }
 }
 private function createServiceHal(Service $service)
 {
     $normalizer = $this->normalizer();
     $hal = (new Hal('/services/' . $service->getId()))->setData($this->getData($service));
     foreach ($service->getProviders() as $provider) {
         $hal->addResource('providers', (new Hal('/providers/' . $provider->getId()))->setData($normalizer->normalize($provider)));
     }
     foreach ($service->getStages() as $stage) {
         $hal->addResource('stages', (new Hal('/stages/' . $stage->getId()))->setData($normalizer->normalize($stage)));
     }
     foreach ($service->getCategories() as $category) {
         $hal->addResource('categories', (new Hal('/categories/' . $category->getId()))->setData($normalizer->normalize($category)));
     }
     foreach ($service->getServiceUsers() as $serviceUser) {
         $hal->addResource('serviceUsers', (new Hal('/service-users/' . $serviceUser->getId()))->setData($normalizer->normalize($serviceUser)));
     }
     foreach ($service->getIssues() as $issue) {
         $hal->addResource('issues', (new Hal('/issues/' . $issue->getId()))->setData($normalizer->normalize($issue)));
     }
     return $hal;
 }
Пример #4
0
 private function addServices()
 {
     $doctrine = $this->getContainer()->get('doctrine');
     $manager = $doctrine->getManager();
     $cmd = $manager->getClassMetadata('AppBundle\\Entity\\Service');
     $connection = $manager->getConnection();
     $connection->beginTransaction();
     try {
         $connection->query('SET FOREIGN_KEY_CHECKS=0');
         $connection->query('DELETE FROM ' . $cmd->getTableName());
         $connection->query('DELETE FROM service_stage');
         $connection->query('DELETE FROM service_issue');
         $connection->query('DELETE FROM service_provider');
         $connection->query('DELETE FROM service_category');
         $connection->query('DELETE FROM service_service_user');
         $connection->query('ALTER TABLE ' . $cmd->getTableName() . ' AUTO_INCREMENT = 1');
         // Beware of ALTER TABLE here--it's another DDL statement and will cause
         // an implicit commit.
         $connection->query('SET FOREIGN_KEY_CHECKS=1');
         $connection->commit();
     } catch (\Exception $e) {
         $connection->rollback();
     }
     $service = new Service("My Service", "This is a service", "me", new \DateTimeImmutable("2018-01-01T00:00:00+0000"));
     $service->addCategory($manager->getRepository('AppBundle\\Entity\\Category')->find(1));
     $service->addStage($manager->getRepository('AppBundle\\Entity\\Stage')->find(1));
     $service->addStage($manager->getRepository('AppBundle\\Entity\\Stage')->find(2));
     $service->addProvider($manager->getRepository('AppBundle\\Entity\\Provider')->find(1));
     $service->addProvider($manager->getRepository('AppBundle\\Entity\\Provider')->find(2));
     $service->addServiceUser($manager->getRepository('AppBundle\\Entity\\ServiceUser')->find(2));
     $service->addServiceUser($manager->getRepository('AppBundle\\Entity\\ServiceUser')->find(3));
     $service->addIssue($manager->getRepository('AppBundle\\Entity\\Issue')->find(2));
     $manager->persist($service);
     $service2 = new Service("Another Service", "This is a another service", "someone else", new \DateTimeImmutable("2018-01-01T00:00:00+0000"));
     $service2->addCategory($manager->getRepository('AppBundle\\Entity\\Category')->find(6));
     $service2->addCategory($manager->getRepository('AppBundle\\Entity\\Category')->find(7));
     $service2->addStage($manager->getRepository('AppBundle\\Entity\\Stage')->find(3));
     $service2->addProvider($manager->getRepository('AppBundle\\Entity\\Provider')->find(2));
     $service2->addServiceUser($manager->getRepository('AppBundle\\Entity\\ServiceUser')->find(1));
     $service2->addIssue($manager->getRepository('AppBundle\\Entity\\Issue')->find(3));
     $manager->persist($service2);
     $manager->flush();
 }
Пример #5
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $doctrine = $this->getContainer()->get('doctrine');
     $manager = $doctrine->getManager();
     $cmd = $manager->getClassMetadata('AppBundle\\Entity\\Service');
     $connection = $manager->getConnection();
     $connection->beginTransaction();
     try {
         $connection->query('SET FOREIGN_KEY_CHECKS=0');
         $connection->query('DELETE FROM ' . $cmd->getTableName());
         $connection->query('DELETE FROM provider');
         $connection->query('DELETE FROM service_stage');
         $connection->query('DELETE FROM service_issue');
         $connection->query('DELETE FROM service_provider');
         $connection->query('DELETE FROM service_category');
         $connection->query('DELETE FROM service_service_user');
         $connection->query('ALTER TABLE ' . $cmd->getTableName() . ' AUTO_INCREMENT = 1');
         $connection->query('ALTER TABLE provider AUTO_INCREMENT = 1');
         // Beware of ALTER TABLE here--it's another DDL statement and will cause
         // an implicit commit.
         $connection->query('SET FOREIGN_KEY_CHECKS=1');
         $connection->commit();
     } catch (\Exception $e) {
         $connection->rollback();
     }
     $file = new \SplFileObject(__DIR__ . '/../../../trello.csv');
     $file->setFlags(\SplFileObject::READ_CSV);
     foreach ($file as $row) {
         // Skip header row or empty row
         if ($row[0] == "Card ID" || $row[0] == null) {
             continue;
         }
         $matches = [];
         $name = $row[1];
         if (preg_match('/(.*)\\((.*)\\)/', $row[1], $matches)) {
             $name = trim($matches[1]);
             $providerName = $matches[2];
             if (!isset($this->providers[$providerName])) {
                 $provider = new Provider($providerName);
                 $manager->persist($provider);
                 $this->providers[$providerName] = $provider;
             }
         }
         $service = new Service($name, $row[3], null, null);
         if (isset($providerName)) {
             $service->addProvider($this->providers[$providerName]);
         }
         $output->writeln("---");
         $output->writeln("Processing " . $name);
         switch ($row[15]) {
             case "Arrival":
                 $service->addStage($manager->getRepository('AppBundle\\Entity\\Stage')->find(1));
                 break;
             case "Awaiting Decision":
                 $service->addStage($manager->getRepository('AppBundle\\Entity\\Stage')->find(2));
                 break;
             case "Positive Decision":
                 $service->addStage($manager->getRepository('AppBundle\\Entity\\Stage')->find(3));
                 break;
             case "Positive decision - no recourse to public funds":
                 $service->addStage($manager->getRepository('AppBundle\\Entity\\Stage')->find(5));
                 break;
             case "Negative Decision - with state support (e.g. section 4)":
                 $service->addStage($manager->getRepository('AppBundle\\Entity\\Stage')->find(5));
                 break;
             case "Negative Decision - Destitute":
                 $service->addStage($manager->getRepository('AppBundle\\Entity\\Stage')->find(6));
                 break;
             case "Gateway Protection programme (Refugee Council)":
                 $service->addStage($manager->getRepository('AppBundle\\Entity\\Stage')->find(7));
                 break;
             default:
                 $output->writeln("Skipping because list is " . $row[15]);
                 continue 2;
         }
         foreach (explode(',', $row[4]) as $label) {
             switch (trim($label)) {
                 case "Children":
                     $service->addServiceUser($manager->getRepository('AppBundle\\Entity\\ServiceUser')->find(3));
                     break;
                 case "Family":
                     $service->addServiceUser($manager->getRepository('AppBundle\\Entity\\ServiceUser')->find(2));
                     break;
                 case "Vulnerable adults":
                     $service->addServiceUser($manager->getRepository('AppBundle\\Entity\\ServiceUser')->find(4));
                     break;
                 case "Single Male":
                     $service->addServiceUser($manager->getRepository('AppBundle\\Entity\\ServiceUser')->find(5));
                     break;
                 case "Single Female":
                     $service->addServiceUser($manager->getRepository('AppBundle\\Entity\\ServiceUser')->find(6));
                     break;
                 case "Needing further support/Under-resourced (blue)":
                     $service->addIssue($manager->getRepository('AppBundle\\Entity\\Issue')->find(1));
                     break;
                 case "Gap in provision (pink)":
                     $service->addIssue($manager->getRepository('AppBundle\\Entity\\Issue')->find(2));
                     break;
                 case "Needing Immediate Action (purple)":
                     $service->addIssue($manager->getRepository('AppBundle\\Entity\\Issue')->find(3));
                     break;
                 case "Right to Remain/Positive Decision (green)":
                     $service->addStage($manager->getRepository('AppBundle\\Entity\\Stage')->find(3));
                     break;
                 case "Arrival (red)":
                     $service->addStage($manager->getRepository('AppBundle\\Entity\\Stage')->find(1));
                     break;
                 case "Awaiting Decision (yellow)":
                     $service->addStage($manager->getRepository('AppBundle\\Entity\\Stage')->find(2));
                     break;
                 case "Positive no recourse (black)":
                     $service->addStage($manager->getRepository('AppBundle\\Entity\\Stage')->find(4));
                     break;
                 case "Negative Decision with state support  e.g section 4  (sky)":
                     $service->addStage($manager->getRepository('AppBundle\\Entity\\Stage')->find(5));
                     break;
                 case "Negative Decision/Destitute (orange)":
                     $service->addStage($manager->getRepository('AppBundle\\Entity\\Stage')->find(6));
                     break;
                 case "Gateway":
                     $service->addStage($manager->getRepository('AppBundle\\Entity\\Stage')->find(7));
                     break;
                 case "Education":
                     $service->addCategory($manager->getRepository('AppBundle\\Entity\\Category')->find(1));
                     break;
                 case "Accommodation":
                     $service->addCategory($manager->getRepository('AppBundle\\Entity\\Category')->find(3));
                     break;
                 case "Health & Social Care":
                     $service->addCategory($manager->getRepository('AppBundle\\Entity\\Category')->find(2));
                     break;
                 case "Finance":
                     $service->addCategory($manager->getRepository('AppBundle\\Entity\\Category')->find(4));
                     break;
                 case "Social & Community":
                     $service->addCategory($manager->getRepository('AppBundle\\Entity\\Category')->find(6));
                     break;
                 case "Asylum Process Advice & Legal":
                     $service->addCategory($manager->getRepository('AppBundle\\Entity\\Category')->find(5));
                     break;
                 case "Resources e.g. clothes and food":
                     $service->addCategory($manager->getRepository('AppBundle\\Entity\\Category')->find(7));
                     break;
                 default:
                     $output->writeln('Unhandled label - ' . $label);
             }
         }
         $manager->persist($service);
         $output->writeln("OK");
     }
     $manager->flush();
     $output->writeln("CSV Imported");
 }
Пример #6
0
 /**
  * Add service
  *
  * @param Service $service
  *
  * @return $this
  */
 public function addService(Service $service)
 {
     $service->setCategory($this);
     $this->services[] = $service;
     return $this;
 }
Пример #7
0
 /**
  * Add services
  *
  * @param \AppBundle\Entity\Service $services
  * @return ServiceGroup
  */
 public function addService(\AppBundle\Entity\Service $services)
 {
     $services->setServiceGroup($this);
     $this->services[] = $services;
     return $this;
 }
Пример #8
0
 /**
  * Creates a form to delete a Service entity by id.
  *
  * @param Service $service
  *
  * @return \Symfony\Component\Form\Form
  */
 private function createDeleteForm(Service $service)
 {
     return $this->createFormBuilder()->setAction($this->generateUrl('service_delete', array('id' => $service->getId())))->setMethod('DELETE')->getForm();
 }