Skip to content

Commit bad960f

Browse files
authored
Merge branch 'symfony:2.x' into TurboResponse-generic-actions
2 parents 9e87c1c + bf3a0f0 commit bad960f

File tree

17 files changed

+106
-85
lines changed

17 files changed

+106
-85
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
src/LazyImage @Kocal
2+
src/Map @Kocal
3+
src/Translator @Kocal

src/Icons/src/Command/ImportIconCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6868
$io->comment(\sprintf('Importing %s...', $fullName));
6969

7070
try {
71-
$svg = $this->iconify->fetchSvg($prefix, $name);
71+
$iconSvg = $this->iconify->fetchIcon($prefix, $name)->toHtml();
7272
} catch (IconNotFoundException $e) {
7373
$io->error($e->getMessage());
7474
$result = Command::FAILURE;
@@ -79,7 +79,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7979
$cursor = new Cursor($output);
8080
$cursor->moveUp(2);
8181

82-
$this->registry->add(\sprintf('%s/%s', $prefix, $name), $svg);
82+
$this->registry->add(\sprintf('%s/%s', $prefix, $name), $iconSvg);
8383

8484
$license = $this->iconify->metadataFor($prefix)['license'];
8585

src/Icons/src/Command/LockIconsCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8181
}
8282

8383
try {
84-
$svg = $this->iconify->fetchSvg($prefix, $name);
84+
$iconSvg = $this->iconify->fetchIcon($prefix, $name)->toHtml();
8585
} catch (IconNotFoundException) {
8686
// icon not found on iconify
8787
if ($io->isVerbose()) {
@@ -90,7 +90,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9090
continue;
9191
}
9292

93-
$this->registry->add(\sprintf('%s/%s', $prefix, $name), $svg);
93+
$this->registry->add(\sprintf('%s/%s', $prefix, $name), $iconSvg);
9494

9595
$license = $this->iconify->metadataFor($prefix)['license'];
9696
++$count;

src/Icons/src/Iconify.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -85,25 +85,6 @@ public function fetchIcon(string $prefix, string $name): Icon
8585
]);
8686
}
8787

88-
public function fetchSvg(string $prefix, string $name): string
89-
{
90-
if (!isset($this->sets()[$prefix])) {
91-
throw new IconNotFoundException(\sprintf('The icon "%s:%s" does not exist on iconify.design.', $prefix, $name));
92-
}
93-
94-
$response = $this->http->request('GET', \sprintf('/%s/%s.svg', $prefix, $name));
95-
96-
if (200 !== $response->getStatusCode()) {
97-
throw new IconNotFoundException(\sprintf('The icon "%s:%s" does not exist on iconify.design.', $prefix, $name));
98-
}
99-
100-
if (!str_starts_with($svg = $response->getContent(), '<svg')) {
101-
throw new IconNotFoundException(\sprintf('The icon "%s:%s" does not exist on iconify.design.', $prefix, $name));
102-
}
103-
104-
return $svg;
105-
}
106-
10788
public function hasIconSet(string $prefix): bool
10889
{
10990
return isset($this->sets()[$prefix]);

src/Icons/tests/Unit/IconifyTest.php

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Symfony\Component\Cache\Adapter\NullAdapter;
1616
use Symfony\Component\HttpClient\MockHttpClient;
1717
use Symfony\Component\HttpClient\Response\JsonMockResponse;
18-
use Symfony\Component\HttpClient\Response\MockResponse;
1918
use Symfony\UX\Icons\Exception\IconNotFoundException;
2019
use Symfony\UX\Icons\Iconify;
2120

@@ -173,37 +172,6 @@ public function testGetMetadata(): void
173172
$this->assertSame('Font Awesome Solid', $metadata['name']);
174173
}
175174

