public function getFieldById(ContentTypeInterface $contentType, $fieldId)
    {
        $field = $this->om->getRepository($this->configurationManager->getEntityClass('field'))->find($fieldId);


        if (!$field instanceof FieldInterface) {
            return null;
        }
        if ($field->getContentType() && $field->getContentType()->getId() == $contentType->getId()) {
            return $field;
        }

        $parent = $field;
        while ($parent && $parentLayout = $parent->getLayout()) {
            if ($parent = $parentLayout->getParent()) {
                if ($parent->getContentType() !== null && $parent->getContentType()->getId() == $contentType->getId()) {
                    return $field;
                }
            }
        }

        return null;
    }
public function getFieldById(ContentTypeInterface $contentType, $fieldId)
    {
        $field = $this->om->getRepository($this->configurationManager->getEntityClass('field'))->find($fieldId);


        if (!$field instanceof FieldInterface) {
            return null;
        }
        if ($field->getContentType() && $field->getContentType()->getId() == $contentType->getId()) {
            return $field;
        }

        $parent = $field;
        while ($parent && $parentLayout = $parent->getLayout()) {
            if ($parent = $parentLayout->getParent()) {
                if ($parent->getContentType() !== null && $parent->getContentType()->getId() == $contentType->getId()) {
                    return $field;
                }
            }
        }

        return null;
    }
public function getFieldById ( ContentTypeInterface $ contentType , $ fieldId ) { $ field = $ this -> om -> getRepository ( $ this -> configurationManager -> getEntityClass ( 'field' ) ) -> find ( $ fieldId ) ; if ( ! $ field instanceof FieldInterface ) { return null ; } if ( $ field -> getContentType ( ) && $ field -> getContentType ( ) -> getId ( ) == $ contentType -> getId ( ) ) { return $ field ; } $ parent = $ field ; while ( $ parent && $ parentLayout = $ parent -> getLayout ( ) ) { if ( $ parent = $ parentLayout -> getParent ( ) ) { if ( $ parent -> getContentType ( ) !== null && $ parent -> getContentType ( ) -> getId ( ) == $ contentType -> getId ( ) ) { return $ field ; } } } return null ; }
Get field matching slug

@param ContentTypeInterface $contentType
@param int                  $fieldId

@return FieldInterface|null
Get field matching slug