Skip to content

Commit

Permalink
Merge pull request #97 from conferencetools/fix-hostname-routing
Browse files Browse the repository at this point in the history
Amended routing to enable hostname based prefixes, fixed issue with e…
  • Loading branch information
carnage authored Apr 8, 2018
2 parents 6f6e5f6 + e8cf9d2 commit c53c168
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 18 deletions.
2 changes: 1 addition & 1 deletion config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
],
\ConferenceTools\Tickets\Domain\Event\Ticket\TicketPurchasePaid::class => [
\ConferenceTools\Tickets\Domain\Projection\TicketRecord::class,
//\ConferenceTools\Tickets\EventListener\EmailPurchase::class,
\ConferenceTools\Tickets\EventListener\EmailPurchase::class,
],
\ConferenceTools\Tickets\Domain\Event\Ticket\DiscountCodeApplied::class => [
\ConferenceTools\Tickets\Domain\Projection\TicketRecord::class,
Expand Down
8 changes: 8 additions & 0 deletions config/routes.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

return [
'tickets' => [
'type' => \Zend\Mvc\Router\Http\Literal::class,
'options' => [
'route' => ''
],
'child_routes' => [
'purchasing' => [
'type' => 'Segment',
'options' => [
'route' => '/',
Expand Down Expand Up @@ -54,4 +60,6 @@
],
],
],
],
],
];
12 changes: 6 additions & 6 deletions src/Controller/TicketController.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function __construct(

public function indexAction()
{
return $this->redirect()->toRoute('tickets/select-tickets');
return $this->redirect()->toRoute('tickets/purchasing/select-tickets', [], ['force_canonical' => true]);
}

public function selectTicketsAction()
Expand Down Expand Up @@ -105,7 +105,7 @@ public function selectTicketsAction()
$this->getCommandBus()->dispatch($command);
/** @var TicketPurchaseCreated $event */
$event = $this->events()->getEventsByType(TicketPurchaseCreated::class)[0];
return $this->redirect()->toRoute('tickets/purchase', ['purchaseId' => $event->getId()]);
return $this->redirect()->toRoute('tickets/purchasing/purchase', ['purchaseId' => $event->getId()], ['force_canonical' => true]);
} catch (\DomainException $e) {
$this->flashMessenger()->addErrorMessage($e->getMessage());
}
Expand Down Expand Up @@ -191,12 +191,12 @@ public function purchaseAction()

if ($purchase === null || $purchase->hasTimedout()) {
$this->flashMessenger()->addErrorMessage('Purchase Id invalid or your purchase timed out');
return $this->redirect()->toRoute('tickets/select-tickets');
return $this->redirect()->toRoute('tickets/purchasing/select-tickets', [], ['force_canonical' => true]);
}

if ($purchase->isPaid()) {
$this->flashMessenger()->addInfoMessage('This purchase has already been paid for');
return $this->redirect()->toRoute('tickets/complete', ['purchaseId' => $purchaseId]);
return $this->redirect()->toRoute('tickets/purchasing/complete', ['purchaseId' => $purchaseId], ['force_canonical' => true]);
}

