Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lmammino/1165880 to your computer and use it in GitHub Desktop.
Save lmammino/1165880 to your computer and use it in GitHub Desktop.
Playing with Symfony2 services
<?php
namespace Oinm\ServiceBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;
/**
* This is the class that loads and manages your bundle configuration
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
*/
class ImageFilesystemStorageExtension extends Extension
{
/**
* {@inheritDoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('ImageFilesystemStorage.xml');
}
public function getAlias()
{
return "oinm_imagefilesystemstorage";
}
}
<?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">
<parameters>
<parameter key="oinm_imagefilesystemstorage.imagespath">%kernel.root_dir%/../web/images/</parameter>
<parameter key="oinm_imagestorage.relativebaseurl">images/</parameter>
<parameter key="oinm_imagestorage.absolutebaseurl"></parameter>
<parameter key="oinm_imagestorage.useabsoluteurls">false</parameter>
</parameters>
<services>
<service id="oinm_imagefilesystemstorage" class="Oinm\ServiceBundle\Service\Image\ImageFilesystemStorage">
<argument type="string">%oinm_imagefilesystemstorage.imagespath%</argument>
<argument type="string">%oinm_imagestorage.relativebaseurl%</argument>
<argument type="string">%oinm_imagestorage.absolutebaseurl%</argument>
<argument type="constant">%oinm_imagestorage.useabsoluteurls%</argument>
</service>
</services>
</container>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment