Try and data to database and get an error.:
Uncaught Error: Call to a member function persist() on null in
public function addNewPostAction()
{
// Create new Post entity..
// $entityManager = $container->get('doctrine.entitymanager.orm_default');
$post = new Post();
$post->setTitle('Top 10+ Books about Zend Framework 3');
$post->setContent('Post body goes here');
$post->setStatus(Post::STATUS_PUBLISHED);
$currentDate = date('Y-m-d H:i:s');
$post->setDateCreated($currentDate);
$this->entityManager->persist($post);
$this->entityManager->flush();
}
UPDATE: Error: Zend\Mvc\Controller\PluginManager::get was unable to fetch or create an instance for get
public function addNewPostAction()
{
// Create new Post entity..
// $entityManager = $container->get('doctrine.entitymanager.orm_default');
$post = new Post();
$post->setTitle('Top 10+ Books about Zend Framework 3');
$post->setContent('Post body goes here');
$post->setStatus(Post::STATUS_PUBLISHED);
$currentDate = date('Y-m-d H:i:s');
$dm = $this->get('doctrine.odm.mongodb.document_manager');
$dm->persist($post);
$dm->flush();
}