Permalink
Browse files

fixed bundle on mac.

Signed-off-by: Taylor Otwell <taylorotwell@gmail.com>
  • Loading branch information...
1 parent 6edd958 commit 36e9c44cd209692116564c565c332632542ec45b @taylorotwell taylorotwell committed Feb 29, 2012
Showing 534 changed files with 2,757 additions and 437 deletions.
@@ -501,3 +501,4 @@ necessary. Here is a sample; alter the names:
That's all there is to it!
+
@@ -1,128 +0,0 @@
-<?php
-/*
- * $Id$
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * This software consists of voluntary contributions made by many individuals
- * and is licensed under the LGPL. For more information, see
- * <http://www.doctrine-project.org>.
- */
-
-namespace Doctrine\Common\Cache;
-
-/**
- * Array cache driver.
- *
- * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
- * @link www.doctrine-project.org
- * @since 2.x
- * @author Taylor Otwell <taylorotwell@gmail.com>
- */
-class FileCache extends CacheProvider
-{
- /**
- * @var array $data
- */
- private $data = array();
-
- /**
- * Create a new FileCache CacheProvider.
- *
- * @param string $cachePath the directory where the cache files should be stored
- */
- public function __construct($cachePath)
- {
- $this->cachePath = $cachePath;
-
- $this->warmCache();
- }
-
- /**
- * {@inheritdoc}
- */
- protected function doFetch($id)
- {
- return (isset($this->data[$id])) ? $this->data[$id] : false;
- }
-
- /**
- * {@inheritdoc}
- */
- protected function doContains($id)
- {
- return isset($this->data[$id]);
- }
-
- /**
- * {@inheritdoc}
- */
- protected function doSave($id, $data, $lifeTime = 0)
- {
- $this->data[$id] = $data;
-
- return true;
- }
-
- /**
- * {@inheritdoc}
- */
- protected function doDelete($id)
- {
- unset($this->data[$id]);
-
- return true;
- }
-
- /**
- * {@inheritdoc}
- */
- protected function doFlush()
- {
- @unlink($this->cachePath);
-
- $this->data = array();
-
- return true;
- }
-
- /**
- * {@inheritdoc}
- */
- protected function doGetStats()
- {
- return null;
- }
-
- /**
- * Load the file cache from disk.
- */
- protected function warmCache()
- {
- if (file_exists($this->cachePath))
- {
- $this->data = unserialize(file_get_contents($this->cachePath));
- }
- }
-
- /**
- * Handle the destruction of the provider.
- *
- * Write the cache out to disk.
- */
- public function __destruct()
- {
- file_put_contents($this->cachePath, serialize($this->data));
- }
-
-}
@@ -208,6 +208,7 @@ public function setParameter($key, $value, $type = null)
{
$key = trim($key, ':');
+ $value = $this->processParameterValue($value);
if ($type === null) {
$type = Query\ParameterTypeInferer::inferType($value);
}
@@ -219,6 +220,53 @@ public function setParameter($key, $value, $type = null)
}
/**
+ * Process an individual parameter value
+ *
+ * @param mixed $value
+ * @return array
+ */
+ private function processParameterValue($value)
+ {
+ switch (true) {
+ case is_array($value):
+ for ($i = 0, $l = count($value); $i < $l; $i++) {
+ $paramValue = $this->processParameterValue($value[$i]);
+ $value[$i] = is_array($paramValue) ? $paramValue[key($paramValue)] : $paramValue;
+ }
+
+ return $value;
+
+ case is_object($value) && $this->_em->getMetadataFactory()->hasMetadataFor(get_class($value)):
+ return $this->convertObjectParameterToScalarValue($value);
+
+ default:
+ return $value;
+ }
+ }
+
+ protected function convertObjectParameterToScalarValue($value)
+ {
+ $class = $this->_em->getClassMetadata(get_class($value));
+
+ if ($class->isIdentifierComposite) {
+ throw new \InvalidArgumentException("Binding an entity with a composite primary key to a query is not supported. You should split the parameter into the explicit fields and bind them seperately.");
+ }
+
+ if ($this->_em->getUnitOfWork()->getEntityState($value) === UnitOfWork::STATE_MANAGED) {
+ $values = $this->_em->getUnitOfWork()->getEntityIdentifier($value);
+ } else {
+ $values = $class->getIdentifierValues($value);
+ }
+
+ $value = $values[$class->getSingleIdentifierFieldName()];
+ if (!$value) {
+ throw new \InvalidArgumentException("Binding entities to query parameters only allowed for entities that have an identifier.");
+ }
+
+ return $value;
+ }
+
+ /**
* Sets a collection of query parameters.
*
* @param array $params
@@ -605,7 +653,7 @@ public function execute($params = array(), $hydrationMode = null)
/**
* Set the result cache id to use to store the result set cache entry.
- * If this is not explicitely set by the developer then a hash is automatically
+ * If this is not explicitly set by the developer then a hash is automatically
* generated for you.
*
* @param string $id
@@ -24,7 +24,9 @@
Doctrine\Common\Annotations\AnnotationRegistry,
Doctrine\Common\Annotations\AnnotationReader,
Doctrine\ORM\Mapping\Driver\Driver,
- Doctrine\ORM\Mapping\Driver\AnnotationDriver;
+ Doctrine\ORM\Mapping\Driver\AnnotationDriver,
+ Doctrine\ORM\Mapping\NamingStrategy,
+ Doctrine\ORM\Mapping\DefaultNamingStrategy;
/**
* Configuration container for all configuration options of Doctrine.
@@ -548,4 +550,29 @@ public function getDefaultRepositoryClassName()
return isset($this->_attributes['defaultRepositoryClassName']) ?
$this->_attributes['defaultRepositoryClassName'] : 'Doctrine\ORM\EntityRepository';
}
+
+ /**
+ * Set naming strategy.
+ *
+ * @since 2.3
+ * @param NamingStrategy $namingStrategy
+ */
+ public function setNamingStrategy(NamingStrategy $namingStrategy)
+ {
+ $this->_attributes['namingStrategy'] = $namingStrategy;
+ }
+
+ /**
+ * Get naming strategy..
+ *
+ * @since 2.3
+ * @return NamingStrategy
+ */
+ public function getNamingStrategy()
+ {
+ if (!isset($this->_attributes['namingStrategy'])) {
+ $this->_attributes['namingStrategy'] = new DefaultNamingStrategy();
+ }
+ return $this->_attributes['namingStrategy'];
+ }
}
@@ -488,7 +488,7 @@ public function close()
public function persist($entity)
{
if ( ! is_object($entity)) {
- throw new \InvalidArgumentException(gettype($entity));
+ throw ORMInvalidArgumentException::invalidObject('EntityManager#persist()' , $entity);
}
$this->errorIfClosed();
@@ -507,7 +507,7 @@ public function persist($entity)
public function remove($entity)
{
if ( ! is_object($entity)) {
- throw new \InvalidArgumentException(gettype($entity));
+ throw ORMInvalidArgumentException::invalidObject('EntityManager#remove()' , $entity);
}
$this->errorIfClosed();
@@ -524,7 +524,7 @@ public function remove($entity)
public function refresh($entity)
{
if ( ! is_object($entity)) {
- throw new \InvalidArgumentException(gettype($entity));
+ throw ORMInvalidArgumentException::invalidObject('EntityManager#refresh()' , $entity);
}
$this->errorIfClosed();
@@ -544,7 +544,7 @@ public function refresh($entity)
public function detach($entity)
{
if ( ! is_object($entity)) {
- throw new \InvalidArgumentException(gettype($entity));
+ throw ORMInvalidArgumentException::invalidObject('EntityManager#detach()' , $entity);
}
$this->unitOfWork->detach($entity);
@@ -561,7 +561,7 @@ public function detach($entity)
public function merge($entity)
{
if ( ! is_object($entity)) {
- throw new \InvalidArgumentException(gettype($entity));
+ throw ORMInvalidArgumentException::invalidObject('EntityManager#merge()' , $entity);
}
$this->errorIfClosed();
File renamed without changes.
@@ -36,22 +36,22 @@
*/
abstract class AbstractHydrator
{
- /** @var ResultSetMapping The ResultSetMapping. */
+ /** @var \Doctrine\ORM\Query\ResultSetMapping The ResultSetMapping. */
protected $_rsm;
/** @var EntityManager The EntityManager instance. */
protected $_em;
- /** @var AbstractPlatform The dbms Platform instance */
+ /** @var \Doctrine\DBAL\Platforms\AbstractPlatform The dbms Platform instance */
protected $_platform;
- /** @var UnitOfWork The UnitOfWork of the associated EntityManager. */
+ /** @var \Doctrine\ORM\UnitOfWork The UnitOfWork of the associated EntityManager. */
protected $_uow;
/** @var array The cache used during row-by-row hydration. */
protected $_cache = array();
- /** @var Statement The statement that provides the data to hydrate. */
+ /** @var \Doctrine\DBAL\Driver\Statement The statement that provides the data to hydrate. */
protected $_stmt;
/** @var array The query hints. */
@@ -93,6 +93,7 @@ public function iterate($stmt, $resultSetMapping, array $hints = array())
*
* @param object $stmt
* @param object $resultSetMapping
+ * @param array $hints
* @return mixed
*/
public function hydrateAll($stmt, $resultSetMapping, array $hints = array())
@@ -233,7 +234,7 @@ protected function gatherRowData(array $data, array &$cache, array &$id, array &
if (isset($cache[$key]['isScalar'])) {
$value = $cache[$key]['type']->convertToPHPValue($value, $this->_platform);
-
+
$rowData['scalars'][$cache[$key]['fieldName']] = $value;
continue;
@@ -286,4 +286,4 @@ private function getClassMetadata($className)
return $this->_ce[$className];
}
-}
+}
@@ -208,8 +208,8 @@ private function _initRelatedCollection($entity, $class, $fieldName, $parentDqlA
/**
* Gets an entity instance.
*
- * @param $data The instance data.
- * @param $dqlAlias The DQL alias of the entity's class.
+ * @param array $data The instance data.
+ * @param string $dqlAlias The DQL alias of the entity's class.
* @return object The entity.
*/
private function _getEntity(array $data, $dqlAlias)
@@ -234,20 +234,7 @@ private function _getEntity(array $data, $dqlAlias)
$this->_hints['fetchAlias'] = $dqlAlias;
- $entity = $this->_uow->createEntity($className, $data, $this->_hints);
-
- //TODO: These should be invoked later, after hydration, because associations may not yet be loaded here.
- if (isset($this->_ce[$className]->lifecycleCallbacks[Events::postLoad])) {
- $this->_ce[$className]->invokeLifecycleCallbacks(Events::postLoad, $entity);
- }
-
- $evm = $this->_em->getEventManager();
-
- if ($evm->hasListeners(Events::postLoad)) {
- $evm->dispatchEvent(Events::postLoad, new LifecycleEventArgs($entity, $this->_em));
- }
-
- return $entity;
+ return $this->_uow->createEntity($className, $data, $this->_hints);
}
private function _getEntityFromIdentityMap($className, array $data)
Oops, something went wrong.

0 comments on commit 36e9c44

Please sign in to comment.