Skip to content

@ftassi /StorageFactory.php secret
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Wiring up Symfony2 services in the DIC using configuration parameters
<?xml version="1.0" encoding="UTF-8" ?>
<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="vich_uploader.property_mapping_factory" class="Vich\UploaderBundle\Mapping\PropertyMappingFactory" public="false">
<argument type="service" id="service_container" />
<argument type="service" id="vich_uploader.annotation_driver" />
<argument type="service" id="vich_uploader.adapter" />
<argument>%vich_uploader.mappings%</argument>
</service>
<service id="vich_uploader.storage_factory" class="Vich\UploaderBundle\Storage\StorageFactory">
<argument type="service" id="service_container" />
</service>
</services>
</container>
<?xml version="1.0" encoding="UTF-8" ?>
<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="vich_uploader.storage.adapter.rackspace_cloud_files" class="Vich\UploaderBundle\Storage\Adapter\RackspaceCloudFilesAdapter">
<call method="setContainer">
<argument type="service" id="service_container" />
</call>
<call method="setMediaContainer">
<argument type="string">%vich_uploader.storage.adapter.rackspace.media_container%</argument>
</call>
</service>
<service id="vich_uploader.storage.file_system" class="Vich\UploaderBundle\Storage\FileSystemStorage">
<argument type="service" id="vich_uploader.property_mapping_factory" />
</service>
<service id="vich_uploader.storage.cdn" class="Vich\UploaderBundle\Storage\CDNStorage">
<argument type="service" id="vich_uploader.property_mapping_factory" />
<argument type="service" id="vich_uploader.storage.adapter.rackspace_cloud_files" />
</service>
<service
id="vich_uploader.storage"
class="Vich\UploaderBundle\Storage\StorageInterface"
factory-service="vich_uploader.storage_factory"
factory-method ="createStorage">
</service>
</services>
</container>
<?php
namespace Vich\UploaderBundle\Storage;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* StorageFactory
*
** @author Francesco Tassi <tassi.francesco@gmail.com>
*/
class StorageFactory
{
/**
*
* @var ContainerInterface
*/
protected $container;
/**
*
* @param ContainerInterface $container
*/
public function __construct(ContainerInterface $container)
{
$this->container = $container;
}
public function createStorage()
{
return $this->container->get($this->container->getParameter('vich_uploader.storage_service'));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.