Skip to content

Commit

Permalink
Symfony 5 (#7559)
Browse files Browse the repository at this point in the history
* Symfony 5

* fixed Translator issues

* Fixed AppAppKernelTestDebugContainer.xml path

* debug

* Stan: fixed path to app container XML file

* Stan: fixed path to app container XML file

* Stan: fixed reported issues

* Stan: fixed reported issues

* Stan: fixed reported issues

* Stan: fixed reported issues

* composer.json: minimum requirements

* composer.json: "symfony/swiftmailer-bundle": "^3.5.0"

* set symfony/symfony to 5.1.1, because of symfony/symfony#37056

* codeception/module-symfony: ^1.3.0"

* Removed DOS Routing loader

* composer.json: "codeception/phpunit-wrapper": "^7.8.1"
  • Loading branch information
brusch committed Nov 18, 2020
1 parent 0acbd02 commit f0019e7
Show file tree
Hide file tree
Showing 28 changed files with 82 additions and 139 deletions.
2 changes: 1 addition & 1 deletion .travis/phpstan.travis.neon
Expand Up @@ -6,4 +6,4 @@ parameters:
bootstrapFiles:
- phpstan-bootstrap.php
symfony:
container_xml_path: ../var/cache/test/appAppKernelTestDebugContainer.xml
container_xml_path: ../var/cache/test/AppKernelTestDebugContainer.xml
Expand Up @@ -20,18 +20,17 @@
use Pimcore\Bundle\AdminBundle\Security\Authentication\Token\PreAuthenticatedAdminToken;
use Pimcore\Bundle\AdminBundle\Security\User\User;
use Pimcore\Tool\Authentication;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Http\Firewall\ListenerInterface;

/**
* Checks if there's an existing admin session and stores its token on the security token storage.
*
* @package Pimcore\Bundle\AdminBundle\Security\Firewall
*/
class PreAuthenticatedAdminSessionListener implements ListenerInterface
class PreAuthenticatedAdminSessionListener
{
/**
* @var TokenStorageInterface
Expand Down Expand Up @@ -66,7 +65,7 @@ public function __construct(
/**
* @inheritDoc
*/
public function handle(GetResponseEvent $event)
public function __invoke(RequestEvent $event)
{
$request = $event->getRequest();

Expand Down
2 changes: 1 addition & 1 deletion bundles/CoreBundle/DataCollector/PimcoreDataCollector.php
Expand Up @@ -33,7 +33,7 @@ public function __construct(
$this->contextResolver = $contextResolver;
}

public function collect(Request $request, Response $response, \Exception $exception = null)
public function collect(Request $request, Response $response, ?\Throwable $exception = null)
{
$this->data = [
'version' => Version::getVersion(),
Expand Down
Expand Up @@ -56,7 +56,7 @@ public function getName()
return 'pimcore_targeting';
}

public function collect(Request $request, Response $response, \Exception $exception = null)
public function collect(Request $request, Response $response, ?\Throwable $exception = null)
{
$this->data = [];

Expand Down
Expand Up @@ -18,7 +18,6 @@
namespace Pimcore\Bundle\CoreBundle\DependencyInjection\Compiler;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

Expand Down Expand Up @@ -61,7 +60,7 @@ public function process(ContainerBuilder $container)
continue;
}

if ($reflector->isSubclassOf(AbstractController::class) || $reflector->isSubclassOf(Controller::class)) {
if ($reflector->isSubclassOf(AbstractController::class)) {
$serviceControllers[$id] = $definition->getClass();
}
}
Expand Down
Expand Up @@ -164,11 +164,11 @@ public function process(ContainerBuilder $container)
if ($workflowConfig['supports']) {
foreach ((array)$workflowConfig['supports'] as $supportedClassName) {
$strategyDefinition = new Definition(
Workflow\SupportStrategy\ClassInstanceSupportStrategy::class,
Workflow\SupportStrategy\InstanceOfSupportStrategy::class,
[$supportedClassName]
);
$strategyDefinition->setPublic(false);
$registryDefinition->addMethodCall('add', [new Reference($workflowId), $strategyDefinition]);
$registryDefinition->addMethodCall('addWorkflow', [new Reference($workflowId), $strategyDefinition]);
}
} elseif (isset($workflowConfig['support_strategy'])) {
$supportStrategyType = $workflowConfig['support_strategy']['type'] ?? null;
Expand All @@ -179,10 +179,10 @@ public function process(ContainerBuilder $container)
foreach ($workflowConfig['support_strategy']['arguments'] ?? [] as $argument) {
$supportStrategyDefinition->addArgument($argument);
}
$registryDefinition->addMethodCall('add', [new Reference($workflowId), $supportStrategyDefinition]);
$registryDefinition->addMethodCall('addWorkflow', [new Reference($workflowId), $supportStrategyDefinition]);
} elseif (isset($workflowConfig['support_strategy']['service'])) {
$registryDefinition->addMethodCall(
'add',
'addWorkflow',
[new Reference($workflowId), new Reference($workflowConfig['support_strategy']['service'])]
);
}
Expand Down
7 changes: 0 additions & 7 deletions bundles/CoreBundle/Resources/config/commands.yml
Expand Up @@ -67,13 +67,6 @@ services:
tags:
- { name: console.command, command: 'pimcore:bundle:uninstall' }

Pimcore\Bundle\CoreBundle\Command\Bundle\UpdateCommand:
arguments:
- '@Pimcore\Extension\Bundle\PimcoreBundleManager'
- '@Pimcore\Bundle\CoreBundle\Command\Bundle\Helper\PostStateChange'
tags:
- { name: console.command, command: 'pimcore:bundle:update' }

Pimcore\Bundle\CoreBundle\Command\ClassesRebuildCommand:
calls:
- [setClassDefinitionManager, ['@Pimcore\Model\DataObject\ClassDefinition\ClassDefinitionManager']]
Expand Down
6 changes: 3 additions & 3 deletions bundles/CoreBundle/Resources/config/pimcore/default.yml
Expand Up @@ -8,7 +8,7 @@ framework:
serializer:
enabled: true
router:
resource: "%kernel.root_dir%/config/routing.yml"
resource: "%kernel.project_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
Expand Down Expand Up @@ -252,13 +252,13 @@ pimcore:
app:
name: Migrations
namespace: App\Migrations
directory: "%kernel.root_dir%/Migrations"
directory: "%kernel.project_dir%/Migrations"

# this is the core migration set used for Composer post-package-update event
pimcore_core:
name: Pimcore Core Migrations
namespace: Pimcore\Bundle\CoreBundle\Migrations
directory: "%kernel.root_dir%/../vendor/pimcore/pimcore/bundles/CoreBundle/Migrations"
directory: "%kernel.project_dir%/../vendor/pimcore/pimcore/bundles/CoreBundle/Migrations"

sitemaps:
generators:
Expand Down
2 changes: 1 addition & 1 deletion bundles/CoreBundle/Resources/config/pimcore/dev.yml
@@ -1,6 +1,6 @@
framework:
router:
resource: "%kernel.root_dir%/config/routing_dev.yml"
resource: "%kernel.project_dir%/app/config/routing_dev.yml"
strict_requirements: true
profiler: { only_exceptions: false }

Expand Down
3 changes: 1 addition & 2 deletions bundles/CoreBundle/Resources/config/routing.yml
Expand Up @@ -24,8 +24,7 @@ _pimcore_service_thumbnail:
filename: '.*'

_fos_js_routing:
resource: .
type: fos_js_routing
resource: "@FOSJsRoutingBundle/Resources/config/routing/routing-sf4.xml"

# auto loads routes from all bundles in Resources/config/pimcore/routing.yml
_pimcore_bundle_auto:
Expand Down
6 changes: 1 addition & 5 deletions bundles/CoreBundle/Resources/config/routing_dev.yml
Expand Up @@ -4,8 +4,4 @@ _wdt:

_profiler:
resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
prefix: /_profiler

_errors:
resource: "@TwigBundle/Resources/config/routing/errors.xml"
prefix: /_error
prefix: /_profiler
5 changes: 0 additions & 5 deletions bundles/CoreBundle/Resources/config/services_routing.yml
Expand Up @@ -48,11 +48,6 @@ services:
tags:
- { name: routing.loader }

# routing loader for fos js routing routes
Pimcore\Routing\Loader\FOSJsRoutingLoader:
tags:
- { name: routing.loader }

# redirect handler used to handle redirects before/after routing
Pimcore\Routing\RedirectHandler:
calls:
Expand Down
15 changes: 8 additions & 7 deletions composer.json
Expand Up @@ -58,15 +58,15 @@
"doctrine/inflector": "^1.4.0 || ^2.0.0",
"egulias/email-validator": "^2.1.5",
"endroid/qr-code": "^3.4.4",
"friendsofsymfony/jsrouting-bundle": "^2.5",
"friendsofsymfony/jsrouting-bundle": "^2.6",
"geoip2/geoip2": "^2.9",
"google/apiclient": "^2.0",
"google/apiclient": "^2.8",
"guzzlehttp/guzzle": "^6.3",
"http-interop/http-factory-guzzle": "^1.0.0",
"lcobucci/jwt": "^3.2",
"league/csv": "^9.1",
"mjaschen/phpgeo": "^2.0",
"mpratt/embera": "^2.0.3",
"mpratt/embera": "^2.0.14",
"myclabs/deep-copy": "^1.7",
"neitanod/forceutf8": "^2.0.4",
"nesbot/carbon": "^1.34.0 || ^2.11.0",
Expand All @@ -80,10 +80,10 @@
"sensio/framework-extra-bundle": "^5.4",
"sensiolabs/ansi-to-html": "^1.1",
"symfony-cmf/routing-bundle": "^2.0",
"symfony/contracts": "^1.1",
"symfony/contracts": "^2.0",
"symfony/monolog-bundle": "^3.1.0",
"symfony/swiftmailer-bundle": "^3.2.2",
"symfony/symfony": "^4.4.12",
"symfony/swiftmailer-bundle": "^3.5.0",
"symfony/symfony": "^5.1.1",
"tijsverkoyen/css-to-inline-styles": "^2.2.1",
"twig/extensions": "^1.5",
"twig/twig": "^2.10",
Expand All @@ -107,7 +107,8 @@
"require-dev": {
"cache/integration-tests": "^0.16.0",
"codeception/codeception": "^4.1.12",
"codeception/module-symfony": "^1",
"codeception/module-symfony": "^1.3.0",
"codeception/phpunit-wrapper": "^7.8.1",
"phpstan/phpstan": "^0.12.53",
"phpstan/phpstan-symfony": "^0.12.11",
"phpunit/phpunit": "^7.5",
Expand Down
Expand Up @@ -217,7 +217,7 @@ To use the former handler use the following config:
framework:
session:
handler_id: session.handler.native_file
save_path: "%kernel.root_dir%/../var/sessions"
save_path: "%kernel.project_dir%/../var/sessions"
```
If you have configured your own session handler nothing will change.

Expand Down
8 changes: 8 additions & 0 deletions lib/Console/ConsoleOutputDecorator.php
Expand Up @@ -19,6 +19,7 @@

use Symfony\Component\Console\Formatter\OutputFormatterInterface;
use Symfony\Component\Console\Output\ConsoleOutputInterface;
use Symfony\Component\Console\Output\ConsoleSectionOutput;
use Symfony\Component\Console\Output\OutputInterface;

/**
Expand Down Expand Up @@ -117,4 +118,11 @@ public function setErrorOutput(OutputInterface $error)
{
$this->errorOutput = $error;
}

public function section(): ConsoleSectionOutput
{
$sections = [];
$stream = @fopen('php://stdout', 'w') ?: fopen('php://output', 'w');
return new ConsoleSectionOutput($stream, $sections, $this->getVerbosity(), $this->isDecorated(), $this->getFormatter());
}
}
2 changes: 2 additions & 0 deletions lib/HttpKernel/CacheWarmer/MkdirCacheWarmer.php
Expand Up @@ -71,5 +71,7 @@ public function warmUp($cacheDir)
$fs->mkdir($directory, $this->mode);
}
}

return [];
}
}
8 changes: 4 additions & 4 deletions lib/Image/Optimizer/AdvancedPngOptimizer.php
Expand Up @@ -14,8 +14,8 @@

namespace Pimcore\Image\Optimizer;

use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser;
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface;
use Symfony\Component\Mime\MimeTypeGuesserInterface;
use Symfony\Component\Mime\MimeTypes;

final class AdvancedPngOptimizer extends AbstractCommandOptimizer
{
Expand All @@ -26,7 +26,7 @@ final class AdvancedPngOptimizer extends AbstractCommandOptimizer

public function __construct()
{
$this->mimeTypeGuesser = MimeTypeGuesser::getInstance();
$this->mimeTypeGuesser = MimeTypes::getDefault();
}

/**
Expand All @@ -50,6 +50,6 @@ protected function getCommand(string $executable, string $input, string $output)
*/
public function supports(string $input): bool
{
return $this->mimeTypeGuesser->guess($input) === 'image/png';
return $this->mimeTypeGuesser->guessMimeType($input) === 'image/png';
}
}
8 changes: 4 additions & 4 deletions lib/Image/Optimizer/CjpegOptimizer.php
Expand Up @@ -14,8 +14,8 @@

namespace Pimcore\Image\Optimizer;

use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser;
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface;
use Symfony\Component\Mime\MimeTypeGuesserInterface;
use Symfony\Component\Mime\MimeTypes;

final class CjpegOptimizer extends AbstractCommandOptimizer
{
Expand All @@ -26,7 +26,7 @@ final class CjpegOptimizer extends AbstractCommandOptimizer

public function __construct()
{
$this->mimeTypeGuesser = MimeTypeGuesser::getInstance();
$this->mimeTypeGuesser = MimeTypes::getDefault();
}

/**
Expand All @@ -50,6 +50,6 @@ protected function getCommand(string $executable, string $input, string $output)
*/
public function supports(string $input): bool
{
return $this->mimeTypeGuesser->guess($input) === 'image/jpeg';
return $this->mimeTypeGuesser->guessMimeType($input) === 'image/jpeg';
}
}
8 changes: 4 additions & 4 deletions lib/Image/Optimizer/JpegoptimOptimizer.php
Expand Up @@ -14,8 +14,8 @@

namespace Pimcore\Image\Optimizer;

use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser;
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface;
use Symfony\Component\Mime\MimeTypeGuesserInterface;
use Symfony\Component\Mime\MimeTypes;

final class JpegoptimOptimizer extends AbstractCommandOptimizer
{
Expand All @@ -26,7 +26,7 @@ final class JpegoptimOptimizer extends AbstractCommandOptimizer

public function __construct()
{
$this->mimeTypeGuesser = MimeTypeGuesser::getInstance();
$this->mimeTypeGuesser = MimeTypes::getDefault();
}

/**
Expand Down Expand Up @@ -56,6 +56,6 @@ protected function getCommand(string $executable, string $input, string $output)
*/
public function supports(string $input): bool
{
return $this->mimeTypeGuesser->guess($input) === 'image/jpeg';
return $this->mimeTypeGuesser->guessMimeType($input) === 'image/jpeg';
}
}
8 changes: 4 additions & 4 deletions lib/Image/Optimizer/PngCrushOptimizer.php
Expand Up @@ -14,8 +14,8 @@

namespace Pimcore\Image\Optimizer;

use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser;
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface;
use Symfony\Component\Mime\MimeTypeGuesserInterface;
use Symfony\Component\Mime\MimeTypes;

final class PngCrushOptimizer extends AbstractCommandOptimizer
{
Expand All @@ -26,7 +26,7 @@ final class PngCrushOptimizer extends AbstractCommandOptimizer

public function __construct()
{
$this->mimeTypeGuesser = MimeTypeGuesser::getInstance();
$this->mimeTypeGuesser = MimeTypes::getDefault();
}

/**
Expand All @@ -50,6 +50,6 @@ protected function getCommand(string $executable, string $input, string $output)
*/
public function supports(string $input): bool
{
return $this->mimeTypeGuesser->guess($input) === 'image/png';
return $this->mimeTypeGuesser->guessMimeType($input) === 'image/png';
}
}
8 changes: 4 additions & 4 deletions lib/Image/Optimizer/PngOutOptimizer.php
Expand Up @@ -14,8 +14,8 @@

namespace Pimcore\Image\Optimizer;

use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser;
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface;
use Symfony\Component\Mime\MimeTypeGuesserInterface;
use Symfony\Component\Mime\MimeTypes;

final class PngOutOptimizer extends AbstractCommandOptimizer
{
Expand All @@ -26,7 +26,7 @@ final class PngOutOptimizer extends AbstractCommandOptimizer

public function __construct()
{
$this->mimeTypeGuesser = MimeTypeGuesser::getInstance();
$this->mimeTypeGuesser = MimeTypes::getDefault();
}

/**
Expand All @@ -50,6 +50,6 @@ protected function getCommand(string $executable, string $input, string $output)
*/
public function supports(string $input): bool
{
return $this->mimeTypeGuesser->guess($input) === 'image/png';
return $this->mimeTypeGuesser->guessMimeType($input) === 'image/png';
}
}

0 comments on commit f0019e7

Please sign in to comment.