Esempio n. 1
0
 public function testMediaFactoryTransplantAdapter()
 {
     $result = Process::factory(['adapter' => new GenericMock(null), 'source' => 'image/jpeg']);
     $this->assertInstanceOf('\\mm\\Media\\Process\\Image', $result);
 }
Esempio n. 2
0
 /**
  * Converts the media to given MIME type.
  *
  * @param string $mimeType
  * @return boolean|object false on error or a Media object on success
  */
 public function convert($mimeType)
 {
     $this->_adapter->convert($mimeType);
     if ($this->name() != Type::guessName($mimeType)) {
         // Crosses media (i.e. document -> image).
         $config = Process::config();
         if ($config[$this->name()] == $config[Type::guessName($mimeType)]) {
             // ...but using the same adapter.
             $media = Process::factory(['source' => $mimeType, 'adapter' => $this->_adapter]);
         } else {
             // ...using different adapters.
             $handle = fopen('php://temp', 'w+');
             $this->_adapter->store($handle);
             $media = Process::factory(['source' => $handle]);
             fclose($handle);
         }
         return $media;
     }
     // Stays entirely in same media (i.e. image -> image).
     return $this;
 }