Example #1
0
 /**
  * @param $email
  *
  * @return UserDocument|null
  * @throws NotFoundHttpException
  */
 public function getUserByEmail($email)
 {
     $user = $this->mongoDB->getRepository('AppBundle:User')->findOneByEmail($email);
     if (!$user) {
         throw new NotFoundHttpException('No user found for email ' . $email);
     }
     return $user;
 }
Example #2
0
 public function __construct(ManagerRegistry $registry, Google_Client $googleClient, ValidatorInterface $validator, JWTManagerInterface $tokenManager)
 {
     $this->dm = $registry->getManager();
     $this->repository = $registry->getRepository('MapBundle:User');
     $this->googleClient = $googleClient;
     $this->validator = $validator;
     $this->tokenManager = $tokenManager;
 }
Example #3
0
 /**
  * @param FormBuilderInterface  $builder
  * @param array                 $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('label', 'text')->add('slug', 'text');
     $builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) {
         $label = $event->getData();
         if (!is_string($label)) {
             throw new TransformationFailedException();
         }
         $tag = $this->manager->getRepository('ApiBundle:Tag')->findOneByLabel($label);
         if (!$tag) {
             $tag = new Tag();
             $tag->setLabel($label);
             $this->manager->getManager()->persist($tag);
             $this->manager->getManager()->flush();
         }
         $event->setData(['label' => $tag->getLabel(), 'slug' => $tag->getSlug()]);
     });
 }
Example #4
0
 public function __construct(ManagerRegistry $registry)
 {
     $this->dm = $registry->getManager();
     $this->repository = $registry->getRepository('MapBundle:Content');
 }
 private function createTextnodes(ManagerRegistry $mongo, DocumentManager $dm)
 {
     $loremIpsumLength = 3500;
     $repository = $mongo->getRepository('DembeloMain:Textnode');
     $allAccessNodes = $repository->findByAccess(true);
     if (count($allAccessNodes) >= 7) {
         return;
     }
     $loremIpsum = $this->getContainer()->get('apoutchika.lorem_ipsum');
     $textnodeData = array(array('topic' => $this->dummyData['topics'][0], 'text' => $loremIpsum->getWords($loremIpsumLength), 'access' => true, 'licensee' => $this->dummyData['licensees'][0], 'metadata' => array('Titel' => 'Titel 1', 'Autor' => 'Autor 1', 'Verlag' => 'Verlag 1')), array('text' => $loremIpsum->getWords($loremIpsumLength), 'access' => false, 'licensee' => $this->dummyData['licensees'][0], 'metadata' => array('Titel' => 'Titel 2', 'Autor' => 'Autor 2', 'Verlag' => 'Verlag 2')), array('text' => $loremIpsum->getWords($loremIpsumLength), 'access' => false, 'licensee' => $this->dummyData['licensees'][0], 'metadata' => array('Titel' => 'Titel 3', 'Autor' => 'Autor 3', 'Verlag' => 'Verlag 3')), array('topic' => $this->dummyData['topics'][1], 'text' => $loremIpsum->getWords($loremIpsumLength), 'access' => true, 'licensee' => $this->dummyData['licensees'][0], 'metadata' => array('Titel' => 'Titel 4', 'Autor' => 'Autor 4', 'Verlag' => 'Verlag 4')), array('text' => $loremIpsum->getWords($loremIpsumLength), 'access' => false, 'licensee' => $this->dummyData['licensees'][0], 'metadata' => array('Titel' => 'Titel 5', 'Autor' => 'Autor 5', 'Verlag' => 'Verlag 5')), array('text' => $loremIpsum->getWords($loremIpsumLength), 'access' => false, 'licensee' => $this->dummyData['licensees'][0], 'metadata' => array('Titel' => 'Titel 6', 'Autor' => 'Autor 6', 'Verlag' => 'Verlag 6')));
     foreach ($textnodeData as $textnodeDatum) {
         $textnode = new Textnode();
         $textnode->setStatus(Textnode::STATUS_ACTIVE);
         if (isset($textnodeDatum['topic'])) {
             $textnode->setTopicId($textnodeDatum['topic']->getId());
         }
         if (isset($textnodeDatum['licensee'])) {
             $textnode->setLicenseeId($textnodeDatum['licensee']->getId());
         }
         $textnode->setCreated(date('Y-m-d H:i:s'));
         $textnode->setText($textnodeDatum['text']);
         $textnode->setAccess($textnodeDatum['access']);
         $textnode->setMetadata($textnodeDatum['metadata']);
         $dm->persist($textnode);
         $this->dummyData['textnodes'][] = $textnode;
     }
 }
Example #6
0
 /**
  * get a repository class for a given class name
  *
  * @param string $documentId class to instanciate
  *
  * @return \Doctrine\Common\Persistence\ObjectManager
  */
 public function get($documentId)
 {
     return $this->managerRegistry->getRepository($documentId);
 }
 /**
  * Clear follows related to account
  * @param integer $accountId
  */
 public function deleteUserFollows($accountId)
 {
     $this->_mongodb->getRepository('IMSCoreBundle:Follow\\Follow')->deleteFollowsByUserId($accountId);
 }
Example #8
0
 /**
  * Get the Doctrine ObjectRepository for the respective collection.
  *
  * @return \Doctrine\Common\Persistence\ObjectRepository
  */
 protected function getRepository()
 {
     return $this->doctrine->getRepository($this->getRepositoryName());
 }