Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/Command/BuildCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,24 @@ public function buildSingleObject($data, $type, $isConflictResolution = false) {
$catName = $data['category'];
$data['category'] = $this->getCategoryId($catName);
}

// Make sure default value is applied to empty tinyint fields
foreach ($object->_fieldMeta as $key => $value) {
if ($value['dbtype'] == 'tinyint') {
$excludes = (isset($type['exclude_keys']) && is_array($type['exclude_keys'])) ? $type['exclude_keys'] : array();

// Skip fields that are explicitly defined OR excluded in YAML config
if (isset($data[$key]) || in_array($key, $excludes)) continue;

// Reset fields with a value other than the default
if (isset($value['default']) && $object->get($key) != $value['default']) {
if ($this->output->isVerbose()) {
$this->output->writeln("- Resetting <comment>$key</comment> field to default value for <comment>" . $object->get('name') . "</comment> object.");
}
$data[$key] = $value['default'];
}
}
}
}

$object->fromArray($data, '', true, true);
Expand Down