Пример #1
0
 /**
  * @Route("/post/{id}")
  * @Template()
  */
 public function indexAction($id)
 {
     $post = new Post();
     $post->setName('Александр');
     $post->setPhone('097 758 11 54');
     $post->setEmail('*****@*****.**');
     $post->setProduct('phone Elari (red)');
     $post->setPrice(1389);
     $post->setPlace('Харьков');
     $post->setTransport("novapochta");
     $post->setPayMethod("cache");
     $this->em->persist($post);
     $this->em->flush();
     return $this->templating->renderResponse('Post/index.html.twig', array('post' => $post));
 }
Пример #2
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $providerPool = $this->getContainer()->get('opifer.mailinglist.provider_pool');
     $lists = $this->em->getRepository('OpiferMailingListBundle:MailingList')->findWithProviders();
     if (empty($lists)) {
         $output->writeln("<info>0 lists found to synchronise: exiting…</info>");
         return;
     }
     $logger = $this->buildLoggerClosure($output, count($lists));
     $logger('Lists initialised.');
     foreach ($lists as $list) {
         /** @var MailingListProviderInterface $provider */
         $provider = $providerPool->getProvider($list->getProvider());
         $provider->synchroniseList($list, $logger);
         $logger(sprintf('Finished synchronisation on %s with %s', $list->getName(), $provider->getName()), 1);
     }
     //
     //            /** @var MailingList $mailingList */
     //            foreach ($mailingLists as $mailingList) {
     //                if ($mailingList->getProvider() == 'mailplus') {
     //                    $output->writeln(sprintf('Synchronizing subscriptions for mailinglist %s', $mailingList->getDisplayName()));
     //
     //                    /** @var MailPlusProvider $provider */
     //                    $provider = $this->getContainer()->get('opifer.mailplus_provider');
     //
     //                    $synced = $failed = 0;
     //
     //                    $subscriptions = $subscriptionRepository->getUnsyncedByMailinglist($mailingList);
     //
     //                    /** @var Subscription $subscription */
     //                    foreach ($subscriptions as $subscription) {
     //                        $success = $provider->sync($subscription);
     //
     //                        if ($success) {
     //                            $synced++;
     //                        } else {
     //                            $failed++;
     //                        }
     //                    }
     //
     //                    $output->writeln(sprintf('%d synched and %d failed of %d subscriptions', $synced, $failed, count($subscriptions)));
     //                }
     //            }
     //        }
 }
Пример #3
0
 /**
  * Get the role by slug
  *
  * @param $slug
  * @return mixed
  * @throws RoleNotFoundException
  */
 public function get($slug)
 {
     $lowerslug = strtolower($slug);
     //create unique key for kind and uppercased name
     $key = md5('role.' . $lowerslug);
     //cache has value return this one
     $cached = Cache::get($key);
     if ($cached) {
         return $cached;
     }
     $role = $this->em->getRepository($this->class)->findOneBy(['slug' => $lowerslug]);
     if (!$role) {
         throw new RoleNotFoundException($slug);
     }
     //cache it for next request
     Cache::forever($key, $role);
     return Cache::get($key);
 }
Пример #4
0
 public function testFlushByPassException()
 {
     $this->resource->expects($this->exactly(2))->method('getName')->will($this->returnValue($name = 'name'));
     $this->objectManager->expects($this->once())->method('flush')->will($this->throwException(new \Exception()));
     $this->eventDispatcher->expects($this->at(0))->method('dispatch')->with($this->identicalTo('lug.' . $name . '.pre_' . ($action = 'flush')), $this->callback(function (DomainEvent $event) use($action) {
         return $event->getResource() === $this->resource && $event->getObject() === null && $event->getAction() === $action;
     }));
     $this->eventDispatcher->expects($this->at(1))->method('dispatch')->with($this->identicalTo('lug.' . $name . '.error_' . $action), $this->callback(function (DomainEvent $event) use($action) {
         $result = $event->getResource() === $this->resource && $event->getObject() === null && $event->getAction() === $action;
         $event->setStopped(false);
         return $result;
     }));
     $this->domainManager->flush();
 }
Пример #5
0
 /**
  * Finds the organizations in which the given user is registered.
  *
  * @param User $user
  * @return ArrayCollection
  */
 public function organizationsOfUser(User $user)
 {
     $qb = $this->em->createQueryBuilder();
     $qb->select('ur, o')->from($this->urClass, 'ur')->join('ur.organization', 'o')->join('ur.role', 'r')->where($qb->expr()->eq('ur.user', '?1'), $qb->expr()->eq('r.slug', '?2'))->setParameter(1, $user->id())->setParameter(2, 'user');
     $userRoles = $qb->getQuery()->getResult();
     //convert to only organizations
     $result = [];
     foreach ($userRoles as $userRole) {
         if (!in_array($userRole->organization(), $result)) {
             $result[] = $userRole->organization();
         }
     }
     return $result;
 }
 /**
  * Find an Organization by their domain name
  *
  * @param string $domain_name
  * @return Organization
  */
 public function organizationOfDomain($domain_name)
 {
     return $this->em->getRepository($this->class)->findOneBy(['domain_name' => $domain_name]);
 }
 /**
  * Adds an created UserRole
  *
  * @param UserRole $userRole
  * @return mixed
  */
 public function add(UserRole $userRole)
 {
     $this->em->merge($userRole);
     $this->em->flush();
 }