mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-29 21:48:45 +02:00
migration symfony 5 4 (#300)
* symfony 5.4 (diff dev) * symfony 5.4 (working) * symfony 5.4 (update autoload) * symfony 5.4 (remove swiftmailer mailer implementation) * symfony 5.4 (php doc and split Global accessor class) ### Impacted packages: composer require php:">=7.2.5 <8.0.0" symfony/console:5.4.* symfony/dotenv:5.4.* symfony/framework-bundle:5.4.* symfony/twig-bundle:5.4.* symfony/yaml:5.4.* --update-with-dependencies composer require symfony/stopwatch:5.4.* symfony/web-profiler-bundle:5.4.* --dev --update-with-dependencies
This commit is contained in:
@@ -11,9 +11,9 @@
|
||||
|
||||
namespace Symfony\Bridge\Twig\Extension;
|
||||
|
||||
use Fig\Link\GenericLinkProvider;
|
||||
use Fig\Link\Link;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\WebLink\GenericLinkProvider;
|
||||
use Symfony\Component\WebLink\Link;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\TwigFunction;
|
||||
|
||||
@@ -22,7 +22,7 @@ use Twig\TwigFunction;
|
||||
*
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
class WebLinkExtension extends AbstractExtension
|
||||
final class WebLinkExtension extends AbstractExtension
|
||||
{
|
||||
private $requestStack;
|
||||
|
||||
@@ -34,7 +34,7 @@ class WebLinkExtension extends AbstractExtension
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFunctions()
|
||||
public function getFunctions(): array
|
||||
{
|
||||
return [
|
||||
new TwigFunction('link', [$this, 'link']),
|
||||
@@ -49,15 +49,14 @@ class WebLinkExtension extends AbstractExtension
|
||||
/**
|
||||
* Adds a "Link" HTTP header.
|
||||
*
|
||||
* @param string $uri The relation URI
|
||||
* @param string $rel The relation type (e.g. "preload", "prefetch", "prerender" or "dns-prefetch")
|
||||
* @param array $attributes The attributes of this link (e.g. "['as' => true]", "['pr' => 0.5]")
|
||||
*
|
||||
* @return string The relation URI
|
||||
*/
|
||||
public function link($uri, $rel, array $attributes = [])
|
||||
public function link(string $uri, string $rel, array $attributes = []): string
|
||||
{
|
||||
if (!$request = $this->requestStack->getMasterRequest()) {
|
||||
if (!$request = $this->requestStack->getMainRequest()) {
|
||||
return $uri;
|
||||
}
|
||||
|
||||
@@ -75,12 +74,11 @@ class WebLinkExtension extends AbstractExtension
|
||||
/**
|
||||
* Preloads a resource.
|
||||
*
|
||||
* @param string $uri A public path
|
||||
* @param array $attributes The attributes of this link (e.g. "['as' => true]", "['crossorigin' => 'use-credentials']")
|
||||
* @param array $attributes The attributes of this link (e.g. "['as' => true]", "['crossorigin' => 'use-credentials']")
|
||||
*
|
||||
* @return string The path of the asset
|
||||
*/
|
||||
public function preload($uri, array $attributes = [])
|
||||
public function preload(string $uri, array $attributes = []): string
|
||||
{
|
||||
return $this->link($uri, 'preload', $attributes);
|
||||
}
|
||||
@@ -88,12 +86,11 @@ class WebLinkExtension extends AbstractExtension
|
||||
/**
|
||||
* Resolves a resource origin as early as possible.
|
||||
*
|
||||
* @param string $uri A public path
|
||||
* @param array $attributes The attributes of this link (e.g. "['as' => true]", "['pr' => 0.5]")
|
||||
* @param array $attributes The attributes of this link (e.g. "['as' => true]", "['pr' => 0.5]")
|
||||
*
|
||||
* @return string The path of the asset
|
||||
*/
|
||||
public function dnsPrefetch($uri, array $attributes = [])
|
||||
public function dnsPrefetch(string $uri, array $attributes = []): string
|
||||
{
|
||||
return $this->link($uri, 'dns-prefetch', $attributes);
|
||||
}
|
||||
@@ -101,12 +98,11 @@ class WebLinkExtension extends AbstractExtension
|
||||
/**
|
||||
* Initiates a early connection to a resource (DNS resolution, TCP handshake, TLS negotiation).
|
||||
*
|
||||
* @param string $uri A public path
|
||||
* @param array $attributes The attributes of this link (e.g. "['as' => true]", "['pr' => 0.5]")
|
||||
* @param array $attributes The attributes of this link (e.g. "['as' => true]", "['pr' => 0.5]")
|
||||
*
|
||||
* @return string The path of the asset
|
||||
*/
|
||||
public function preconnect($uri, array $attributes = [])
|
||||
public function preconnect(string $uri, array $attributes = []): string
|
||||
{
|
||||
return $this->link($uri, 'preconnect', $attributes);
|
||||
}
|
||||
@@ -114,12 +110,11 @@ class WebLinkExtension extends AbstractExtension
|
||||
/**
|
||||
* Indicates to the client that it should prefetch this resource.
|
||||
*
|
||||
* @param string $uri A public path
|
||||
* @param array $attributes The attributes of this link (e.g. "['as' => true]", "['pr' => 0.5]")
|
||||
* @param array $attributes The attributes of this link (e.g. "['as' => true]", "['pr' => 0.5]")
|
||||
*
|
||||
* @return string The path of the asset
|
||||
*/
|
||||
public function prefetch($uri, array $attributes = [])
|
||||
public function prefetch(string $uri, array $attributes = []): string
|
||||
{
|
||||
return $this->link($uri, 'prefetch', $attributes);
|
||||
}
|
||||
@@ -127,12 +122,11 @@ class WebLinkExtension extends AbstractExtension
|
||||
/**
|
||||
* Indicates to the client that it should prerender this resource .
|
||||
*
|
||||
* @param string $uri A public path
|
||||
* @param array $attributes The attributes of this link (e.g. "['as' => true]", "['pr' => 0.5]")
|
||||
* @param array $attributes The attributes of this link (e.g. "['as' => true]", "['pr' => 0.5]")
|
||||
*
|
||||
* @return string The path of the asset
|
||||
*/
|
||||
public function prerender($uri, array $attributes = [])
|
||||
public function prerender(string $uri, array $attributes = []): string
|
||||
{
|
||||
return $this->link($uri, 'prerender', $attributes);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user