Skip to content

Commit e950156

Browse files
committed
minor #1665 [Icons] Icon changes (kbond)
This PR was squashed before being merged into the 2.x branch. Discussion ---------- [Icons] `Icon` changes | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Issues | n/a | License | MIT 1. Removed `Serializable` from `Icon` (this isn't needed unless I'm mistaken) 2. I moved `Icon` up a level (this is a personal preference). `@smnandre` did you have plans for more classes in the `Svg` namespace? Commits ------- b8930e4 [Icons] `Icon` changes
2 parents a2f9a6b + b8930e4 commit e950156

13 files changed

+19
-25
lines changed

src/Icons/src/Svg/Icon.php renamed to src/Icons/src/Icon.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\UX\Icons\Svg;
12+
namespace Symfony\UX\Icons;
1313

1414
/**
1515
* @author Simon André <[email protected]>
1616
*
1717
* @internal
1818
*/
19-
final class Icon implements \Stringable, \Serializable
19+
final class Icon implements \Stringable
2020
{
2121
/**
2222
* Transforms a valid icon ID into an icon name.
@@ -193,16 +193,6 @@ public function __toString(): string
193193
return $this->toHtml();
194194
}
195195

196-
public function serialize(): string
197-
{
198-
return serialize([$this->innerSvg, $this->attributes]);
199-
}
200-
201-
public function unserialize(string $data): void
202-
{
203-
[$this->innerSvg, $this->attributes] = unserialize($data);
204-
}
205-
206196
public function __serialize(): array
207197
{
208198
return [$this->innerSvg, $this->attributes];

src/Icons/src/IconCacheWarmer.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Symfony\UX\Icons\Exception\IconNotFoundException;
1515
use Symfony\UX\Icons\Registry\CacheIconRegistry;
16-
use Symfony\UX\Icons\Svg\Icon;
1716
use Symfony\UX\Icons\Twig\IconFinder;
1817

1918
/**

src/Icons/src/IconRegistryInterface.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\UX\Icons;
1313

1414
use Symfony\UX\Icons\Exception\IconNotFoundException;
15-
use Symfony\UX\Icons\Svg\Icon;
1615

1716
/**
1817
* @author Kevin Bond <[email protected]>

src/Icons/src/Iconify.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Symfony\Contracts\Cache\CacheInterface;
1818
use Symfony\Contracts\HttpClient\HttpClientInterface;
1919
use Symfony\UX\Icons\Exception\IconNotFoundException;
20-
use Symfony\UX\Icons\Svg\Icon;
2120

2221
/**
2322
* @author Kevin Bond <[email protected]>

src/Icons/src/Registry/CacheIconRegistry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
use Symfony\Contracts\Cache\CacheInterface;
1515
use Symfony\UX\Icons\Exception\IconNotFoundException;
16+
use Symfony\UX\Icons\Icon;
1617
use Symfony\UX\Icons\IconRegistryInterface;
17-
use Symfony\UX\Icons\Svg\Icon;
1818

1919
/**
2020
* @author Kevin Bond <[email protected]>

src/Icons/src/Registry/ChainIconRegistry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
namespace Symfony\UX\Icons\Registry;
1313

1414
use Symfony\UX\Icons\Exception\IconNotFoundException;
15+
use Symfony\UX\Icons\Icon;
1516
use Symfony\UX\Icons\IconRegistryInterface;
16-
use Symfony\UX\Icons\Svg\Icon;
1717

1818
/**
1919
* @author Kevin Bond <[email protected]>

src/Icons/src/Registry/IconifyOnDemandRegistry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
namespace Symfony\UX\Icons\Registry;
1313

1414
use Symfony\UX\Icons\Exception\IconNotFoundException;
15+
use Symfony\UX\Icons\Icon;
1516
use Symfony\UX\Icons\Iconify;
1617
use Symfony\UX\Icons\IconRegistryInterface;
17-
use Symfony\UX\Icons\Svg\Icon;
1818

1919
/**
2020
* @author Kevin Bond <[email protected]>

src/Icons/src/Registry/LocalSvgIconRegistry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
use Symfony\Component\Filesystem\Filesystem;
1515
use Symfony\UX\Icons\Exception\IconNotFoundException;
16+
use Symfony\UX\Icons\Icon;
1617
use Symfony\UX\Icons\IconRegistryInterface;
17-
use Symfony\UX\Icons\Svg\Icon;
1818

1919
/**
2020
* @author Kevin Bond <[email protected]>

src/Icons/tests/Unit/IconRendererTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\UX\Icons\Exception\IconNotFoundException;
16+
use Symfony\UX\Icons\Icon;
1617
use Symfony\UX\Icons\IconRegistryInterface;
1718
use Symfony\UX\Icons\IconRenderer;
18-
use Symfony\UX\Icons\Svg\Icon;
1919
use Symfony\UX\Icons\Tests\Util\InMemoryIconRegistry;
2020

2121
/**

src/Icons/tests/Unit/Svg/IconTest.php renamed to src/Icons/tests/Unit/IconTest.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\UX\Icons\Tests\Unit\Svg;
12+
namespace Symfony\UX\Icons\Tests\Unit;
1313

1414
use PHPUnit\Framework\TestCase;
15-
use Symfony\UX\Icons\Svg\Icon;
15+
use Symfony\UX\Icons\Icon;
1616

1717
final class IconTest extends TestCase
1818
{
@@ -275,4 +275,11 @@ public static function provideWithAttributesTestCases(): iterable
275275
['foo' => 'foobar', 'baz' => 'qux'],
276276
];
277277
}
278+
279+
public function testSerialize(): void
280+
{
281+
$icon = new Icon('foo', ['bar' => 'baz']);
282+
283+
$this->assertEquals($icon, unserialize(serialize($icon)));
284+
}
278285
}

src/Icons/tests/Unit/Registry/InMemoryIconRegistryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\UX\Icons\Exception\IconNotFoundException;
16-
use Symfony\UX\Icons\Svg\Icon;
16+
use Symfony\UX\Icons\Icon;
1717
use Symfony\UX\Icons\Tests\Util\InMemoryIconRegistry;
1818

1919
/**

src/Icons/tests/Unit/Registry/LocalSvgIconRegistryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
namespace Symfony\UX\Icons\Tests\Unit\Registry;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\UX\Icons\Icon;
1516
use Symfony\UX\Icons\Registry\LocalSvgIconRegistry;
16-
use Symfony\UX\Icons\Svg\Icon;
1717

1818
/**
1919
* @author Kevin Bond <[email protected]>

src/Icons/tests/Util/InMemoryIconRegistry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
namespace Symfony\UX\Icons\Tests\Util;
1313

1414
use Symfony\UX\Icons\Exception\IconNotFoundException;
15+
use Symfony\UX\Icons\Icon;
1516
use Symfony\UX\Icons\IconRegistryInterface;
16-
use Symfony\UX\Icons\Svg\Icon;
1717

1818
/**
1919
* @author Simon André <[email protected]>

0 commit comments

Comments
 (0)