src/AppBundle/DependencyInjection/Compiler/ExtensionPass.php
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace AppBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\Reference;
class ExtensionPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
if (!$container->has('extension.manager')) {
return;
}
$managerDefinition = $container->findDefinition('extension.manager');
$collectorDefinition = $container->findDefinition('biz.service_provider.collector');
$taggedServices = $this->findSortTaggedServiceIds($container);
foreach ($taggedServices as $id => $tags) {
$def = $container->getDefinition($id);
if (is_subclass_of($def->getClass(), 'Pimple\ServiceProviderInterface')) {
$collectorDefinition->addMethodCall('add', array(new Reference($id)));
}
$managerDefinition->addMethodCall('addExtension', array(new Reference($id)));
}
}
/**
* sort service by priority asc
*
* @param ContainerBuilder $container
*
* @return array
*/
protected function findSortTaggedServiceIds(ContainerBuilder $container)
{
$taggedServices = $container->findTaggedServiceIds('extension');
ksort($taggedServices);
return $taggedServices;
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。