Skip to content

Commit

Permalink
#6017 moving entity name validity checks into the EntityManager API…
Browse files Browse the repository at this point in the history
…, documenting newly thrown exception types
  • Loading branch information
Ocramius committed Nov 27, 2016
1 parent 9227412 commit 1d7397c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/Doctrine/ORM/EntityManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

namespace Doctrine\ORM;

use Doctrine\ORM\Mapping\MappingException;
use Exception;
use Doctrine\Common\EventManager;
use Doctrine\DBAL\Connection;
Expand Down Expand Up @@ -539,10 +540,22 @@ public function getPartialReference($entityName, $identifier)
* @param string|null $entityName if given, only entities of this type will get detached
*
* @return void
*
* @throws ORMInvalidArgumentException if a non-null non-string value is given
* @throws \Doctrine\Common\Persistence\Mapping\MappingException if a $entityName is given, but that entity is not
* found in the mappings
*/
public function clear($entityName = null)
{
$this->unitOfWork->clear($entityName);
if (null !== $entityName && ! is_string($entityName)) {
throw ORMInvalidArgumentException::invalidEntityName($entityName);
}

$this->unitOfWork->clear(
null === $entityName
? null
: $this->metadataFactory->getMetadataFor($entityName)->getName()
);
}

/**
Expand Down

0 comments on commit 1d7397c

Please sign in to comment.