From f7bab1b9902f3ae3c07ee5cd27505bc3034cbc2f Mon Sep 17 00:00:00 2001 From: Erol Uysal Date: Thu, 12 Sep 2019 19:13:17 +0300 Subject: [PATCH 1/5] added reference type to generate url --- Imagine/Cache/CacheManager.php | 37 +++++++++++++++++----------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/Imagine/Cache/CacheManager.php b/Imagine/Cache/CacheManager.php index b650a3e42..d7fe3e6e3 100644 --- a/Imagine/Cache/CacheManager.php +++ b/Imagine/Cache/CacheManager.php @@ -138,10 +138,11 @@ public function getRuntimePath($path, array $runtimeConfig) * @param string $filter The name of the imagine filter in effect * @param array $runtimeConfig * @param string $resolver + * @param string $referenceType The type of reference to be generated (one of the constants) * * @return string */ - public function generateUrl($path, $filter, array $runtimeConfig = [], $resolver = null) + public function generateUrl($path, $filter, array $runtimeConfig = [], $resolver = null, $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH) { $params = [ 'path' => ltrim($path, '/'), @@ -153,12 +154,12 @@ public function generateUrl($path, $filter, array $runtimeConfig = [], $resolver } if (empty($runtimeConfig)) { - $filterUrl = $this->router->generate('liip_imagine_filter', $params, UrlGeneratorInterface::ABSOLUTE_URL); + $filterUrl = $this->router->generate('liip_imagine_filter', $params, $referenceType); } else { $params['filters'] = $runtimeConfig; $params['hash'] = $this->signer->sign($path, $runtimeConfig); - $filterUrl = $this->router->generate('liip_imagine_filter_runtime', $params, UrlGeneratorInterface::ABSOLUTE_URL); + $filterUrl = $this->router->generate('liip_imagine_filter_runtime', $params, $referenceType); } return $filterUrl; @@ -206,21 +207,6 @@ public function resolve($path, $filter, $resolver = null) return $postEvent->getUrl(); } - /** - * BC Layer for Symfony < 4.3 - * - * @param CacheResolveEvent $event - * @param string $eventName - */ - private function dispatchWithBC(CacheResolveEvent $event, string $eventName): void - { - if ($this->dispatcher instanceof ContractsEventDispatcherInterface) { - $this->dispatcher->dispatch($event, $eventName); - } else { - $this->dispatcher->dispatch($eventName, $event); - } - } - /** * @see ResolverInterface::store * @@ -301,4 +287,19 @@ protected function getResolver($filter, $resolver) return $this->resolvers[$resolverName]; } + + /** + * BC Layer for Symfony < 4.3 + * + * @param CacheResolveEvent $event + * @param string $eventName + */ + private function dispatchWithBC(CacheResolveEvent $event, string $eventName): void + { + if ($this->dispatcher instanceof ContractsEventDispatcherInterface) { + $this->dispatcher->dispatch($event, $eventName); + } else { + $this->dispatcher->dispatch($eventName, $event); + } + } } From 4792e5952417468eb67c3efa2899ca35b9306648 Mon Sep 17 00:00:00 2001 From: Erol Uysal Date: Thu, 12 Sep 2019 19:23:42 +0300 Subject: [PATCH 2/5] revert cs fix --- Imagine/Cache/CacheManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Imagine/Cache/CacheManager.php b/Imagine/Cache/CacheManager.php index d7fe3e6e3..87cf04c42 100644 --- a/Imagine/Cache/CacheManager.php +++ b/Imagine/Cache/CacheManager.php @@ -292,7 +292,7 @@ protected function getResolver($filter, $resolver) * BC Layer for Symfony < 4.3 * * @param CacheResolveEvent $event - * @param string $eventName + * @param string $eventName */ private function dispatchWithBC(CacheResolveEvent $event, string $eventName): void { From bea2f4af551de14b96bf72434b2e1fcfc373f2e2 Mon Sep 17 00:00:00 2001 From: Erol Uysal Date: Thu, 12 Sep 2019 19:33:11 +0300 Subject: [PATCH 3/5] revert autofix --- Imagine/Cache/CacheManager.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Imagine/Cache/CacheManager.php b/Imagine/Cache/CacheManager.php index 87cf04c42..9fa37c6a3 100644 --- a/Imagine/Cache/CacheManager.php +++ b/Imagine/Cache/CacheManager.php @@ -207,6 +207,21 @@ public function resolve($path, $filter, $resolver = null) return $postEvent->getUrl(); } + /** + * BC Layer for Symfony < 4.3 + * + * @param CacheResolveEvent $event + * @param string $eventName + */ + private function dispatchWithBC(CacheResolveEvent $event, string $eventName): void + { + if ($this->dispatcher instanceof ContractsEventDispatcherInterface) { + $this->dispatcher->dispatch($event, $eventName); + } else { + $this->dispatcher->dispatch($eventName, $event); + } + } + /** * @see ResolverInterface::store * @@ -287,19 +302,4 @@ protected function getResolver($filter, $resolver) return $this->resolvers[$resolverName]; } - - /** - * BC Layer for Symfony < 4.3 - * - * @param CacheResolveEvent $event - * @param string $eventName - */ - private function dispatchWithBC(CacheResolveEvent $event, string $eventName): void - { - if ($this->dispatcher instanceof ContractsEventDispatcherInterface) { - $this->dispatcher->dispatch($event, $eventName); - } else { - $this->dispatcher->dispatch($eventName, $event); - } - } } From ed1a50e028873eef7559d3f0fc90f695395e1c8a Mon Sep 17 00:00:00 2001 From: Erol Uysal Date: Thu, 12 Sep 2019 19:39:54 +0300 Subject: [PATCH 4/5] fixes type --- Imagine/Cache/CacheManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Imagine/Cache/CacheManager.php b/Imagine/Cache/CacheManager.php index 9fa37c6a3..5f5d988b4 100644 --- a/Imagine/Cache/CacheManager.php +++ b/Imagine/Cache/CacheManager.php @@ -138,7 +138,7 @@ public function getRuntimePath($path, array $runtimeConfig) * @param string $filter The name of the imagine filter in effect * @param array $runtimeConfig * @param string $resolver - * @param string $referenceType The type of reference to be generated (one of the constants) + * @param int $referenceType The type of reference to be generated (one of the constants) * * @return string */ From c96ea0ff956b2bf99f889655500f10f27a3de0aa Mon Sep 17 00:00:00 2001 From: Erol Uysal Date: Mon, 16 Sep 2019 10:51:48 +0300 Subject: [PATCH 5/5] fix a few things. --- Imagine/Cache/CacheManager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Imagine/Cache/CacheManager.php b/Imagine/Cache/CacheManager.php index 5f5d988b4..3ecd88956 100644 --- a/Imagine/Cache/CacheManager.php +++ b/Imagine/Cache/CacheManager.php @@ -138,11 +138,11 @@ public function getRuntimePath($path, array $runtimeConfig) * @param string $filter The name of the imagine filter in effect * @param array $runtimeConfig * @param string $resolver - * @param int $referenceType The type of reference to be generated (one of the constants) + * @param int $referenceType The type of reference to be generated (one of the UrlGenerator constants) * * @return string */ - public function generateUrl($path, $filter, array $runtimeConfig = [], $resolver = null, $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH) + public function generateUrl($path, $filter, array $runtimeConfig = [], $resolver = null, $referenceType = UrlGeneratorInterface::ABSOLUTE_URL) { $params = [ 'path' => ltrim($path, '/'),