public function getQueryRegistration(Convention $convention) { $qb = $this->createQueryBuilder('registration'); $alias = current($qb->getRootAliases()); $qb->andWhere($qb->expr()->eq($alias . '.convention', $convention->getId())); return $qb; }
public function invoiceAction(Convention $convention, Request $request) { $registrations = $convention->getRegistrations(); $zip = new ZipArchive(); $title = $convention->getSlug(); $filename = tempnam('/tmp/', 'ritsiGA-' . $title . '-'); unlink($filename); if ($zip->open($filename, ZIPARCHIVE::CREATE) !== true) { throw new \Exception("cannot open <{$filename}>\n"); } if (false === $zip->addEmptyDir($title)) { throw new \Exception("cannot add empty dir {$title}\n"); } $route_dir = $this->container->getParameter('kernel.root_dir'); foreach ($registrations as $registration) { $single_file = $route_dir . '/../private/documents/invoices/' . $registration->getId() . '.pdf'; if (false === file_exists($single_file)) { continue; } $name = $registration->getId(); if (false === $zip->addFile($single_file, implode('/', array($title, $name . '.pdf')))) { throw new \Exception("cannot add file\n"); } } if (false === $zip->close()) { throw new \Exception("cannot close <{$filename}>\n"); } $response = new BinaryFileResponse($filename); $response->trustXSendfileTypeHeader(); $response->prepare($request); $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $convention->getSlug() . '-facturas.zip', iconv('UTF-8', 'ASCII//TRANSLIT', $convention->getSlug() . '-facturas.zip')); return $response; }
/** * Returns the base url of a convention * * * @param Convention $convention * @return string */ public function conventionURL(Convention $convention) { $request = $this->requestStack->getCurrentRequest(); $domain = $convention->getDomain(); $url = str_replace('http://', '', $request->getUri()); $url_complete = "http://" . $domain . "." . $url; return $url_complete; }
public function onKernelRequest(GetResponseEvent $event) { $context = $this->router->getContext(); preg_match('/^\\/convention\\/([a-z]\\w+)/', $context->getPathInfo(), $matches); $code = isset($matches[1]) ? $matches[1] : $this->baseCode; if (!$context->hasParameter('code')) { $context->setParameter('code', $code); } if ($this->baseCode == $code) { $site = new Convention(); $site->setDomain('ritsi'); $this->siteManager->setCurrentSite($site); return; } $site = $this->em->getRepository('AppBundle:Convention')->findOneBy(array('domain' => $code)); if (!$site) { throw new NotFoundHttpException(sprintf('No site for code "%s"', $code)); } $this->siteManager->setCurrentSite($site); }
/** * @Given existen las asambleas: */ public function thereAreConventions(TableNode $tableNode) { foreach ($tableNode->getHash() as $conventionHash) { $convention = new Convention(); $convention->setName($conventionHash['nombre']); $convention->setStartsAt(new \DateTime($conventionHash['fechaInicio'])); $convention->setEndsAt(new \DateTime($conventionHash['fechaFin'])); $convention->setDomain($conventionHash['dominio']); $convention->setEmail($this->faker->email); $this->getEntityManager()->persist($convention); } $this->getEntityManager()->flush(); }
public function getQueryConvention(Convention $convention) { $qb = $this->createQueryBuilder('convention'); return $qb->where('convention.id=:id')->setParameter('id', $convention->getId()); }
/** * OrganizerRole constructor. * @param Convention $convention */ public function __construct(Convention $convention) { $this->role = 'ROLE_RITSIGA_ORGANIZER_' . strtoupper($convention->getDomain()); }
/** * OrganizerRole constructor. * * @param Convention $convention */ public function __construct(Convention $convention) { $this->role = 'ROLE_RITSIGA_ORGANIZER_' . $convention->getSlug(); $this->code = $convention->getSlug(); }