public function getBlockTypeFields(): array
    {
        if ($this->_blockTypeFields !== null) {
            return $this->_blockTypeFields;
        }

        if (empty($blockTypes = $this->getBlockTypes())) {
            return $this->_blockTypeFields = [];
        }

        // Get the fields & layout IDs
        $contexts = [];
        $layoutIds = [];
        foreach ($blockTypes as $blockType) {
            $contexts[] = 'superTableBlockType:' . $blockType->uid;
            $layoutIds[] = $blockType->fieldLayoutId;
        }

        /** @var Field[] $fieldsById */
        $fieldsById = ArrayHelper::index(Craft::$app->getFields()->getAllFields($contexts), 'id');

        // Get all the field IDs grouped by layout ID
        $fieldIdsByLayoutId = Craft::$app->getFields()->getFieldIdsByLayoutIds($layoutIds);

        // Assemble the fields
        $this->_blockTypeFields = [];

        foreach ($blockTypes as $blockType) {
            if (isset($fieldIdsByLayoutId[$blockType->fieldLayoutId])) {
                $fieldColumnPrefix = 'field_';

                foreach ($fieldIdsByLayoutId[$blockType->fieldLayoutId] as $fieldId) {
                    if (isset($fieldsById[$fieldId])) {
                        $fieldsById[$fieldId]->columnPrefix = $fieldColumnPrefix;
                        $this->_blockTypeFields[] = $fieldsById[$fieldId];
                    }
                }
            }
        }

        return $this->_blockTypeFields;
    }
public function getBlockTypeFields(): array
    {
        if ($this->_blockTypeFields !== null) {
            return $this->_blockTypeFields;
        }

        if (empty($blockTypes = $this->getBlockTypes())) {
            return $this->_blockTypeFields = [];
        }

        // Get the fields & layout IDs
        $contexts = [];
        $layoutIds = [];
        foreach ($blockTypes as $blockType) {
            $contexts[] = 'superTableBlockType:' . $blockType->uid;
            $layoutIds[] = $blockType->fieldLayoutId;
        }

        /** @var Field[] $fieldsById */
        $fieldsById = ArrayHelper::index(Craft::$app->getFields()->getAllFields($contexts), 'id');

        // Get all the field IDs grouped by layout ID
        $fieldIdsByLayoutId = Craft::$app->getFields()->getFieldIdsByLayoutIds($layoutIds);

        // Assemble the fields
        $this->_blockTypeFields = [];

        foreach ($blockTypes as $blockType) {
            if (isset($fieldIdsByLayoutId[$blockType->fieldLayoutId])) {
                $fieldColumnPrefix = 'field_';

                foreach ($fieldIdsByLayoutId[$blockType->fieldLayoutId] as $fieldId) {
                    if (isset($fieldsById[$fieldId])) {
                        $fieldsById[$fieldId]->columnPrefix = $fieldColumnPrefix;
                        $this->_blockTypeFields[] = $fieldsById[$fieldId];
                    }
                }
            }
        }

        return $this->_blockTypeFields;
    }
public function getBlockTypeFields ( ) : array { if ( $ this -> _blockTypeFields !== null ) { return $ this -> _blockTypeFields ; } if ( empty ( $ blockTypes = $ this -> getBlockTypes ( ) ) ) { return $ this -> _blockTypeFields = [ ] ; } // Get the fields & layout IDs $ contexts = [ ] ; $ layoutIds = [ ] ; foreach ( $ blockTypes as $ blockType ) { $ contexts [ ] = 'superTableBlockType:' . $ blockType -> uid ; $ layoutIds [ ] = $ blockType -> fieldLayoutId ; } /** @var Field[] $fieldsById */ $ fieldsById = ArrayHelper :: index ( Craft :: $ app -> getFields ( ) -> getAllFields ( $ contexts ) , 'id' ) ; // Get all the field IDs grouped by layout ID $ fieldIdsByLayoutId = Craft :: $ app -> getFields ( ) -> getFieldIdsByLayoutIds ( $ layoutIds ) ; // Assemble the fields $ this -> _blockTypeFields = [ ] ; foreach ( $ blockTypes as $ blockType ) { if ( isset ( $ fieldIdsByLayoutId [ $ blockType -> fieldLayoutId ] ) ) { $ fieldColumnPrefix = 'field_' ; foreach ( $ fieldIdsByLayoutId [ $ blockType -> fieldLayoutId ] as $ fieldId ) { if ( isset ( $ fieldsById [ $ fieldId ] ) ) { $ fieldsById [ $ fieldId ] -> columnPrefix = $ fieldColumnPrefix ; $ this -> _blockTypeFields [ ] = $ fieldsById [ $ fieldId ] ; } } } } return $ this -> _blockTypeFields ; }
Returns all of the block types' fields.

@return FieldInterface[]
Returns all of the block types fields .