Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add snippets for Dependency Injection #6

Merged
merged 1 commit into from
Apr 20, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions Snippets/DependencyInjection/configuration.sublime-snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<snippet>
<content><![CDATA[namespace ${1:VendorName}\\Bundle\\${2:BundleName}Bundle\\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
{
\$treeBuilder = new TreeBuilder();
\$rootNode = \$treeBuilder->root('${3:bundle_name}');

\$rootNode
->children()
->scalarNode('enabled')
->setInfo('Enable the container extension')
->setDefault(true)
->end()
->end()
;

return \$treeBuilder;
}
}
]]></content>
<tabTrigger>sfdiconfiguration</tabTrigger>
<scope>source.php</scope>
<description>Symfony2 / Dependency Injection / Configuration</description>
</snippet>
25 changes: 25 additions & 0 deletions Snippets/DependencyInjection/extension.sublime-snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<snippet>
<content><![CDATA[namespace ${1:VendorName}\\Bundle\\${2:BundleName}Bundle\\DependencyInjection;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\Config\FileLocator;

class ${2:BundleName}Extension extends Extension
{
public function load(array \$configs, ContainerBuilder \$container)
{
\$config = \$this->processConfiguration(new Configuration(), \$configs);
if (false === \$config['enabled']) {
return;
}

\$loader = new XmlFileLoader(\$container, new FileLocator(__DIR__.'/../Resources/config'));
\$loader->load('services.xml');
}
}
]]></content>
<tabTrigger>sfdiextension</tabTrigger>
<scope>source.php</scope>
<description>Symfony2 / Dependency Injection / Extension</description>
</snippet>
15 changes: 15 additions & 0 deletions Snippets/DependencyInjection/services.sublime-snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<snippet>
<content><![CDATA[<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<service id="${1:id}" class="${2:class}" />
</services>
</container>
]]></content>
<tabTrigger>sfdiservices</tabTrigger>
<description>Symfony2 / Dependency Injection / Service file</description>
</snippet>