eZ\Publish\Core\Persistence\Legacy\Content\Type\Mapper::toFieldDefinition PHP Method

toFieldDefinition() public method

Maps a FieldDefinition from the given $storageFieldDef.
public toFieldDefinition ( StorageFieldDefinition $storageFieldDef, eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition $fieldDef )
$storageFieldDef eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldDefinition
$fieldDef eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition
    public function toFieldDefinition(StorageFieldDefinition $storageFieldDef, FieldDefinition $fieldDef)
    {
        $converter = $this->converterRegistry->getConverter($fieldDef->fieldType);
        $converter->toFieldDefinition($storageFieldDef, $fieldDef);
    }

Usage Example

Esempio n. 1
0
 /**
  * @return void
  * @covers eZ\Publish\Core\Persistence\Legacy\Content\Type\Mapper::toFieldDefinition
  * @covers eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldDefinition
  */
 public function testToFieldDefinition()
 {
     $converterMock = $this->getMock('eZ\\Publish\\Core\\Persistence\\Legacy\\Content\\FieldValue\\Converter');
     $converterMock->expects($this->once())->method('toFieldDefinition')->with($this->isInstanceOf('eZ\\Publish\\Core\\Persistence\\Legacy\\Content\\StorageFieldDefinition'), $this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\Type\\FieldDefinition'));
     $converterRegistry = new ConverterRegistry(array('some_type' => $converterMock));
     $mapper = new Mapper($converterRegistry);
     $storageFieldDef = new StorageFieldDefinition();
     $fieldDef = new FieldDefinition();
     $fieldDef->fieldType = 'some_type';
     $mapper->toFieldDefinition($storageFieldDef, $fieldDef);
 }