Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

sf5 update #99

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions Command/DriverLockCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,28 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Command\Command;

/**
* Create a lock action
*
* @package LexikMaintenanceBundle
* @author Gilles Gauthier <[email protected]>
*/
class DriverLockCommand extends ContainerAwareCommand
class DriverLockCommand extends Command
{
protected $ttl;

/**
* return object of Queue
*
* @return object
* @package LexikMaintenanceBundleBundle
*/
public function setContainer($container){
$this->container = $container;
}

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -70,6 +80,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

$output->writeln('<info>'.$driver->getMessageLock($driver->lock()).'</info>');
return 0;
}

/**
Expand Down Expand Up @@ -137,7 +148,7 @@ function($value) use ($default) {
*/
private function getDriver()
{
return $this->getContainer()->get('lexik_maintenance.driver.factory')->getDriver();
return $this->container->get('lexik_maintenance.driver.factory')->getDriver();
}

/**
Expand Down
18 changes: 15 additions & 3 deletions Command/DriverUnlockCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,27 @@

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Command\Command;

/**
* Create an unlock action
*
* @package LexikMaintenanceBundle
* @author Gilles Gauthier <[email protected]>
*/
class DriverUnlockCommand extends ContainerAwareCommand
class DriverUnlockCommand extends Command
{

/**
* return object of Queue
*
* @return object
* @package LexikMaintenanceBundleBundle
*/
public function setContainer($container){
$this->container = $container;
}

/**
* {@inheritdoc}
*/
Expand All @@ -39,11 +50,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
return;
}

$driver = $this->getContainer()->get('lexik_maintenance.driver.factory')->getDriver();
$driver = $this->container->get('lexik_maintenance.driver.factory')->getDriver();

$unlockMessage = $driver->getMessageUnlock($driver->unlock());

$output->writeln('<info>'.$unlockMessage.'</info>');
return 0;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class Configuration implements ConfigurationInterface
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('lexik_maintenance');
$treeBuilder = new TreeBuilder('lexik_maintenance');
$rootNode = $treeBuilder->getRootNode();

$rootNode
->addDefaultsIfNotSet()
Expand Down
8 changes: 4 additions & 4 deletions Drivers/AbstractDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Lexik\Bundle\MaintenanceBundle\Drivers;

use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Translation\Translator;

/**
* Abstract class for drivers
Expand All @@ -18,7 +18,7 @@ abstract class AbstractDriver
protected $options;

/**
* @var TranslatorInterface
* @var Translator
*/
protected $translator;

Expand Down Expand Up @@ -122,9 +122,9 @@ public function getOptions()
/**
* Set translatorlator
*
* @param TranslatorInterface $translator
* @param Translator $translator
*/
public function setTranslator(TranslatorInterface $translator)
public function setTranslator(Translator $translator)
{
$this->translator = $translator;
}
Expand Down
2 changes: 1 addition & 1 deletion Drivers/DriverFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class DriverFactory
* @param array $driverOptions Options driver
* @throws \ErrorException
*/
public function __construct(DatabaseDriver $dbDriver, TranslatorInterface $translator, array $driverOptions)
public function __construct(DatabaseDriver $dbDriver, Translator $translator, array $driverOptions)
{
$this->driverOptions = $driverOptions;

Expand Down
12 changes: 6 additions & 6 deletions Listener/MaintenanceListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
use Lexik\Bundle\MaintenanceBundle\Exception\ServiceUnavailableException;

use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpFoundation\IpUtils;

/**
Expand Down Expand Up @@ -143,13 +143,13 @@ public function __construct(
}

/**
* @param GetResponseEvent $event GetResponseEvent
* @param RequestEvent $event RequestEvent
*
* @return void
*
* @throws ServiceUnavailableException
*/
public function onKernelRequest(GetResponseEvent $event)
public function onKernelRequest(RequestEvent $event)
{
if(!$event->isMasterRequest()){
return;
Expand Down Expand Up @@ -210,10 +210,10 @@ public function onKernelRequest(GetResponseEvent $event)
/**
* Rewrites the http code of the response
*
* @param FilterResponseEvent $event FilterResponseEvent
* @param ResponseEvent $event ResponseEvent
* @return void
*/
public function onKernelResponse(FilterResponseEvent $event)
public function onKernelResponse(ResponseEvent $event)
{
if ($this->handleResponse && $this->http_code !== null) {
$response = $event->getResponse();
Expand Down
6 changes: 6 additions & 0 deletions Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,16 @@

<service id="Lexik\Bundle\MaintenanceBundle\Command\DriverLockCommand" class="Lexik\Bundle\MaintenanceBundle\Command\DriverLockCommand">
<tag name="console.command"/>
<call method="setContainer">
<argument type="service" id="service_container" />
</call>
</service>

<service id="Lexik\Bundle\MaintenanceBundle\Command\DriverUnlockCommand" class="Lexik\Bundle\MaintenanceBundle\Command\DriverUnlockCommand">
<tag name="console.command"/>
<call method="setContainer">
<argument type="service" id="service_container" />
</call>
</service>
</services>
</container>
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
],
"require": {
"php": ">=5.3.9",
"symfony/framework-bundle": "~2.7|~3.0|^4.0",
"symfony/translation": "~2.7|~3.0|^4.0"
"symfony/framework-bundle": "~2.7|~3.0|^4.0|^5.0",
"symfony/translation": "~2.7|~3.0|^4.0|^5.0"
},
"require-dev": {
"symfony/phpunit-bridge": "~2.7|~3.0|^4.0",
"phpunit/phpunit": "~4.8|~5.7.11"
"symfony/phpunit-bridge": "~2.7|~3.0|^4.0|^5.0",
"phpunit/phpunit": "8.5.*"
},
"autoload": {
"psr-4": { "Lexik\\Bundle\\MaintenanceBundle\\": "" }
Expand Down