public function createMany($articleTypes)
{
Validation::notEmpty($articleTypes, 'articleTypes');
foreach ($articleTypes as $typeName => $type) {
$artType = $this->_create($typeName);
if (isset($type['fields']) && is_array($type['fields'])) {
foreach ($type['fields'] as $field) {
$this->_createField($field['name'], $artType);
}
}
}
try {
$this->getManager()->flush();
} catch (\PDOException $e) {
// duplicate keys, no worries
if ($e->getCode() == 23000 && strpos($e->getMessage(), 'Duplicate') !== false) {
return true;
}
throw $e;
} catch (\Exception $e) {
throw $e;
}
return true;
}