Skip to content

[Icons] Icon changes #1665

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

Merged
merged 1 commit into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 2 additions & 12 deletions src/Icons/src/Svg/Icon.php → src/Icons/src/Icon.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
* file that was distributed with this source code.
*/

namespace Symfony\UX\Icons\Svg;
namespace Symfony\UX\Icons;

/**
* @author Simon André <[email protected]>
*
* @internal
*/
final class Icon implements \Stringable, \Serializable
final class Icon implements \Stringable
{
/**
* Transforms a valid icon ID into an icon name.
Expand Down Expand Up @@ -193,16 +193,6 @@ public function __toString(): string
return $this->toHtml();
}

public function serialize(): string
{
return serialize([$this->innerSvg, $this->attributes]);
}

public function unserialize(string $data): void
{
[$this->innerSvg, $this->attributes] = unserialize($data);
}

Comment on lines -196 to -205
Copy link
Member

Choose a reason for hiding this comment

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

Those methods were here for caching purposes no?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, but this is handled by __serialize/__unserialize IIUC.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's my understanding that the Serializable interface is being phased out.

public function __serialize(): array
{
return [$this->innerSvg, $this->attributes];
Expand Down
1 change: 0 additions & 1 deletion src/Icons/src/IconCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use Symfony\UX\Icons\Exception\IconNotFoundException;
use Symfony\UX\Icons\Registry\CacheIconRegistry;
use Symfony\UX\Icons\Svg\Icon;
use Symfony\UX\Icons\Twig\IconFinder;

/**
Expand Down
1 change: 0 additions & 1 deletion src/Icons/src/IconRegistryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Symfony\UX\Icons;

use Symfony\UX\Icons\Exception\IconNotFoundException;
use Symfony\UX\Icons\Svg\Icon;

/**
* @author Kevin Bond <[email protected]>
Expand Down
1 change: 0 additions & 1 deletion src/Icons/src/Iconify.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Symfony\Contracts\Cache\CacheInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use Symfony\UX\Icons\Exception\IconNotFoundException;
use Symfony\UX\Icons\Svg\Icon;

/**
* @author Kevin Bond <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion src/Icons/src/Registry/CacheIconRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

use Symfony\Contracts\Cache\CacheInterface;
use Symfony\UX\Icons\Exception\IconNotFoundException;
use Symfony\UX\Icons\Icon;
use Symfony\UX\Icons\IconRegistryInterface;
use Symfony\UX\Icons\Svg\Icon;

/**
* @author Kevin Bond <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion src/Icons/src/Registry/ChainIconRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
namespace Symfony\UX\Icons\Registry;

use Symfony\UX\Icons\Exception\IconNotFoundException;
use Symfony\UX\Icons\Icon;
use Symfony\UX\Icons\IconRegistryInterface;
use Symfony\UX\Icons\Svg\Icon;

/**
* @author Kevin Bond <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion src/Icons/src/Registry/IconifyOnDemandRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
namespace Symfony\UX\Icons\Registry;

use Symfony\UX\Icons\Exception\IconNotFoundException;
use Symfony\UX\Icons\Icon;
use Symfony\UX\Icons\Iconify;
use Symfony\UX\Icons\IconRegistryInterface;
use Symfony\UX\Icons\Svg\Icon;

/**
* @author Kevin Bond <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion src/Icons/src/Registry/LocalSvgIconRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

use Symfony\Component\Filesystem\Filesystem;
use Symfony\UX\Icons\Exception\IconNotFoundException;
use Symfony\UX\Icons\Icon;
use Symfony\UX\Icons\IconRegistryInterface;
use Symfony\UX\Icons\Svg\Icon;

/**
* @author Kevin Bond <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion src/Icons/tests/Unit/IconRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

use PHPUnit\Framework\TestCase;
use Symfony\UX\Icons\Exception\IconNotFoundException;
use Symfony\UX\Icons\Icon;
use Symfony\UX\Icons\IconRegistryInterface;
use Symfony\UX\Icons\IconRenderer;
use Symfony\UX\Icons\Svg\Icon;
use Symfony\UX\Icons\Tests\Util\InMemoryIconRegistry;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
* file that was distributed with this source code.
*/

namespace Symfony\UX\Icons\Tests\Unit\Svg;
namespace Symfony\UX\Icons\Tests\Unit;

use PHPUnit\Framework\TestCase;
use Symfony\UX\Icons\Svg\Icon;
use Symfony\UX\Icons\Icon;

final class IconTest extends TestCase
{
Expand Down Expand Up @@ -275,4 +275,11 @@ public static function provideWithAttributesTestCases(): iterable
['foo' => 'foobar', 'baz' => 'qux'],
];
}

public function testSerialize(): void
{
$icon = new Icon('foo', ['bar' => 'baz']);

$this->assertEquals($icon, unserialize(serialize($icon)));
}
}
2 changes: 1 addition & 1 deletion src/Icons/tests/Unit/Registry/InMemoryIconRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use PHPUnit\Framework\TestCase;
use Symfony\UX\Icons\Exception\IconNotFoundException;
use Symfony\UX\Icons\Svg\Icon;
use Symfony\UX\Icons\Icon;
use Symfony\UX\Icons\Tests\Util\InMemoryIconRegistry;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Icons/tests/Unit/Registry/LocalSvgIconRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
namespace Symfony\UX\Icons\Tests\Unit\Registry;

use PHPUnit\Framework\TestCase;
use Symfony\UX\Icons\Icon;
use Symfony\UX\Icons\Registry\LocalSvgIconRegistry;
use Symfony\UX\Icons\Svg\Icon;

/**
* @author Kevin Bond <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion src/Icons/tests/Util/InMemoryIconRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
namespace Symfony\UX\Icons\Tests\Util;

use Symfony\UX\Icons\Exception\IconNotFoundException;
use Symfony\UX\Icons\Icon;
use Symfony\UX\Icons\IconRegistryInterface;
use Symfony\UX\Icons\Svg\Icon;

/**
* @author Simon André <[email protected]>
Expand Down