Skip to content

Commit 70b2688

Browse files
committed
feat: upgrade script, remove rector
1 parent d54801f commit 70b2688

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

SerializerAwareProviderInterface.php

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the API Platform project.
5+
*
6+
* (c) Kévin Dunglas <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace ApiPlatform\State;
15+
16+
use Psr\Container\ContainerInterface;
17+
18+
/**
19+
* Injects serializer in providers.
20+
*
21+
* @author Vincent Chalamon <[email protected]>
22+
*/
23+
interface SerializerAwareProviderInterface
24+
{
25+
public function setSerializerLocator(ContainerInterface $serializerLocator);
26+
}

SerializerAwareProviderTrait.php

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the API Platform project.
5+
*
6+
* (c) Kévin Dunglas <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace ApiPlatform\State;
15+
16+
use Psr\Container\ContainerInterface;
17+
use Symfony\Component\Serializer\SerializerInterface;
18+
19+
/**
20+
* Injects serializer in providers.
21+
*
22+
* @author Vincent Chalamon <[email protected]>
23+
*/
24+
trait SerializerAwareProviderTrait
25+
{
26+
/**
27+
* @internal
28+
*
29+
* @var ContainerInterface
30+
*/
31+
private $serializerLocator;
32+
33+
public function setSerializerLocator(ContainerInterface $serializerLocator): void
34+
{
35+
$this->serializerLocator = $serializerLocator;
36+
}
37+
38+
private function getSerializer(): SerializerInterface
39+
{
40+
return $this->serializerLocator->get('serializer');
41+
}
42+
}

0 commit comments

Comments
 (0)