eZ\Publish\Core\FieldType\Image\IO\Legacy::loadBinaryFileByUri PHP Метод

loadBinaryFileByUri() публичный Метод

Since both services should use the same uri, we can use any of them to *GET* the URI.
public loadBinaryFileByUri ( $binaryFileUri )
    public function loadBinaryFileByUri($binaryFileUri)
    {
        try {
            return $this->publishedIOService->loadBinaryFileByUri($binaryFileUri);
        } catch (InvalidArgumentException $prefixException) {
            // InvalidArgumentException means that the prefix didn't match, NotFound can pass through
            try {
                return $this->draftIOService->loadBinaryFileByUri($binaryFileUri);
            } catch (InvalidArgumentException $e) {
                throw $prefixException;
            }
        }
    }

Usage Example

Пример #1
0
 public function testLoadBinaryFileByUriWithDraftFile()
 {
     $binaryFileUri = 'var/test/images-versioned/an/image.png';
     $binaryFile = new BinaryFile(array('id' => 'an/image.png'));
     $this->publishedIoServiceMock->expects($this->once())->method('loadBinaryFileByUri')->with($binaryFileUri)->will($this->throwException(new InvalidArgumentException('$id', "Prefix not found in {$binaryFile->id}")));
     $this->draftIoServiceMock->expects($this->once())->method('loadBinaryFileByUri')->with($binaryFileUri)->will($this->returnValue($binaryFile));
     self::assertSame($binaryFile, $this->service->loadBinaryFileByUri($binaryFileUri));
 }