-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow specifying how a label should be supplied and read back on input (
#8) * Allow specifying how a label should be supplied and read back on input when using #[FromKey] * Fix nelmio incompatibility * Update method visibility * Update tests
- Loading branch information
Showing
36 changed files
with
493 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/DependencyInjection/Entity/CompilerPass/LabelProcessorCompilerPass.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace DualMedia\DtoRequestBundle\DependencyInjection\Entity\CompilerPass; | ||
|
||
use DualMedia\DtoRequestBundle\DtoBundle; | ||
use DualMedia\DtoRequestBundle\Service\Entity\LabelProcessorService; | ||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
class LabelProcessorCompilerPass implements CompilerPassInterface | ||
{ | ||
public function process( | ||
ContainerBuilder $container | ||
): void { | ||
// @codeCoverageIgnoreStart | ||
if (!$container->hasDefinition(LabelProcessorService::class)) { | ||
return; | ||
} | ||
// @codeCoverageIgnoreEnd | ||
|
||
$args = []; | ||
|
||
foreach ($container->findTaggedServiceIds(DtoBundle::LABEL_PROCESSOR_TAB) as $id => $tags) { | ||
$args[$id] = new Reference($id); | ||
} | ||
|
||
$container->getDefinition(LabelProcessorService::class)->setArgument(0, $args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace DualMedia\DtoRequestBundle\Exception\Entity; | ||
|
||
/** | ||
* Thrown when a label processor cannot be found for the specified service id | ||
*/ | ||
class LabelProcessorNotFoundException extends \RuntimeException | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace DualMedia\DtoRequestBundle\Interfaces\Entity; | ||
|
||
interface LabelProcessorInterface | ||
{ | ||
/** | ||
* Turns the label into a possible result key | ||
* | ||
* @param string $value | ||
* | ||
* @return string | ||
*/ | ||
public function normalize( | ||
string $value | ||
): string; | ||
|
||
/** | ||
* Turns the possible result key into a label | ||
* | ||
* @param string $value | ||
* | ||
* @return string | ||
*/ | ||
public function denormalize( | ||
string $value | ||
): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace DualMedia\DtoRequestBundle\Interfaces\Entity; | ||
|
||
interface LabelProcessorServiceInterface | ||
{ | ||
/** | ||
* @param string $service | ||
* @return LabelProcessorInterface | ||
*/ | ||
public function getProcessor( | ||
string $service | ||
): LabelProcessorInterface; | ||
} |
Oops, something went wrong.