eZ\Publish\Core\REST\Client\Values\ContentType\ContentType::getFieldDefinition PHP Method

getFieldDefinition() public method

This method returns the field definition for the given identifier.
public getFieldDefinition ( string $fieldDefinitionIdentifier ) : FieldDefinition
$fieldDefinitionIdentifier string
return FieldDefinition
    public function getFieldDefinition($fieldDefinitionIdentifier)
    {
        $fieldDefinitions = $this->getFieldDefinitions();
        foreach ($fieldDefinitions as $fieldDefinition) {
            if ($fieldDefinition->identifier === $fieldDefinitionIdentifier) {
                return $fieldDefinition;
            }
        }
        return null;
    }

Usage Example

Esempio n. 1
0
 public function testGetFieldDefinitionFailure()
 {
     $contentType = new ContentType($this->contentTypeServiceMock, array('fieldDefinitionListReference' => '/content/types/23/fieldDefinitions'));
     $contentTypeServiceMock = $this->contentTypeServiceMock;
     $contentTypeServiceMock->expects($this->once())->method('loadFieldDefinitionList')->with($this->equalTo('/content/types/23/fieldDefinitions'))->will($this->returnValue($this->getFieldDefinitionListMock()));
     $this->assertEquals(null, $contentType->getFieldDefinition('non-existent'));
 }