$form = new PurchaseForm($purchase);
Expand Down Expand Up @@ -235,7 +235,7 @@ public function purchaseAction()
'You will receive an email shortly with your receipt. ' .
'Tickets will be sent to the delegates shortly before the event'
);
return $this->redirect()->toRoute('tickets/complete', ['purchaseId' => $purchaseId]);
return $this->redirect()->toRoute('tickets/purchasing/complete', ['purchaseId' => $purchaseId], ['force_canonical' => true]);
} catch (CardErrorException $e) {
$this->flashMessenger()->addErrorMessage(
sprintf(
Expand Down Expand Up @@ -282,7 +282,7 @@ public function completeAction()

if ($purchase === null) {
$this->flashMessenger()->addErrorMessage('Purchase Id invalid');
return $this->redirect()->toRoute('tickets/select-tickets');
return $this->redirect()->toRoute('tickets/purchasing/select-tickets', [], ['force_canonical' => true]);
}

return new ViewModel(['purchase' => $purchase]);
Expand Down
4 changes: 2 additions & 2 deletions src/EventListener/EmailPurchaseFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace ConferenceTools\Tickets\EventListener;

use Zend\Mail\Transport\Factory;
use Zend\Mail\Transport\Smtp;
use Zend\Mail\Transport\SmtpOptions;
use Zend\ServiceManager\FactoryInterface;
Expand All @@ -13,8 +14,7 @@ public function createService(ServiceLocatorInterface $serviceLocator)
{
$serviceLocator = $serviceLocator->getServiceLocator();
$config = $serviceLocator->get('Config');
$options = new SmtpOptions($config['mail']);
$transport = new Smtp($options);
$transport = Factory::create($config['mail']);

return new EmailPurchase(
$serviceLocator->get('doctrine.entitymanager.orm_default'),
Expand Down
14 changes: 8 additions & 6 deletions view/email/receipt.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,16 @@
<table style="border-spacing: 0; border-collapse: collapse !important; color: #000 !important; text-shadow: none !important; background-color: transparent !important; -webkit-box-shadow: none !important; box-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; width: 100%; max-width: 100%; margin-bottom: 20px;" bgcolor="transparent !important">
<?php foreach($this->purchase->getTickets() as $ticket):?>
<?php $url = $this->url(
'tickets/manage',
['purchaseId' => $this->purchase->getPurchaseId(), 'ticketId' => $ticket->getTicketId()]
'tickets/purchasing/manage',
['purchaseId' => $this->purchase->getPurchaseId(), 'ticketId' => $ticket->getTicketId()],
['force_canonical' => true]
)?>
<tr style="color: #000 !important; text-shadow: none !important; background-color: transparent !important; -webkit-box-shadow: none !important; box-shadow: none !important; page-break-inside: avoid; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;" bgcolor="transparent !important">
<td style="color: #000 !important; text-shadow: none !important; background-color: #fff !important; -webkit-box-shadow: none !important; box-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; position: static; min-height: 1px; float: none; width: 50%; display: table-cell; padding: 0 15px;" bgcolor="#fff !important">
<?=$ticket->getTicketType()->getDisplayName()?>
</td>
<td style="color: #337ab7 !important; text-shadow: none !important; background-color: #fff !important; -webkit-box-shadow: none !important; box-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; position: static; min-height: 1px; float: none; width: 50%; display: table-cell; padding: 0 15px;" bgcolor="#fff !important">
<a href="<?= $this->serverUrl() . $url?>" style="background-color: transparent !important; color: #337ab7 !important; text-shadow: none !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-decoration: none; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;">Manage</a>
<a href="<?=$url?>" style="background-color: transparent !important; color: #337ab7 !important; text-shadow: none !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-decoration: none; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;">Manage</a>
</td>
</tr>
<?php endforeach;?>
Expand All @@ -145,10 +146,11 @@
</div>
</div>
<?php $url = $this->url(
'tickets/complete',
['purchaseId' => $this->purchase->getPurchaseId()]
'tickets/purchasing/complete',
['purchaseId' => $this->purchase->getPurchaseId()],
['force_canonical' => true]
)?>
Email broken? <a href="<?= $this->serverUrl() . $url?>" style="background-color: transparent !important; color: #337ab7 !important; text-shadow: none !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-decoration: none; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;">Click here to view in a browser</a>
Email broken? <a href="<?=$url?>" style="background-color: transparent !important; color: #337ab7 !important; text-shadow: none !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-decoration: none; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;">Click here to view in a browser</a>

</div>
</body>
Expand Down
7 changes: 4 additions & 3 deletions view/tickets/ticket/complete.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@
<table class="table">
<?php foreach($this->purchase->getTickets() as $ticket):?>
<?php $url = $this->url(
'tickets/manage',
['purchaseId' => $this->purchase->getPurchaseId(), 'ticketId' => $ticket->getTicketId()]
'tickets/purchasing/manage',
['purchaseId' => $this->purchase->getPurchaseId(), 'ticketId' => $ticket->getTicketId()],
['force_canonical' => true]
)?>
<tr>
<td class="col-xs-6">
<?=$ticket->getTicketType()->getDisplayName()?>
</td>
<td class="col-xs-6">
<?php if (!$ticket->getTicketType()->isSupplementary()): ?>
<a href="<?= $this->serverUrl() . $url?>">Manage</a>
<a href="<?=$url?>">Manage</a>
<?php endif;?>

</td>
Expand Down

0 comments on commit c53c168

Please sign in to comment.