2008-08-31 18:27:16 +00:00
|
|
|
<?php
|
|
|
|
|
2009-01-22 19:38:10 +00:00
|
|
|
namespace Doctrine\ORM\Id;
|
|
|
|
|
2009-03-30 19:43:05 +00:00
|
|
|
use Doctrine\ORM\EntityManager;
|
|
|
|
|
2009-01-22 19:38:10 +00:00
|
|
|
class IdentityGenerator extends AbstractIdGenerator
|
2008-08-31 18:27:16 +00:00
|
|
|
{
|
2008-09-07 13:48:40 +00:00
|
|
|
/**
|
2009-03-30 19:43:05 +00:00
|
|
|
* Generates an ID for the given entity.
|
2008-09-07 13:48:40 +00:00
|
|
|
*
|
2009-03-30 19:43:05 +00:00
|
|
|
* @param object $entity
|
|
|
|
* @return integer|float
|
2008-09-07 13:48:40 +00:00
|
|
|
* @override
|
|
|
|
*/
|
2009-03-30 19:43:05 +00:00
|
|
|
public function generate(EntityManager $em, $entity)
|
2008-09-07 13:48:40 +00:00
|
|
|
{
|
2009-03-30 19:43:05 +00:00
|
|
|
return $em->getConnection()->lastInsertId();
|
2008-08-31 18:27:16 +00:00
|
|
|
}
|
2009-01-03 19:50:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return boolean
|
|
|
|
* @override
|
|
|
|
*/
|
2009-02-20 05:46:20 +00:00
|
|
|
public function isPostInsertGenerator()
|
|
|
|
{
|
2009-01-03 19:50:13 +00:00
|
|
|
return true;
|
|
|
|
}
|
2009-02-20 05:46:20 +00:00
|
|
|
}
|