Esempio n. 1
0
 public function loadOrCreateTags($tags, Administration $administration = null)
 {
     if (!$administration) {
         $administration = $this->getCurrentAdministration();
     }
     if (!$administration) {
         return array();
     }
     $repo = $this->entityManager->getRepository('HomefinanceBundle:Tag');
     $values = array();
     foreach ($tags as $tag) {
         $t = $repo->findOneByNameAndAdministration($administration, $tag);
         if (!$t) {
             $t = new Tag();
             $t->setAdministration($administration);
             $t->setName($tag);
             $this->entityManager->persist($t);
         }
         $values[] = $t;
     }
     return $values;
 }
Esempio n. 2
0
 public function emailAddressConfirmed(BaseUser $user)
 {
     if (!empty($user->getNewEmail())) {
         $user->setEmail($user->getNewEmail());
         $user->setNewEmail(null);
     }
     $user->setEnabled(true);
     $this->resetTokenData($user);
     $event = new UserEvent($user);
     $this->dispatcher->dispatch(UserEvents::CONFIRMATION_SUCCESS, $event);
     $this->entityManager->persist($user);
     $this->entityManager->flush();
 }
 /**
  * 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;
 }