Fixed documentation for ORM\Event and ORM\Id
This commit is contained in:
parent
dacdd6cd89
commit
fad22d1e60
@ -44,10 +44,10 @@ class LifecycleEventArgs extends EventArgs
|
||||
private $entity;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Constructor.
|
||||
*
|
||||
* @param object $entity
|
||||
* @param \Doctrine\ORM\EntityManager $em
|
||||
* @param object $entity
|
||||
* @param EntityManager $em
|
||||
*/
|
||||
public function __construct($entity, EntityManager $em)
|
||||
{
|
||||
@ -56,7 +56,7 @@ class LifecycleEventArgs extends EventArgs
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve associated Entity.
|
||||
* Retrieves associated Entity.
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
@ -66,7 +66,7 @@ class LifecycleEventArgs extends EventArgs
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve associated EntityManager.
|
||||
* Retrieves associated EntityManager.
|
||||
*
|
||||
* @return \Doctrine\ORM\EntityManager
|
||||
*/
|
||||
|
@ -44,8 +44,8 @@ class LoadClassMetadataEventArgs extends EventArgs
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param \Doctrine\ORM\Mapping\ClassMetadataInfo $classMetadata
|
||||
* @param \Doctrine\ORM\EntityManager $em
|
||||
* @param ClassMetadataInfo $classMetadata
|
||||
* @param EntityManager $em
|
||||
*/
|
||||
public function __construct(ClassMetadataInfo $classMetadata, EntityManager $em)
|
||||
{
|
||||
@ -54,7 +54,7 @@ class LoadClassMetadataEventArgs extends EventArgs
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve associated ClassMetadata.
|
||||
* Retrieves associated ClassMetadata.
|
||||
*
|
||||
* @return \Doctrine\ORM\Mapping\ClassMetadataInfo
|
||||
*/
|
||||
@ -64,7 +64,7 @@ class LoadClassMetadataEventArgs extends EventArgs
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve associated EntityManager.
|
||||
* Retrieves associated EntityManager.
|
||||
*
|
||||
* @return \Doctrine\ORM\EntityManager
|
||||
*/
|
||||
@ -73,4 +73,3 @@ class LoadClassMetadataEventArgs extends EventArgs
|
||||
return $this->em;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ class OnClearEventArgs extends \Doctrine\Common\EventArgs
|
||||
* Constructor.
|
||||
*
|
||||
* @param \Doctrine\ORM\EntityManager $em
|
||||
* @param string $entityClass Optional entity class
|
||||
* @param string|null $entityClass Optional entity class.
|
||||
*/
|
||||
public function __construct($em, $entityClass = null)
|
||||
{
|
||||
@ -53,7 +53,7 @@ class OnClearEventArgs extends \Doctrine\Common\EventArgs
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve associated EntityManager.
|
||||
* Retrieves associated EntityManager.
|
||||
*
|
||||
* @return \Doctrine\ORM\EntityManager
|
||||
*/
|
||||
@ -65,7 +65,7 @@ class OnClearEventArgs extends \Doctrine\Common\EventArgs
|
||||
/**
|
||||
* Name of the entity class that is cleared, or empty if all are cleared.
|
||||
*
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function getEntityClass()
|
||||
{
|
||||
@ -73,7 +73,7 @@ class OnClearEventArgs extends \Doctrine\Common\EventArgs
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if event clears all entities.
|
||||
* Checks if event clears all entities.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
|
@ -47,7 +47,7 @@ class PostFlushEventArgs extends EventArgs
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve associated EntityManager.
|
||||
* Retrieves associated EntityManager.
|
||||
*
|
||||
* @return \Doctrine\ORM\EntityManager
|
||||
*/
|
||||
|
@ -35,6 +35,11 @@ class PreFlushEventArgs extends \Doctrine\Common\EventArgs
|
||||
*/
|
||||
private $_em;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param \Doctrine\ORM\EntityManager $em
|
||||
*/
|
||||
public function __construct($em)
|
||||
{
|
||||
$this->_em = $em;
|
||||
|
@ -40,9 +40,9 @@ class PreUpdateEventArgs extends LifecycleEventArgs
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param object $entity
|
||||
* @param \Doctrine\ORM\EntityManager $em
|
||||
* @param array $changeSet
|
||||
* @param object $entity
|
||||
* @param EntityManager $em
|
||||
* @param array $changeSet
|
||||
*/
|
||||
public function __construct($entity, EntityManager $em, array &$changeSet)
|
||||
{
|
||||
@ -52,7 +52,7 @@ class PreUpdateEventArgs extends LifecycleEventArgs
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve entity changeset.
|
||||
* Retrieves entity changeset.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@ -62,7 +62,9 @@ class PreUpdateEventArgs extends LifecycleEventArgs
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if field has a changeset.
|
||||
* Checks if field has a changeset.
|
||||
*
|
||||
* @param string $field
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
@ -72,9 +74,10 @@ class PreUpdateEventArgs extends LifecycleEventArgs
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the old value of the changeset of the changed field.
|
||||
* Gets the old value of the changeset of the changed field.
|
||||
*
|
||||
* @param string $field
|
||||
*
|
||||
* @param string $field
|
||||
* @return mixed
|
||||
*/
|
||||
public function getOldValue($field)
|
||||
@ -85,9 +88,10 @@ class PreUpdateEventArgs extends LifecycleEventArgs
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the new value of the changeset of the changed field.
|
||||
* Gets the new value of the changeset of the changed field.
|
||||
*
|
||||
* @param string $field
|
||||
*
|
||||
* @param string $field
|
||||
* @return mixed
|
||||
*/
|
||||
public function getNewValue($field)
|
||||
@ -98,10 +102,12 @@ class PreUpdateEventArgs extends LifecycleEventArgs
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the new value of this field.
|
||||
* Sets the new value of this field.
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setNewValue($field, $value)
|
||||
{
|
||||
@ -111,9 +117,13 @@ class PreUpdateEventArgs extends LifecycleEventArgs
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert the field exists in changeset.
|
||||
* Asserts the field exists in changeset.
|
||||
*
|
||||
* @param string $field
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
private function assertValidField($field)
|
||||
{
|
||||
@ -126,4 +136,3 @@ class PreUpdateEventArgs extends LifecycleEventArgs
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,9 @@ abstract class AbstractIdGenerator
|
||||
/**
|
||||
* Generates an identifier for an entity.
|
||||
*
|
||||
* @param \Doctrine\ORM\EntityManager $em
|
||||
* @param \Doctrine\ORM\Mapping\Entity $entity
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
abstract public function generate(EntityManager $em, $entity);
|
||||
|
@ -36,8 +36,13 @@ class AssignedGenerator extends AbstractIdGenerator
|
||||
/**
|
||||
* Returns the identifier assigned to the given entity.
|
||||
*
|
||||
* @param object $entity
|
||||
* @param EntityManager $em
|
||||
* @param object $entity
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Doctrine\ORM\ORMException
|
||||
*
|
||||
* @override
|
||||
*/
|
||||
public function generate(EntityManager $em, $entity)
|
||||
|
@ -28,13 +28,19 @@ use Doctrine\ORM\EntityManager;
|
||||
*/
|
||||
class IdentityGenerator extends AbstractIdGenerator
|
||||
{
|
||||
/** @var string The name of the sequence to pass to lastInsertId(), if any. */
|
||||
/**
|
||||
* The name of the sequence to pass to lastInsertId(), if any.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_seqName;
|
||||
|
||||
/**
|
||||
* @param string $seqName The name of the sequence to pass to lastInsertId()
|
||||
* to obtain the last generated identifier within the current
|
||||
* database session/connection, if any.
|
||||
* Constructor.
|
||||
*
|
||||
* @param string|null $seqName The name of the sequence to pass to lastInsertId()
|
||||
* to obtain the last generated identifier within the current
|
||||
* database session/connection, if any.
|
||||
*/
|
||||
public function __construct($seqName = null)
|
||||
{
|
||||
|
@ -38,8 +38,7 @@ class SequenceGenerator extends AbstractIdGenerator implements Serializable
|
||||
/**
|
||||
* Initializes a new sequence generator.
|
||||
*
|
||||
* @param \Doctrine\ORM\EntityManager $em The EntityManager to use.
|
||||
* @param string $sequenceName The name of the sequence.
|
||||
* @param string $sequenceName The name of the sequence.
|
||||
* @param integer $allocationSize The allocation size of the sequence.
|
||||
*/
|
||||
public function __construct($sequenceName, $allocationSize)
|
||||
@ -51,8 +50,11 @@ class SequenceGenerator extends AbstractIdGenerator implements Serializable
|
||||
/**
|
||||
* Generates an ID for the given entity.
|
||||
*
|
||||
* @param object $entity
|
||||
* @param EntityManager $em
|
||||
* @param object $entity
|
||||
*
|
||||
* @return integer|float The generated value.
|
||||
*
|
||||
* @override
|
||||
*/
|
||||
public function generate(EntityManager $em, $entity)
|
||||
@ -89,6 +91,9 @@ class SequenceGenerator extends AbstractIdGenerator implements Serializable
|
||||
return $this->_nextValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function serialize()
|
||||
{
|
||||
return serialize(array(
|
||||
@ -97,6 +102,11 @@ class SequenceGenerator extends AbstractIdGenerator implements Serializable
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $serialized
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unserialize($serialized)
|
||||
{
|
||||
$array = unserialize($serialized);
|
||||
|
@ -32,12 +32,29 @@ use Doctrine\ORM\EntityManager;
|
||||
*/
|
||||
class TableGenerator extends AbstractIdGenerator
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $_tableName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $_sequenceName;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $_allocationSize;
|
||||
|
||||
private $_nextValue;
|
||||
private $_maxValue;
|
||||
|
||||
/**
|
||||
* @param string $tableName
|
||||
* @param string $sequenceName
|
||||
* @param int $allocationSize
|
||||
*/
|
||||
public function __construct($tableName, $sequenceName = 'default', $allocationSize = 10)
|
||||
{
|
||||
$this->_tableName = $tableName;
|
||||
@ -45,6 +62,9 @@ class TableGenerator extends AbstractIdGenerator
|
||||
$this->_allocationSize = $allocationSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function generate(EntityManager $em, $entity)
|
||||
{
|
||||
if ($this->_maxValue === null || $this->_nextValue == $this->_maxValue) {
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
namespace Doctrine\ORM\Id;
|
||||
|
||||
use Serializable;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
|
||||
/**
|
||||
@ -30,13 +29,14 @@ use Doctrine\ORM\EntityManager;
|
||||
*/
|
||||
class UuidGenerator extends AbstractIdGenerator
|
||||
{
|
||||
|
||||
/**
|
||||
* Generates an ID for the given entity.
|
||||
*
|
||||
* @param Doctrine\ORM\EntityManager $em The EntityManager to user
|
||||
* @param object $entity
|
||||
* @param EntityManager $em The EntityManager to use.
|
||||
* @param object $entity
|
||||
*
|
||||
* @return string The generated value.
|
||||
*
|
||||
* @override
|
||||
*/
|
||||
public function generate(EntityManager $em, $entity)
|
||||
@ -45,5 +45,4 @@ class UuidGenerator extends AbstractIdGenerator
|
||||
$sql = 'SELECT ' . $conn->getDatabasePlatform()->getGuidExpression();
|
||||
return $conn->query($sql)->fetchColumn(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user