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);
}