8000 Add a new Link component by dunglas · Pull Request #22273 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Add a new Link component #22273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix naming and CS
  • Loading branch information
dunglas committed Apr 10, 2017
commit aaa54c23130c0cbd9cc84445224d2799f7b66ff9
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"symfony/twig-bundle": "self.version",
"symfony/validator": "self.version",
"symfony/var-dumper": "self.version",
"symfony/web-link": "self.version",
"symfony/web-profiler-bundle": "self.version",
"symfony/web-server-bundle": "self.version",
"symfony/workflow": "self.version",
Expand Down
5 changes: 3 additions & 2 deletions src/Symfony/Bridge/Twig/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"symfony/console": "~2.8|~3.0",
"symfony/var-dumper": "~2.8.10|~3.1.4|~3.2",
"symfony/expression-language": "~2.8|~3.0",
"symfony/weblink": "~3.3"
"symfony/web-link": "~3.3"
},
"suggest": {
"symfony/finder": "",
Expand All @@ -49,7 +49,8 @@
"symfony/security": "For using the SecurityExtension",
"symfony/stopwatch": "For using the StopwatchExtension",
"symfony/var-dumper": "For using the DumpExtension",
"symfony/expression-language": "For using the ExpressionExtension"
"symfony/expression-language": "For using the ExpressionExtension",
"symfony/web-link": "For using the WebLinkExtension"
},
"autoload": {
"psr-4": { "Symfony\\Bridge\\Twig\\": "" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Form\Form;
use Symfony\Component\WebLink\WebLinkManagerInterface;
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Translation\Translator;
use Symfony\Component\Validator\Validation;
use Symfony\Component\WebLink\WebLinkManagerInterface;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this interface does not exist anymore


/**
* FrameworkExtension configuration structure.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
use Symfony\Bridge\Monolog\Processor\DebugProcessor;
use Symfony\Component\Cache\Adapter\AdapterInterface;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Config\Resource\DirectoryResource;
use Symfony\Component\Console\Application;
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand All @@ -28,17 +30,15 @@
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
use Symfony\Component\Finder\Finder;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\WebLink\WebLinkManagerInterface;
use Symfony\Component\PropertyAccess\PropertyAccessor;
use Symfony\Component\Serializer\Encoder\YamlEncoder;
use Symfony\Component\Serializer\Encoder\CsvEncoder;
use Symfony\Component\Serializer\Mapping\Factory\CacheClassMetadataFactory;
use Symfony\Component\Serializer\Normalizer\DataUriNormalizer;
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
use Symfony\Component\Serializer\Normalizer\JsonSerializableNormalizer;
use Symfony\Component\WebLink\WebLinkManagerInterface;
use Symfony\Component\Workflow;
use Symfony\Component\Console\Application;

/**
* FrameworkExtension.
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/FrameworkBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"symfony/workflow": "~3.3",
"symfony/yaml": "~3.2",
"symfony/property-info": "~3.3",
"symfony/weblink": "~3.3",
"symfony/web-link": "~3.3",
"doctrine/annotations": "~1.0",
"phpdocumentor/reflection-docblock": "^3.0",
"twig/twig": "~1.26|~2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/TwigBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"symfony/templating": "~2.8|~3.0",
"symfony/yaml": "~2.8|~3.0",
"symfony/framework-bundle": "^3.2.2",
"symfony/weblink": "~3.3",
"symfony/web-link": "~3.3",
"doctrine/annotations": "~1.0"
},
"conflict": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

namespace Symfony\Component\WebLink\EventListener;

use Symfony\Component\WebLink\HttpHeaderSerializer;
use Symfony\Component\WebLink\WebLinkManagerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\WebLink\HttpHeaderSerializer;
use Symfony\Component\WebLink\WebLinkManagerInterface;

/**
* Adds the Link HTTP header to the response.
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/WebLink/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
WebLink Component
=================

The Link component manages links between resources. It is particularly useful to advise clients
The WebLink component manages links between resources. It is particularly useful to advise clients
to preload and prefetch documents through HTTP and HTTP/2 pushes.

This component implements the [HTML5's Links](https://www.w3.org/TR/html5/links.html), [Preload](https://www.w3.org/TR/preload/)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ class HttpHeaderSerializerTest extends TestCase
*/
private $serializer;

protected function setUp() {
protected function setUp()
{
$this->serializer = new HttpHeaderSerializer();
}

public function testSerialize() {
public function testSerialize()
{
$linkProvider = new GenericLinkProvider(array(
new Link('prerender', '/1'),
(new Link('dns-prefetch', '/2'))->withAttribute('pr', 0.7),
Expand All @@ -39,7 +41,8 @@ public function testSerialize() {
$this->assertEquals('</1>; rel="prerender",</2>; rel="dns-prefetch"; pr="0.7",</3>; rel="preload"; as="script",</4>; rel="preload"; as="image"; nopush,</5>; rel="alternate next"; hreflang="fr"; hreflang="de"; title="Hello"', $this->serializer->serialize($linkProvider));
}

public function testSerializeEmpty() {
public function testSerializeEmpty()
{
$this->assertNull($this->serializer->serialize(new GenericLinkProvider()));
}
}
3 changes: 2 additions & 1 deletion src/Symfony/Component/WebLink/Tests/WebLinkManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public function testAdd()
$this->assertSame(array($link1, $link2), array_values($this->manager->getLinkProvider()->getLinks()));
}

public function testClear() {
public function testClear()
{
$this->manager->add($link1 = new Link());
$this->manager->add($link2 = new Link());

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/WebLink/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "symfony/weblink",
"name": "symfony/web-link",
"type": "library",
"description": "Symfony WebLink Component",
"keywords": ["link", "psr13", "http", "HTTP/2", "preload", "prefetch", "pre-render", "dns-prefetch", "push", "performance"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think pre-render here should be fixed to prerender?

Expand Down
0