-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Возможность заменить кэшер на любой другой.
- Loading branch information
Showing
5 changed files
with
63 additions
and
4 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
DependencyInjection/CompilerPass/ReplaceCacherCompilerPass.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,40 @@ | ||
<?php | ||
|
||
namespace Prokl\InstagramParserRapidApiBundle\DependencyInjection\CompilerPass; | ||
|
||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
/** | ||
* Class ReplaceCacherCompilerPass | ||
* | ||
* @since 21.07.2021 | ||
*/ | ||
class ReplaceCacherCompilerPass implements CompilerPassInterface | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public function process(ContainerBuilder $container): void | ||
{ | ||
$cacherService = $container->getParameter('instagram_parser_rapid_api.cacher'); | ||
|
||
if (!$cacherService) { | ||
return; | ||
} | ||
|
||
$destinationDefinitionParser = $container->getDefinition('instagram_parser_rapid_api.rapid_api'); | ||
$destinationDefinitionUserService = $container->getDefinition('instagram_parser_rapid_api.rapid_api_get_user_id'); | ||
|
||
if (!$container->hasDefinition($cacherService)) { | ||
throw new \RuntimeException( | ||
sprintf('Cacher service %s from parameter cacher_service not exist.', $cacherService) | ||
); | ||
} | ||
|
||
$cacherDefinition = $container->getDefinition($cacherService); | ||
|
||
$destinationDefinitionParser->replaceArgument(0, $cacherDefinition); | ||
$destinationDefinitionUserService->replaceArgument(0, $cacherDefinition); | ||
} | ||
} |
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
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