eZ\Publish\Core\Persistence\Legacy\Content\Type\Gateway\DoctrineDatabase::insertType PHP Method

insertType() public method

Inserts a new content type.
public insertType ( eZ\Publish\SPI\Persistence\Content\Type $type, mixed | null $typeId = null ) : mixed
$type eZ\Publish\SPI\Persistence\Content\Type
$typeId mixed | null
return mixed Type ID
    public function insertType(Type $type, $typeId = null)
    {
        $q = $this->dbHandler->createInsertQuery();
        $q->insertInto($this->dbHandler->quoteTable('ezcontentclass'));
        $q->set($this->dbHandler->quoteColumn('id'), isset($typeId) ? $q->bindValue($typeId, null, \PDO::PARAM_INT) : $this->dbHandler->getAutoIncrementValue('ezcontentclass', 'id'))->set($this->dbHandler->quoteColumn('version'), $q->bindValue($type->status, null, \PDO::PARAM_INT))->set($this->dbHandler->quoteColumn('created'), $q->bindValue($type->created, null, \PDO::PARAM_INT))->set($this->dbHandler->quoteColumn('creator_id'), $q->bindValue($type->creatorId, null, \PDO::PARAM_INT));
        $this->setCommonTypeColumns($q, $type);
        $q->prepare()->execute();
        if (empty($typeId)) {
            $typeId = $this->dbHandler->lastInsertId($this->dbHandler->getSequenceName('ezcontentclass', 'id'));
        }
        $this->insertTypeNameData($typeId, $type->status, $type->name);
        return $typeId;
    }