Upgraded to Symfony 2.1-beta2
This commit is contained in:
@@ -124,8 +124,15 @@ class EntityRepository implements ObjectRepository
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($lockMode !== LockMode::NONE) {
|
||||
$this->_em->lock($entity, $lockMode, $lockVersion);
|
||||
switch ($lockMode) {
|
||||
case LockMode::OPTIMISTIC:
|
||||
$this->_em->lock($entity, $lockMode, $lockVersion);
|
||||
break;
|
||||
case LockMode::PESSIMISTIC_READ:
|
||||
case LockMode::PESSIMISTIC_WRITE:
|
||||
$persister = $this->_em->getUnitOfWork()->getEntityPersister($this->_entityName);
|
||||
$persister->refresh($sortedId, $entity, $lockMode);
|
||||
break;
|
||||
}
|
||||
|
||||
return $entity; // Hit!
|
||||
|
@@ -364,7 +364,19 @@ class BasicEntityPersister
|
||||
$targetMapping = $this->_em->getClassMetadata($this->_class->associationMappings[$idField]['targetEntity']);
|
||||
$where[] = $this->_class->associationMappings[$idField]['joinColumns'][0]['name'];
|
||||
$params[] = $id[$idField];
|
||||
$types[] = $targetMapping->fieldMappings[$targetMapping->identifier[0]]['type'];
|
||||
|
||||
switch (true) {
|
||||
case (isset($targetMapping->fieldMappings[$targetMapping->identifier[0]])):
|
||||
$types[] = $targetMapping->fieldMappings[$targetMapping->identifier[0]]['type'];
|
||||
break;
|
||||
|
||||
case (isset($targetMapping->associationMappings[$targetMapping->identifier[0]])):
|
||||
$types[] = $targetMapping->associationMappings[$targetMapping->identifier[0]]['type'];
|
||||
break;
|
||||
|
||||
default:
|
||||
throw ORMException::unrecognizedField($targetMapping->identifier[0]);
|
||||
}
|
||||
} else {
|
||||
$where[] = $this->_class->getQuotedColumnName($idField, $this->_platform);
|
||||
$params[] = $id[$idField];
|
||||
@@ -690,9 +702,9 @@ class BasicEntityPersister
|
||||
* column or field names to values.
|
||||
* @param object $entity The entity to refresh.
|
||||
*/
|
||||
public function refresh(array $id, $entity)
|
||||
public function refresh(array $id, $entity, $lockMode = 0)
|
||||
{
|
||||
$sql = $this->_getSelectEntitiesSQL($id);
|
||||
$sql = $this->_getSelectEntitiesSQL($id, null, $lockMode);
|
||||
list($params, $types) = $this->expandParameters($id);
|
||||
$stmt = $this->_conn->executeQuery($sql, $params, $types);
|
||||
|
||||
|
@@ -184,7 +184,19 @@ class ProxyFactory
|
||||
|
||||
$file = str_replace($placeholders, $replacements, $file);
|
||||
|
||||
file_put_contents($fileName, $file, LOCK_EX);
|
||||
$parentDirectory = dirname($fileName);
|
||||
|
||||
if ( ! is_dir($parentDirectory)) {
|
||||
if (false === @mkdir($parentDirectory, 0775, true)) {
|
||||
throw ProxyException::proxyDirectoryNotWritable();
|
||||
}
|
||||
} else if ( ! is_writable($parentDirectory)) {
|
||||
throw ProxyException::proxyDirectoryNotWritable();
|
||||
}
|
||||
|
||||
$tmpFileName = $fileName . '.' . uniqid("", true);
|
||||
file_put_contents($tmpFileName, $file);
|
||||
rename($tmpFileName, $fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -136,6 +136,23 @@ public function <methodName>(<methodTypeHint>$<variableName>)
|
||||
<spaces>return $this;
|
||||
}';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private static $_removeMethodTemplate =
|
||||
'/**
|
||||
* <description>
|
||||
*
|
||||
* @param <variableType$<variableName>
|
||||
*/
|
||||
public function <methodName>(<methodTypeHint>$<variableName>)
|
||||
{
|
||||
<spaces>$this-><fieldName>->removeElement($<variableName>);
|
||||
}';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private static $_lifecycleCallbackMethodTemplate =
|
||||
'/**
|
||||
* @<name>
|
||||
@@ -672,6 +689,9 @@ public function <methodName>()
|
||||
if ($code = $this->_generateEntityStubMethod($metadata, 'add', $associationMapping['fieldName'], $associationMapping['targetEntity'])) {
|
||||
$methods[] = $code;
|
||||
}
|
||||
if ($code = $this->_generateEntityStubMethod($metadata, 'remove', $associationMapping['fieldName'], $associationMapping['targetEntity'])) {
|
||||
$methods[] = $code;
|
||||
}
|
||||
if ($code = $this->_generateEntityStubMethod($metadata, 'get', $associationMapping['fieldName'], 'Doctrine\Common\Collections\Collection')) {
|
||||
$methods[] = $code;
|
||||
}
|
||||
@@ -756,12 +776,9 @@ public function <methodName>()
|
||||
|
||||
private function _generateEntityStubMethod(ClassMetadataInfo $metadata, $type, $fieldName, $typeHint = null, $defaultValue = null)
|
||||
{
|
||||
if ($type == "add") {
|
||||
$addMethod = explode("\\", $typeHint);
|
||||
$addMethod = end($addMethod);
|
||||
$methodName = $type . $addMethod;
|
||||
} else {
|
||||
$methodName = $type . Inflector::classify($fieldName);
|
||||
$methodName = $type . Inflector::classify($fieldName);
|
||||
if (in_array($type, array("add", "remove")) && substr($methodName, -1) == "s") {
|
||||
$methodName = substr($methodName, 0, -1);
|
||||
}
|
||||
|
||||
if ($this->_hasMethod($methodName, $metadata)) {
|
||||
|
@@ -1118,6 +1118,10 @@ class UnitOfWork implements PropertyChangedListener
|
||||
if (isset($this->entityIdentifiers[$oid])) {
|
||||
$this->addToIdentityMap($entity);
|
||||
}
|
||||
|
||||
if ($entity instanceof NotifyPropertyChanged) {
|
||||
$entity->addPropertyChangedListener($this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1296,10 +1300,6 @@ class UnitOfWork implements PropertyChangedListener
|
||||
|
||||
$this->identityMap[$className][$idHash] = $entity;
|
||||
|
||||
if ($entity instanceof NotifyPropertyChanged) {
|
||||
$entity->addPropertyChangedListener($this);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1649,7 +1649,7 @@ class UnitOfWork implements PropertyChangedListener
|
||||
$oid = spl_object_hash($entity);
|
||||
|
||||
if (isset($visited[$oid])) {
|
||||
return; // Prevent infinite recursion
|
||||
return $visited[$oid]; // Prevent infinite recursion
|
||||
}
|
||||
|
||||
$visited[$oid] = $entity; // mark visited
|
||||
@@ -2356,11 +2356,12 @@ class UnitOfWork implements PropertyChangedListener
|
||||
}
|
||||
} else {
|
||||
$entity = $this->newInstance($class);
|
||||
$oid = spl_object_hash($entity);
|
||||
$oid = spl_object_hash($entity);
|
||||
|
||||
$this->entityIdentifiers[$oid] = $id;
|
||||
$this->entityStates[$oid] = self::STATE_MANAGED;
|
||||
$this->entityIdentifiers[$oid] = $id;
|
||||
$this->entityStates[$oid] = self::STATE_MANAGED;
|
||||
$this->originalEntityData[$oid] = $data;
|
||||
|
||||
$this->identityMap[$class->rootEntityName][$idHash] = $entity;
|
||||
|
||||
if ($entity instanceof NotifyPropertyChanged) {
|
||||
@@ -2790,6 +2791,10 @@ class UnitOfWork implements PropertyChangedListener
|
||||
$this->originalEntityData[$oid] = $data;
|
||||
|
||||
$this->addToIdentityMap($entity);
|
||||
|
||||
if ($entity instanceof NotifyPropertyChanged) {
|
||||
$entity->addPropertyChangedListener($this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user