-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DI compiler pass to register commonmark extension
- Loading branch information
Showing
3 changed files
with
52 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace Bcremer\Sculpin\Bundle\CommonMarkBundle\DependencyInjection\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
class CommonMarkExtensionPass implements CompilerPassInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
if (false === $container->hasDefinition('sculpin_commonmark.environment')) { | ||
return; | ||
} | ||
|
||
$definition = $container->getDefinition('sculpin_commonmark.environment'); | ||
|
||
foreach ($container->findTaggedServiceIds('sculpin_commonmark.extension') as $id => $attributes) { | ||
$definition->addMethodCall( | ||
'addExtension', | ||
[new Reference($id)] | ||
); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,9 +1,19 @@ | ||
<?php | ||
namespace Bcremer\Sculpin\Bundle\CommonMarkBundle; | ||
|
||
use Bcremer\Sculpin\Bundle\CommonMarkBundle\DependencyInjection\Compiler\CommonMarkExtensionPass; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\HttpKernel\Bundle\Bundle; | ||
|
||
class SculpinCommonMarkBundle extends Bundle | ||
{ | ||
const CONVERTER_NAME = 'commonmark'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function build(ContainerBuilder $container) | ||
{ | ||
$container->addCompilerPass(new CommonMarkExtensionPass()); | ||
} | ||
} |