Newscoop\Service\Implementation\ArticleTypeServiceDoctrine::createMany PHP Метод

createMany() публичный Метод

Creates more article types
См. также: self::create()
public createMany ( array $articleTypes )
$articleTypes array the array of types, optionally with fields [ typeName => [ fields : [ name : fieldName, parentType : typeName, ignore : bool ], [...] ], [...] ]
    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;
    }