Skip to content

Commit

Permalink
FRW-19 Support Symfony packages v6. (#2280)
Browse files Browse the repository at this point in the history
FRW-19 Support Symfony v6
  • Loading branch information
geega authored Jan 24, 2023
1 parent b5785c5 commit 0d550ca
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
2 changes: 2 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ parameters:
- '#Comparison operation "<" between [1-9] and 3 is always (true|false).#'
- '#Method .+\\WidgetTagTwigPlugin::openWidgetContext\(\) should return .+\\WidgetInterface\|null but returns .+\\WidgetPluginInterface\|.+\\WidgetInterface\|null.#'
- '#Parameter \#2 \$string of function explode expects string, string\|false given.#'
- '#^Call to function method_exists\(\) with Symfony\\Component\\HttpKernel\\Event\\ViewEvent and#'
- '#Call to an undefined method Symfony\\Component\\HttpKernel\\Event\\ViewEvent\:\:isMainRequest\(\).#'
excludePaths:
- '%rootDir%/../../../vendor/spryker/spryker-shop/Bundles/ShopApplication/src/SprykerShop/Yves/ShopApplication/Plugin/AbstractTwigExtensionPlugin.php'
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(ControllerResolverInterface $controllerResolver, Cal
/**
* @inheritDoc
*/
public function getController(Request $request)
public function getController(Request $request): callable|false
{
$controller = $request->attributes->get('_controller', null);

Expand All @@ -52,14 +52,12 @@ public function getController(Request $request)
}

/**
* {@inheritDoc}
*
* @param \Symfony\Component\HttpFoundation\Request $request
* @param callable $controller
*
* @return array
*/
public function getArguments(Request $request, $controller)
public function getArguments(Request $request, callable $controller): array
{
if (method_exists($this->controllerResolver, 'getArguments')) {
return $this->controllerResolver->getArguments($request, $controller);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ protected function onKernelView(ViewEvent $event, SprykerApplication $applicatio
/** @var \Twig\Environment $twig */
$twig = $application['twig'];

if (!$event->isMasterRequest()) {
if (!$this->isMainRequest($event)) {
$masterGlobalView = $this->getGlobalView($twig);
}

Expand Down Expand Up @@ -230,4 +230,18 @@ protected function getViewParameters(ViewInterface $view): array

return [];
}

/**
* @param \Symfony\Component\HttpKernel\Event\ViewEvent $event
*
* @return bool
*/
protected function isMainRequest(ViewEvent $event): bool
{
if (method_exists($event, 'isMasterRequest')) {
return $event->isMasterRequest();
}

return $event->isMainRequest();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function onKernelView(ViewEvent $event): void
$masterGlobalView = null;

if ($result instanceof ViewInterface) {
if (!$event->isMasterRequest()) {
if (!$this->isMainRequest($event)) {
$masterGlobalView = $this->getGlobalView();
}

Expand Down Expand Up @@ -270,4 +270,18 @@ protected function addWidgetContainerRegister(WidgetContainerInterface $result):
{
$this->widgetContainerRegistry->add($result);
}

/**
* @param \Symfony\Component\HttpKernel\Event\ViewEvent $event
*
* @return bool
*/
protected function isMainRequest(ViewEvent $event): bool
{
if (method_exists($event, 'isMasterRequest')) {
return $event->isMasterRequest();
}

return $event->isMainRequest();
}
}

0 comments on commit 0d550ca

Please sign in to comment.