Craft\NeoService::getStructure PHP Method

getStructure() public method

Returns the structure for a field.
public getStructure ( NeoFieldType $fieldType ) : craft\StructureModel | boolean
$fieldType NeoFieldType
return craft\StructureModel | boolean
    public function getStructure(NeoFieldType $fieldType)
    {
        $owner = $fieldType->element;
        $field = $fieldType->model;
        $locale = $this->_getFieldLocale($fieldType);
        $result = craft()->db->createCommand()->select('structureId')->from('neoblockstructures')->where('ownerId = :ownerId', [':ownerId' => $owner->id])->andWhere('fieldId = :fieldId', [':fieldId' => $field->id]);
        if ($locale) {
            $result = $result->andWhere('ownerLocale = :ownerLocale', [':ownerLocale' => $locale]);
        } else {
            $result = $result->andWhere('ownerLocale IS NULL');
        }
        $result = $result->queryRow();
        if ($result) {
            return craft()->structures->getStructureById($result['structureId']);
        }
        return false;
    }