protected function insertContent(Content $content, $comment = null) { $tablename = $this->getContenttypeTablename($content->contenttype); // Set creation and update dates $content->setValue('datecreated', date('Y-m-d H:i:s')); $content->setValue('datechanged', date('Y-m-d H:i:s')); // id is set to autoincrement, so let the DB handle it unset($content->values['id']); // Get the JSON database prepared values and make sure it's valid $fieldvalues = $this->getValidSaveData($content->getValues(true), $content->contenttype); $this->app['db']->insert($tablename, $fieldvalues); $seq = null; if ($this->app['db']->getDatabasePlatform() instanceof PostgreSqlPlatform) { $seq = $tablename . '_id_seq'; } $id = $this->app['db']->lastInsertId($seq); if ($id > 0) { $content->setValue('id', $id); $this->logInsert($content->contenttype['slug'], $id, $fieldvalues, $comment); return true; } }