示例#1
0
 public function __construct(Templating $twigEngine, EventDispatcherInterface $eventDispatcher, ManagerRegistry $documentManager, Producer $documentProducer)
 {
     $this->twigEngine = $twigEngine;
     $this->eventDispatcher = $eventDispatcher;
     $this->documentManager = $documentManager->getManager();
     $this->documentProducer = $documentProducer;
 }
示例#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;
 }
示例#3
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;
 }
 /**
  * Set options from configuration
  *
  * @param array $options Options
  */
 public function setOptions($options)
 {
     $this->options = $options;
     if (isset($this->options['host'])) {
         $this->queryDriver = new ServerQuery($this->options);
     } else {
         if (isset($this->options['connection'])) {
             $this->queryDriver = new DefaultQuery($this->options, $this->mongodb->getManager($this->options['connection']));
         } else {
             $this->queryDriver = new DefaultQuery($this->options, $this->mongodb->getManager());
         }
     }
 }
 /**
  * This is not necessarily a good test, it doesn't generate any proxies
  * because there are none in the AnnotationsBundle. However that is
  * rather a task of doctrine to test. We touch the lines here and
  * verify that the container is called correctly for the relevant information.
  *
  * @group DoctrineODMMongoDBProxy
  */
 public function testWarmCache()
 {
     $testManager = $this->createTestDocumentManager(array(__DIR__ . "/../DependencyInjection/Fixtures/Bundles/AnnotationsBundle/Document"));
     $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $registry = new ManagerRegistry('MongodB', array(), array('default' => 'doctrine_mongodb.odm.default_document_manager', 'foo' => 'doctrine_mongodb.odm.foo_document_manager'), 'default', 'default', 'Doctrine\\ODM\\MongoDB\\Proxy\\Proxy');
     $registry->setContainer($container);
     $container->expects($this->at(0))->method('getParameter')->with($this->equalTo('doctrine_mongodb.odm.proxy_dir'))->will($this->returnValue(sys_get_temp_dir()));
     $container->expects($this->at(1))->method('getParameter')->with($this->equalTo('doctrine_mongodb.odm.auto_generate_proxy_classes'))->will($this->returnValue(false));
     $container->expects($this->at(2))->method('get')->with($this->equalTo('doctrine_mongodb'))->will($this->returnValue($registry));
     $container->expects($this->at(3))->method('get')->with($this->equalTo('doctrine_mongodb.odm.default_document_manager'))->will($this->returnValue($testManager));
     $container->expects($this->at(4))->method('get')->with($this->equalTo('doctrine_mongodb.odm.foo_document_manager'))->will($this->returnValue($testManager));
     $cacheWarmer = new ProxyCacheWarmer($container);
     $cacheWarmer->warmUp(sys_get_temp_dir());
 }
示例#6
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()]);
     });
 }
 /**
  * Upload and save word content into article
  *
  * @param Array $files
  * @param String $type
  * @return boolean
  */
 public function convert($files, $type)
 {
     foreach ($files as $file) {
         $fileName = $file["fileName"];
         $path = $file["path"];
         $document = new Document($fileName, $path);
         $this->addDocument($document);
         $this->execute();
     }
     foreach ($files as $file) {
         $fileName = $file["fileName"];
         $document = $this->getDocument($fileName);
         $metadata = $document->getMetadata();
         $author = $metadata->get("Author");
         $title = $metadata->get("dc:title");
         if ($title == "") {
             $this->crawler->addContent($document->getContent());
             $title = $this->crawler->filter('body p:first-child b')->text();
             if ($title == "") {
                 $title = $fileName;
             }
         }
         //Create new Article and add images as Files.
         $article = new Article();
         $authors = new ArrayCollection();
         $authors->add($author);
         //$article->setAuthors($authors);
         $article->setContentType($type);
         $article->setTitle($title);
         $article->setContent($document->getContent());
         $references = new ArrayCollection();
         $dm = $this->doctrineMongodb->getManager();
         foreach ($document->images as $image) {
             $uploadedFile = new UploadedFile("upload/" . $document->getName() . "/" . $image, 'original', 'mime/original', 123, UPLOAD_ERR_OK, true);
             $file = new File();
             $file->setFile($uploadedFile);
             $references->add($file);
         }
         //$article->setReferences($references);
         $dm->persist($article);
         $dm->flush();
     }
     return true;
 }
示例#8
0
 public function __construct(ManagerRegistry $registry)
 {
     $this->manager = $registry->getManager();
     $this->repository = $this->manager->getRepository(UserDocument::REPOSITORY);
 }
示例#9
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;
     }
 }
示例#11
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);
 }
 public function __construct(ManagerRegistry $registry)
 {
     $this->documentManager = $registry->getManager();
 }
示例#14
0
 /**
  * Get the Doctrine ObjectRepository for the respective collection.
  *
  * @return \Doctrine\Common\Persistence\ObjectRepository
  */
 protected function getRepository()
 {
     return $this->doctrine->getRepository($this->getRepositoryName());
 }