Skip to content

Commit

Permalink
TE-5394 updated with master branch
Browse files Browse the repository at this point in the history
  • Loading branch information
bezpiatovs committed Sep 1, 2020
2 parents ccc7e2a + 80f02b9 commit 903367a
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

/**
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved.
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
*/

namespace SprykerShop\Yves\ShopApplication\Plugin\EventDispatcher;

use Spryker\Service\Container\ContainerInterface;
use Spryker\Shared\EventDispatcher\EventDispatcherInterface;
use Spryker\Shared\EventDispatcherExtension\Dependency\Plugin\EventDispatcherPluginInterface;
use Spryker\Yves\Kernel\AbstractPlugin;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;

/**
* @method \SprykerShop\Yves\ShopApplication\ShopApplicationFactory getFactory()
* @method \SprykerShop\Yves\ShopApplication\ShopApplicationConfig getConfig()
*/
class LastVisitCookieEventDispatcherPlugin extends AbstractPlugin implements EventDispatcherPluginInterface
{
protected const EVENT_PRIORITY = -255;
protected const COOKIE_NAME = 'last-visit';
protected const COOKIE_LIFETIME = 108000;

/**
* {@inheritDoc}
* - Adds a listener to handle cookie insertion with data about last time visit.
*
* @api
*
* @param \Spryker\Shared\EventDispatcher\EventDispatcherInterface $eventDispatcher
* @param \Spryker\Service\Container\ContainerInterface $container
*
* @return \Spryker\Shared\EventDispatcher\EventDispatcherInterface
*/
public function extend(EventDispatcherInterface $eventDispatcher, ContainerInterface $container): EventDispatcherInterface
{
$eventDispatcher->addListener(KernelEvents::RESPONSE, function (FilterResponseEvent $event): void {
$event->getResponse()->headers->setCookie(
(Cookie::create(static::COOKIE_NAME, (string)time(), time() + static::COOKIE_LIFETIME))
);
}, static::EVENT_PRIORITY);

return $eventDispatcher;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ShopApplicationServiceProvider extends AbstractPlugin implements ServicePr
/**
* @var \Spryker\Shared\Kernel\Communication\Application
*/
private $application;
protected $application;

/**
* @param \Spryker\Shared\Kernel\Communication\Application $app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
use Codeception\Actor;

/**
* Inherited Methods
*
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
Expand All @@ -21,15 +19,11 @@
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = null)
*
* @SuppressWarnings(PHPMD)
*/
class ShopApplicationYvesTester extends Actor
{
use _generated\ShopApplicationYvesTesterActions;

/**
* Define custom actions here
*/
}

0 comments on commit 903367a

Please sign in to comment.