176-
public function testFetchSvg(): void
177-
{
178-
$client = new MockHttpClient([
179-
new MockResponse(file_get_contents(__DIR__.'/../Fixtures/Iconify/collections.json'), [
180-
'response_headers' => ['content-type' => 'application/json'],
181-
]),
182-
new MockResponse(file_get_contents(__DIR__.'/../Fixtures/Iconify/icon.svg')),
183-
]);
184-
$iconify = new Iconify(new NullAdapter(), 'https://localhost', $client);
185-
186-
$svg = $iconify->fetchSvg('fa6-regular', 'bar');
187-
188-
$this->assertIsString($svg);
189-
$this->stringContains('-.224l.235-.468ZM6.013 2.06c-.649-.1', $svg);
190-
}
191-
192-
public function testFetchSvgThrowIconNotFoundExceptionWhenStatusCodeNot200(): void
193-
{
194-
$client = new MockHttpClient([
195-
new MockResponse(file_get_contents(__DIR__.'/../Fixtures/Iconify/collections.json'), [
196-
'response_headers' => ['content-type' => 'application/json'],
197-
]),
198-
new MockResponse('', ['http_code' => 404]),
199-
]);
200-
$iconify = new Iconify(new NullAdapter(), 'https://localhost', $client);
201-
202-
$this->expectException(IconNotFoundException::class);
203-
204-
$iconify->fetchSvg('fa6-regular', 'bar');
205-
}
206-
207175
private function createHttpClient(mixed $data, int $code = 200): MockHttpClient
208176
{
209177
$mockResponse = new JsonMockResponse($data, ['http_code' => $code]);

src/LiveComponent/doc/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ the user to switch the *entity* to another? For example:
620620

621621
<select data-model="post">
622622
{% for post in posts %}
623-
<option data-model="{{ post.id }}">{{ post.title }}</option>
623+
<option value="{{ post.id }}">{{ post.title }}</option>
624624
{% endfor %}
625625
</select>
626626

src/StimulusBundle/src/AssetMapper/ControllersMapGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private function loadCustomControllers(): array
7777
$name = str_replace(['_', '/', '\\'], ['-', '--', '--'], $name);
7878

7979
$asset = $this->assetMapper->getAssetFromSourcePath($file->getRealPath());
80-
$content = $asset->content ?: file_get_contents($asset->sourcePath);
80+
$content = file_get_contents($asset->sourcePath);
8181
$isLazy = preg_match('/\/\*\s*stimulusFetch:\s*\'lazy\'\s*\*\//i', $content);
8282

8383
$controllersMap[$name] = new MappedControllerAsset($asset, $isLazy);

src/StimulusBundle/tests/AssetMapper/ControllerMapGeneratorTest.php renamed to src/StimulusBundle/tests/AssetMapper/ControllersMapGeneratorTest.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use Symfony\UX\StimulusBundle\AssetMapper\MappedControllerAutoImport;
2121
use Symfony\UX\StimulusBundle\Ux\UxPackageReader;
2222

23-
class ControllerMapGeneratorTest extends TestCase
23+
class ControllersMapGeneratorTest extends TestCase
2424
{
2525
public function testGetControllersMap()
2626
{
@@ -41,7 +41,12 @@ public function testGetControllersMap()
4141
$logicalPath = substr($path, $assetsPosition + 1);
4242
}
4343

44-
return new MappedAsset($logicalPath, $path, content: file_get_contents($path));
44+
$content = null;
45+
if (str_ends_with($path, 'minified-controller.js')) {
46+
$content = 'import{Controller}from"@hotwired/stimulus";export default class extends Controller{}';
47+
}
48+
49+
return new MappedAsset($logicalPath, $path, content: $content);
4550
});
4651

4752
$packageReader = new UxPackageReader(__DIR__.'/../fixtures');
@@ -73,8 +78,8 @@ public function testGetControllersMap()
7378
$map = $generator->getControllersMap();
7479
// + 3 controller.json UX controllers
7580
// - 1 controllers.json UX controller is disabled
76-
// + 9 custom controllers (1 file is not a controller & 1 is overridden)
77-
$this->assertCount(11, $map);
81+
// + 10 custom controllers (1 file is not a controller & 1 is overridden)
82+
$this->assertCount(12, $map);
7883
$packageNames = array_keys($map);
7984
sort($packageNames);
8085
$this->assertSame([
@@ -84,6 +89,7 @@ public function testGetControllersMap()
8489
'hello',
8590
'hello-with-dashes',
8691
'hello-with-underscores',
92+
'minified',
8793
'other',
8894
'subdir--deeper',
8995
'subdir--deeper-with-dashes',
@@ -115,5 +121,8 @@ public function testGetControllersMap()
115121

116122
$otherController = $map['other'];
117123
$this->assertTrue($otherController->isLazy);
124+
125+
$minifiedController = $map['minified'];
126+
$this->assertTrue($minifiedController->isLazy);
118127
}
119128
}

src/StimulusBundle/tests/AssetMapper/StimulusControllerLoaderFunctionalTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ public function testFullApplicationLoad()
6363
// 2x from UX packages, which are enabled in controllers.json
6464
'/assets/fake-vendor/ux-package1/package-controller-second.js',
6565
'/assets/fake-vendor/ux-package2/package-hello-controller.js',
66-
// 2x from more-controllers
66+
// 3x from more-controllers
6767
'/assets/more-controllers/hello-controller.js',
68+
'/assets/more-controllers/minified-controller.js',
6869
'/assets/more-controllers/other-controller.js',
6970
// 5x from importmap.php
7071
'@hotwired/stimulus',
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// minified-controller.js
2+
import { Controller } from '@hotwired/stimulus';
3+
4+
/* stimulusFetch: 'lazy' */
5+
export default class extends Controller {
6+
}

0 commit comments

Comments
 (0)