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