public function store(RequestInterface $request)
{
$post = new Post();
$post->setTitle($request->get("title"));
$post->setContent($request->get("content"));
$db = new Bootstrap();
$db->conn()->persist($post);
$db->conn()->flush();
return redirect("admin");
}
bu da bootstrap sınıfı
namespace Core\Database;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Tools\Setup;
class Bootstrap
{
private $conn = [
'driver' => 'pdo_mysql',
'host' => 'localhost',
'dbname' => 'cms',
'user' => 'root',
'password' => '123456'
];
public function conn()
{
return EntityManager::create($this->conn, $this->config());
}
private function config()
{
return Setup::createAnnotationMetadataConfiguration(array(__DIR__ . "/src"), true, null, null, true);
}
}