예제 #1
0
 /**
  * Returns the complete path of the section (Section / Sub-Section / Sub-sub-section ... )
  *
  * @return string
  */
 public function getHierarchicalName()
 {
     $return = $this->__toString();
     if ($this->getParent()) {
         $return = $this->parent->getHierarchicalName() . " / " . $return;
     }
     return $return;
 }
예제 #2
0
 /**
  * Return the specific Section for an Exception Event
  *
  * @param $id
  * @param $name
  *
  * @return object|Section
  */
 private function getExceptionSection($id, $name)
 {
     // TODO Use a tagging system with internal tags. ie: _section_404
     $sectionRepository = $this->entityManager->getRepository('UnifikSystemBundle:Section');
     $sectionRepository->setCurrentAppName('frontend');
     $sectionRepository->setLocale($this->defaultLocale);
     $section = $sectionRepository->find($id);
     // Doesn't exist, create the Section
     if (!$section) {
         $section = new Section();
         $section->setCurrentLocale($this->defaultLocale);
         $section->setApp($this->entityManager->getRepository('UnifikSystemBundle:App')->find(2));
         $section->setId($id);
         $section->setName($this->translator->trans($name, array(), 'messages', $this->defaultLocale));
         $section->setActive(true);
         $this->entityManager->persist($section);
         // Force ID
         $metadata = $this->entityManager->getClassMetaData(get_class($section));
         $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
         $this->entityManager->flush();
     }
     return $section;
 }
예제 #3
0
 /**
  * Load
  *
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $metadata = $manager->getClassMetaData('Unifik\\SystemBundle\\Entity\\Section');
     $metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
     $sectionHome = new Section();
     $sectionHome->setId(1);
     $sectionHome->setContainer($this->container);
     $sectionHome->setApp($manager->merge($this->getReference('app-frontend')));
     $sectionHome->setCurrentLocale($manager->merge($this->getReference('locale-fr'))->getCode());
     $sectionHome->setName('Accueil');
     $sectionHome->setActive(true);
     $sectionHome->setCurrentLocale($manager->merge($this->getReference('locale-en'))->getCode());
     $sectionHome->setName('Home');
     $sectionHome->setActive(true);
     $manager->persist($sectionHome);
     $manager->flush();
     $this->addReference('section-home', $sectionHome);
 }