NerdsAndCompany\Schematic\Models\MatrixField::populateBlockType PHP Method

populateBlockType() protected method

Populate blocktype.
protected populateBlockType ( Craft\BaseModel $blockType, array $blockTypeDef )
$blockType Craft\BaseModel
$blockTypeDef array
    protected function populateBlockType(BaseModel $blockType, array $blockTypeDef)
    {
        $fieldFactory = $this->getFieldFactory();
        $blockTypeFields = [];
        foreach ($blockType->getFields() as $blockTypeField) {
            $blockTypeFields[$blockTypeField->handle] = $blockTypeField;
        }
        $newBlockTypeFields = [];
        foreach ($blockTypeDef['fields'] as $blockTypeFieldHandle => $blockTypeFieldDef) {
            $blockTypeField = array_key_exists($blockTypeFieldHandle, $blockTypeFields) ? $blockTypeFields[$blockTypeFieldHandle] : new FieldModel();
            $schematicFieldModel = $fieldFactory->build($blockTypeFieldDef['type']);
            $schematicFieldModel->populate($blockTypeFieldDef, $blockTypeField, $blockTypeFieldHandle);
            $newBlockTypeFields[] = $blockTypeField;
        }
        $blockType->setFields($newBlockTypeFields);
    }