/**
  * 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());
         }
     }
 }
 /**
  * Unfollow the listing executes the next actions:
  *      - deletes a follow document from mondoDB collection
  *      - updates follow QTYs for follower
  *      - updates follow QTYs for followed listing owner (if exists)
  *      - updates reputation for follower
  *      - updates reputation for followed listing owner (if exists)
  * 
  * @param \IMS\_CoreBundle\Entity\General\Account $follower
  * @param \IMS\_CoreBundle\Entity\General\MarketItem\Listing $listing
  * @return boolean Whether following was removed
  */
 public function unfollowListing(\IMS\_CoreBundle\Entity\General\Account $follower, \IMS\_CoreBundle\Entity\General\MarketItem\Listing $listing)
 {
     $dm = $this->_mongodb->getManager();
     switch ($listing->getDiscr()) {
         case 'service':
             $type = \IMS\_CoreBundle\Document\Follow\Follow::TYPE_SERVICE;
             break;
         case 'tool':
             $type = \IMS\_CoreBundle\Document\Follow\Follow::TYPE_TOOL;
             break;
         default:
             throw new \Doctrine\ORM\Mapping\MappingException("Discriminator {$listing->getDiscr()} does not exist in discriminator map of IMS Listing Entity.");
     }
     if (!($follow = $this->ifUserFollowsListing($follower->getId(), $listing->getId()))) {
         return false;
     }
     // delete the following
     $dm->remove($follow);
     $dm->flush();
     // update follow QTYs for follower
     \IMS\ServiceBundle\PHPResque\Job\Follow\UpdateUserQtyFollowJob::attach(array('id' => $follower->getId()));
     // update reputation of follower
     \IMS\ServiceBundle\PHPResque\Job\Account\UpdateReputationJob::attach(array('id' => $follower->getId(), 'action' => ReputationHandler::ACTION_LISTING_UNFOLLOW));
     if ($listing->getOwner()) {
         // update follow QTYs for followed
         \IMS\ServiceBundle\PHPResque\Job\Follow\UpdateUserQtyFollowJob::attach(array('id' => $listing->getOwner()->getId()));
         // update reputation of followed
         \IMS\ServiceBundle\PHPResque\Job\Account\UpdateReputationJob::attach(array('id' => $listing->getOwner()->getId(), 'action' => ReputationHandler::ACTION_LISTING_UNFOLLOWED));
     }
     // update followers qty for listing
     \IMS\ServiceBundle\PHPResque\Job\Follow\UpdateListingQtyFollowJob::attach(array('id' => $listing->getId()));
     return true;
 }
示例#3
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;
 }
示例#4
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;
 }
示例#5
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;
 }
示例#7
0
 public function __construct(ManagerRegistry $registry)
 {
     $this->manager = $registry->getManager();
     $this->repository = $this->manager->getRepository(UserDocument::REPOSITORY);
 }
示例#8
0
 public function __construct(ManagerRegistry $registry)
 {
     $this->dm = $registry->getManager();
     $this->repository = $registry->getRepository('MapBundle:Content');
 }
 public function __construct(ManagerRegistry $registry)
 {
     $this->documentManager = $registry->getManager();
 }
示例#10
0
 public function __construct($doctrine, Logger $logger)
 {
     $this->doctrine = $doctrine;
     $this->doctrineManager = $this->doctrine->getManager();
     $this->logger = $logger;
 }