예제 #1
0
 public function inject($obj, $mapping)
 {
     $mapping = $this->factory->fromName($obj, $mapping);
     $this->dispatch(Events::PRE_INJECT, new Event($obj, $mapping));
     $this->injector->injectFile($obj, $mapping);
     $this->dispatch(Events::POST_INJECT, new Event($obj, $mapping));
 }
예제 #2
0
 public function inject($obj, $fieldName)
 {
     $mapping = $this->getMapping($obj, $fieldName);
     $this->dispatch(Events::PRE_INJECT, new Event($obj, $mapping));
     $this->injector->injectFile($obj, $mapping);
     $this->dispatch(Events::POST_INJECT, new Event($obj, $mapping));
 }
 /**
  * Populates uploadable fields from filename properties
  * if necessary.
  *
  * @param \Doctrine\Common\EventArgs $args
  */
 public function postLoad(EventArgs $args)
 {
     $obj = $this->adapter->getObjectFromArgs($args);
     if ($this->isUploadable($obj)) {
         $this->injector->injectFiles($obj);
     }
 }
 /**
  * Test that postLoad skips non uploadable entity.
  */
 public function testPostLoadSkipsNonUploadable()
 {
     $obj = new DummyEntity();
     $class = new \ReflectionClass($obj);
     $args = $this->getMockBuilder('Doctrine\\Common\\EventArgs')->disableOriginalConstructor()->getMock();
     $this->adapter->expects($this->once())->method('getObjectFromArgs')->will($this->returnValue($obj));
     $this->adapter->expects($this->once())->method('getReflectionClass')->will($this->returnValue($class));
     $this->driver->expects($this->once())->method('readUploadable')->with($class)->will($this->returnValue(null));
     $this->injector->expects($this->never())->method('injectFiles');
     $listener = new UploaderListener($this->adapter, $this->driver, $this->storage, $this->injector);
     $listener->postLoad($args);
 }