Permalink
Browse files

fixed service wiring

  • Loading branch information...
dustin10 committed Jan 28, 2012
1 parent 88ee3ef commit 25af55dd13a444be78270ba25f43918ac0091ca0
@@ -55,7 +55,10 @@ public function load(array $configs, ContainerBuilder $container)
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
- $toLoad = array('adapter.xml', 'listener.xml', 'uploader.xml', 'templating.xml', 'driver.xml', 'factory.xml');
+ $toLoad = array(
+ 'adapter.xml', 'listener.xml', 'storage.xml', 'injector.xml',
+ 'templating.xml', 'driver.xml', 'factory.xml'
+ );
foreach ($toLoad as $file) {
$loader->load($file);
}
@@ -34,7 +34,7 @@ public function __construct(Reader $reader)
*/
public function readUploadable(\ReflectionClass $class)
{
- return $this->reader->getClassAnnotation($class, 'Vich\UploaderBundle\Annotation\Uploadable');
+ return $this->reader->getClassAnnotation($class, 'Vich\UploaderBundle\Mapping\Annotation\Uploadable');
}
/**
@@ -48,7 +48,7 @@ public function readUploadableFields(\ReflectionClass $class)
$fields = array();
foreach ($class->getProperties() as $prop) {
- $field = $this->reader->getPropertyAnnotation($prop, 'Vich\UploaderBundle\Annotation\UploadableField');
+ $field = $this->reader->getPropertyAnnotation($prop, 'Vich\UploaderBundle\Mapping\Annotation\UploadableField');
if (null !== $field) {
$field->setPropertyName($prop->getName());
$fields[] = $field;
@@ -71,7 +71,7 @@ public function readUploadableField(\ReflectionClass $class, $field)
try {
$prop = $class->getProperty($field);
- $field = $this->reader->getPropertyAnnotation($prop, 'Vich\UploaderBundle\Annotation\UploadableField');
+ $field = $this->reader->getPropertyAnnotation($prop, 'Vich\UploaderBundle\Mapping\Annotation\UploadableField');
if (null === $field) {
return null;
}
@@ -4,6 +4,7 @@
use Vich\UploaderBundle\Injector\FileInjectorInterface;
use Vich\UploaderBundle\Mapping\PropertyMappingFactory;
+use Symfony\Component\HttpFoundation\File\File;
/**
* FileInjector.
@@ -35,7 +36,7 @@ public function injectFiles($obj)
$mappings = $this->factory->fromObject($obj);
foreach ($mappings as $mapping) {
if ($mapping->getInjectOnLoad()) {
- $name = $mapping->getFileNamePropety()->getValue();
+ $name = $mapping->getFileNameProperty()->getValue($obj);
if (is_null($name)) {
continue;
}
@@ -44,7 +45,7 @@ public function injectFiles($obj)
$mapping->getProperty()->setValue(
$obj,
- new \Symfony\Component\HttpFoundation\File\File($path, false)
+ new File($path, false)
);
}
}
@@ -3,14 +3,13 @@
<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.uploader" class="Vich\UploaderBundle\Upload\Uploader">
+
+ <service id="vich_uploader.file_injector" class="Vich\UploaderBundle\Injector\FileInjector">
<argument type="service" id="vich_uploader.property_mapping_factory" />
- <argument>%vich_uploader.web_dir_name%</argument>
</service>
-
+
</services>
-
+
</container>
@@ -9,7 +9,8 @@
<service id="vich_uploader.listener.uploader" class="Vich\UploaderBundle\EventListener\UploaderListener" public="false">
<argument type="service" id="vich_uploader.adapter" />
<argument type="service" id="vich_uploader.annotation_driver" />
- <argument type="service" id="vich_uploader.uploader" />
+ <argument type="service" id="vich_uploader.storage.file_system" />
+ <argument type="service" id="vich_uploader.file_injector" />
</service>
</services>
@@ -0,0 +1,15 @@
+<?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.file_system" class="Vich\UploaderBundle\Storage\FileSystemStorage">
+ <argument type="service" id="vich_uploader.property_mapping_factory" />
+ </service>
+
+ </services>
+
+</container>
@@ -8,7 +8,8 @@
<service id="vich_uploader.templating.helper.uploader_helper" class="Vich\UploaderBundle\Templating\Helper\UploaderHelper" public="false">
<tag name="templating.helper" alias="vich_uploader" />
- <argument type="service" id="vich_uploader.uploader" />
+ <argument type="service" id="vich_uploader.storage.file_system" />
+ <argument>%vich_uploader.web_dir_name%</argument>
</service>
</services>
View
@@ -121,7 +121,7 @@ namespace Acme\DemoBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraint as Assert;
-use Vich\UploaderBundle\Annotation as Vich;
+use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity
@@ -81,7 +81,7 @@ public function resolvePath($obj, $field)
return sprintf('%s/%s',
$mapping->getUploadDir(),
- $mapping->getFileNameProperty()->getValue()
+ $mapping->getFileNameProperty()->getValue($obj)
);
}
}

0 comments on commit 25af55d

Please sign in to comment.