Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 09f291f

Browse filesBrowse files
Remove ControllerEvent::addAttribute()
1 parent c567933 commit 09f291f
Copy full SHA for 09f291f

File tree

4 files changed

+1
-66
lines changed
Filter options

4 files changed

+1
-66
lines changed

‎src/Symfony/Component/HttpKernel/Event/ControllerArgumentsEvent.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Event/ControllerArgumentsEvent.php
-5Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,4 @@ public function getAttributes(): array
7373
{
7474
return $this->controllerEvent->getAttributes();
7575
}
76-
77-
public function addAttribute(object $attribute, bool $replace = false): void
78-
{
79-
$this->controllerEvent->addAttribute($attribute, $replace);
80-
}
8176
}

‎src/Symfony/Component/HttpKernel/Event/ControllerEvent.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Event/ControllerEvent.php
+1-12Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,21 +79,10 @@ public function getAttributes(): array
7979

8080
foreach (array_merge($class?->getAttributes() ?? [], $action->getAttributes()) as $attribute) {
8181
if (class_exists($attribute->getName())) {
82-
$this->addAttribute($attribute->newInstance());
82+
$this->attributes[$attribute->getName()][] = $attribute->newInstance();
8383
}
8484
}
8585

8686
return $this->attributes;
8787
}
88-
89-
public function addAttribute(object $attribute, bool $replace = false): void
90-
{
91-
if (!isset($this->attributes)) {
92-
$this->getAttributes();
93-
}
94-
if ($replace) {
95-
$this->attributes[$attribute::class] = [];
96-
}
97-
$this->attributes[$attribute::class][] = $attribute;
98-
}
9988
}

‎src/Symfony/Component/HttpKernel/Tests/Event/ControllerArgumentsEventTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/Event/ControllerArgumentsEventTest.php
-28Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\HttpFoundation\Request;
1616
use Symfony\Component\HttpKernel\Event\ControllerArgumentsEvent;
17-
use Symfony\Component\HttpKernel\Event\ControllerEvent;
1817
use Symfony\Component\HttpKernel\HttpKernelInterface;
19-
use Symfony\Component\HttpKernel\Tests\Fixtures\Attribute\Bar;
20-
use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\AttributeController;
2118
use Symfony\Component\HttpKernel\Tests\TestHttpKernel;
2219

2320
class ControllerArgumentsEventTest extends TestCase
@@ -36,29 +33,4 @@ public function testSetAttributes()
3633

3734
$this->assertSame([], $event->getAttributes());
3835
}
39-
40-
public function testGetAttributes()
41-
{
42-
$controller = new AttributeController();
43-
$request = new Request();
44-
45-
$controllerEvent = new ControllerEvent(new TestHttpKernel(), $controller, $request, HttpKernelInterface::MAIN_REQUEST);
46-
47-
$event = new ControllerArgumentsEvent(new TestHttpKernel(), $controllerEvent, ['test'], new Request(), HttpKernelInterface::MAIN_REQUEST);
48-
49-
$expected = [
50-
Bar::class => [
51-
new Bar('class'),
52-
new Bar('method'),
53-
],
54-
];
55-
56-
$this->assertEquals($expected, $event->getAttributes());
57-
58-
$event->addAttribute(new Bar('foo'));
59-
60-
$expected[Bar::class][] = new Bar('foo');
61-
$this->assertEquals($expected, $event->getAttributes());
62-
$this->assertSame($controllerEvent->getAttributes(), $event->getAttributes());
63-
}
6436
}

‎src/Symfony/Component/HttpKernel/Tests/Event/ControllerEventTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/Event/ControllerEventTest.php
-21Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,6 @@ public function testSetAttributes()
3232
$this->assertSame([], $event->getAttributes());
3333
}
3434

35-
public function testAddAttribute()
36-
{
37-
$request = new Request();
38-
$request->attributes->set('_controller_reflectors', [1, 2]);
39-
$controller = [new AttributeController(), 'action'];
40-
$event = new ControllerEvent(new TestHttpKernel(), $controller, $request, HttpKernelInterface::MAIN_REQUEST);
41-
42-
$expected = [Bar::class => [new Bar('class')]];
43-
$this->assertEquals($expected, $event->getAttributes());
44-
45-
$event->addAttribute(new Bar('class2'));
46-
47-
$expected[Bar::class][] = new Bar('class2');
48-
$this->assertEquals($expected, $event->getAttributes());
49-
50-
$event->addAttribute(new Bar('class3'), true);
51-
52-
$expected = [Bar::class => [new Bar('class3')]];
53-
$this->assertEquals($expected, $event->getAttributes());
54-
}
55-
5635
/**
5736
* @dataProvider provideGetAttributes
5837
*/

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.