Skip to content

Commit

Permalink
fixing deprecations in Symfony 4 headed (someday) toward symfony 5 refs
Browse files Browse the repository at this point in the history
  • Loading branch information
craigh committed Dec 16, 2019
1 parent 98c123d commit 5771fad
Show file tree
Hide file tree
Showing 40 changed files with 124 additions and 101 deletions.
45 changes: 32 additions & 13 deletions src/lib/Zikula/Bundle/CoreBundle/Command/AssetsInstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,41 @@
namespace Zikula\Bundle\CoreBundle\Command;

use InvalidArgumentException;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
use Zikula\Bundle\CoreBundle\HttpKernel\ZikulaHttpKernelInterface;

/**
* Command that places bundle web assets into a given directory.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class AssetsInstallCommand extends ContainerAwareCommand
class AssetsInstallCommand extends Command
{
/**
* @var Filesystem
*/
private $filesystem;

/**
* @var ZikulaHttpKernelInterface
*/
private $kernel;

public function __construct(
Filesystem $filesystem,
ZikulaHttpKernelInterface $kernel
) {
$this->filesystem = $filesystem;
$this->kernel = $kernel;
parent::__construct('assets:install');
}

protected function configure()
{
$this
Expand Down Expand Up @@ -72,34 +93,32 @@ protected function execute(InputInterface $input, OutputInterface $output)
if (!function_exists('symlink') && $input->getOption('symlink')) {
throw new InvalidArgumentException('The symlink() function is not available on your system. You need to install the assets without the --symlink option.');
}
$filesystem = $this->getContainer()->get('filesystem');
$kernel = $this->getContainer()->get('kernel');
$array = [
'bundle' => $kernel->getJustBundles(),
'module' => $kernel->getModules(),
'theme' => $kernel->getThemes(),
'bundle' => $this->kernel->getJustBundles(),
'module' => $this->kernel->getModules(),
'theme' => $this->kernel->getThemes(),
];
foreach ($array as $type => $bundles) {
// Create the bundles directory otherwise symlink will fail.
$filesystem->mkdir($targetArg . "/{$type}s/", 0777);
$this->filesystem->mkdir($targetArg . "/{$type}s/", 0777);
$output->writeln(sprintf('Installing assets using the <comment>%s</comment> option', $input->getOption('symlink') ? 'symlink' : 'hard copy'));
foreach ($bundles as $bundle) {
if (is_dir($originDir = $bundle->getPath() . '/Resources/public')) {
$bundlesDir = $targetArg . '/' . $type . 's/';
$targetDir = $bundlesDir . preg_replace('/' . $type . '$/', '', mb_strtolower($bundle->getName()));
$output->writeln(sprintf('Installing assets for <comment>%s</comment> into <comment>%s</comment>', $bundle->getNamespace(), $targetDir));
$filesystem->remove($targetDir);
$this->filesystem->remove($targetDir);
if ($input->getOption('symlink')) {
if ($input->getOption('relative')) {
$relativeOriginDir = $filesystem->makePathRelative($originDir, realpath($bundlesDir));
$relativeOriginDir = $this->filesystem->makePathRelative($originDir, realpath($bundlesDir));
} else {
$relativeOriginDir = $originDir;
}
$filesystem->symlink($relativeOriginDir, $targetDir);
$this->filesystem->symlink($relativeOriginDir, $targetDir);
} else {
$filesystem->mkdir($targetDir, 0777);
$this->filesystem->mkdir($targetDir, 0777);
// We use a custom iterator to ignore VCS files
$filesystem->mirror($originDir, $targetDir, Finder::create()->in($originDir));
$this->filesystem->mirror($originDir, $targetDir, Finder::create()->in($originDir));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,20 @@

namespace Zikula\Bundle\CoreBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Zikula\Bundle\CoreBundle\Bundle\Helper\BootstrapHelper;

class BootstrapBundlesCommand extends ContainerAwareCommand
class BootstrapBundlesCommand extends Command
{

/**
* @var BootstrapHelper
*/
private $bootstrapHelper;

protected function configure()
{
$this
Expand All @@ -37,12 +43,10 @@ protected function configure()

protected function execute(InputInterface $input, OutputInterface $output)
{
$helper = $this->getContainer()->get(BootstrapHelper::class);

if ($input->getArgument('create')) {
$helper->createSchema();
$this->bootstrapHelper->createSchema();
}

$helper->load();
$this->bootstrapHelper->load();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public function __construct(bool $debug)

public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('framework');
$treeBuilder = new TreeBuilder('framework');
$rootNode = $treeBuilder->getRootNode();
$this->addTranslatorSection($rootNode);

return $treeBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Gedmo\Blameable\BlameableListener;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Zikula\UsersModule\Constant;

Expand Down Expand Up @@ -66,7 +66,7 @@ public static function getSubscribedEvents()
];
}

public function onKernelRequest(GetResponseEvent $event): void
public function onKernelRequest(RequestEvent $event): void
{
try {
if (!$this->installed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace Zikula\Bundle\CoreBundle\EventListener;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;

/**
Expand Down Expand Up @@ -46,7 +46,7 @@ public static function getSubscribedEvents()
/**
* Sets x-origin headers in the response object.
*/
public function onKernelResponse(FilterResponseEvent $event): void
public function onKernelResponse(ResponseEvent $event): void
{
if (!$event->isMasterRequest()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

namespace Zikula\Bundle\CoreBundle\EventListener;

use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver;
use Doctrine\Persistence\Mapping\Driver\MappingDriver;
use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;

/**
* Event handler to set the default driver in the driver chain
Expand Down Expand Up @@ -49,7 +49,7 @@ public static function getSubscribedEvents()
];
}

public function setDefaultDriver(GetResponseEvent $event): void
public function setDefaultDriver(RequestEvent $event): void
{
/** @var $ORMConfig Configuration */
$ORMConfig = $this->entityManager->getConfiguration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
Expand Down Expand Up @@ -71,13 +71,13 @@ public static function getSubscribedEvents()
/**
* Handles exceptions.
*/
public function onKernelException(GetResponseForExceptionEvent $event): void
public function onKernelException(ExceptionEvent $event): void
{
if ($event->getRequest()->isXmlHttpRequest()) {
return;
}

$exception = $event->getException();
$exception = $event->getThrowable();
do {
$userLoggedIn = $this->installed ? $this->currentUserApi->isLoggedIn() : false;
if ($exception instanceof AccessDeniedException) {
Expand All @@ -92,7 +92,7 @@ public function onKernelException(GetResponseForExceptionEvent $event): void
*
* @see AccessDeniedException
*/
private function handleAccessDeniedException(GetResponseForExceptionEvent $event, bool $userLoggedIn, string $message = 'Access Denied'): void
private function handleAccessDeniedException(ExceptionEvent $event, bool $userLoggedIn, string $message = 'Access Denied'): void
{
$session = null !== $event->getRequest() && $event->getRequest()->hasSession()
&& null !== $event->getRequest()->getSession() ? $event->getRequest()->getSession() : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Zikula\Common\Translator\TranslatorInterface;
use Zikula\UsersModule\Api\ApiInterface\CurrentUserApiInterface;

Expand Down Expand Up @@ -48,6 +50,8 @@ class LoggerListener extends BaseListener

public function __construct(
LoggableListener $loggableListener,
TokenStorageInterface $tokenStorage,
AuthorizationCheckerInterface $authorizationChecker,
TranslatorInterface $translator,
CurrentUserApiInterface $currentUserApi,
bool $installed
Expand All @@ -56,6 +60,7 @@ public function __construct(
$this->translator = $translator;
$this->currentUserApi = $currentUserApi;
$this->installed = $installed;
parent::__construct($loggableListener, $tokenStorage, $authorizationChecker);
}

public static function getSubscribedEvents()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace Zikula\Bundle\CoreBundle\EventListener;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Zikula\ExtensionsModule\Api\ApiInterface\VariableApiInterface;

Expand Down Expand Up @@ -45,7 +45,7 @@ public static function getSubscribedEvents()
];
}

public function onKernelRequest(GetResponseEvent $event): void
public function onKernelRequest(RequestEvent $event): void
{
if (!$event->isMasterRequest()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\KernelEvents;

class SessionExpireListener implements EventSubscriberInterface
Expand All @@ -39,7 +39,7 @@ public static function getSubscribedEvents()
];
}

public function onKernelRequestSessionExpire(GetResponseEvent $event): void
public function onKernelRequestSessionExpire(RequestEvent $event): void
{
if (!$this->installed) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Exception;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Routing\RouterInterface;
use Twig\Environment;
Expand Down Expand Up @@ -82,7 +82,7 @@ public static function getSubscribedEvents()
];
}

public function onKernelRequestSiteOff(GetResponseEvent $event): void
public function onKernelRequestSiteOff(RequestEvent $event): void
{
if (!$event->isMasterRequest()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Zikula\Bundle\CoreBundle\HttpKernel\ZikulaKernel;
use Zikula\RoutesModule\Helper\MultilingualRoutingHelper;

Expand All @@ -34,7 +34,7 @@ public function __construct(ContainerInterface $container)
$this->container = $container;
}

public function onKernelRequest(GetResponseEvent $event): void
public function onKernelRequest(RequestEvent $event): void
{
if (!$event->isMasterRequest()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Zikula\Bundle\FormExtensionBundle\Event;

use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;
use Zikula\Bundle\FormExtensionBundle\FormTypesChoices;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Zikula/Bundle/HookBundle/Hook/Hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Zikula\Bundle\HookBundle\Hook;

use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;

/**
* Hook class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Zikula\Bundle\HookBundle\Dispatcher\Storage\Doctrine\Entity\RepositoryInterface\HookRuntimeRepositoryInterface;

Expand Down Expand Up @@ -57,9 +57,8 @@ public static function getSubscribedEvents()

/**
* Add dynamically assigned listeners to hookable events at runtime.
* @param GetResponseEvent $event
*/
public function addListeners(GetResponseEvent $event): void
public function addListeners(RequestEvent $event): void
{
if (!$this->installed || !$event->isMasterRequest()) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Zikula/Core/Event/ModuleStateEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Zikula\Core\Event;

use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;
use Zikula\Core\AbstractModule;

/**
Expand Down
6 changes: 1 addition & 5 deletions src/lib/Zikula/Core/Exception/FatalErrorException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,11 @@

namespace Zikula\Core\Exception;

use Symfony\Component\Debug\Exception\FatalErrorException as SymfonyFatalErrorException;
use Symfony\Component\ErrorHandler\Error\FatalError as SymfonyFatalErrorException;

/**
* Class FatalErrorException
*/
class FatalErrorException extends SymfonyFatalErrorException
{
public function __construct(string $message = 'Fatal Error!', int $code = 0, int $severity = 1, string $filename = __FILE__, int $lineno = __LINE__)
{
parent::__construct($message, $code, $severity, $filename, $lineno);
}
}

0 comments on commit 5771fad

Please sign in to comment.