Doctrine\ORM\EntityManager::getUnitOfWork PHP Method

getUnitOfWork() public method

Gets the UnitOfWork used by the EntityManager to coordinate operations.
public getUnitOfWork ( ) : Doctrine\ORM\UnitOfWork
return Doctrine\ORM\UnitOfWork
    public function getUnitOfWork()
    {
        return $this->unitOfWork;
    }

Usage Example

コード例 #1
0
 /**
  * Checks if the passed value is valid.
  *
  * @param mixed      $value      The value that should be validated
  * @param Constraint $constraint The constraint for the validation
  *
  * @api
  */
 public function validate($value, Constraint $constraint)
 {
     if (!$value instanceof Node) {
         $this->context->addViolation('Attempt to validate non Node entity');
         return;
     }
     $uow = $this->entityManager->getUnitOfWork();
     $originalData = $uow->getOriginalEntityData($value);
     // If we've been given a custom path, then don't use nonConflict in route path generation
     $hasCustomPath = strlen($value->getPath());
     $route = $this->routeBuilder->build($value, !$hasCustomPath);
     $routeName = $this->routeBuilder->buildRouteName($route->getPath());
     if (is_array($originalData) && count($originalData)) {
         if ($originalData['path'] !== $value->getPath()) {
             $existingRoute = $this->entityManager->getRepository('CmfRoutingBundle:Route')->findOneByName($routeName);
             if ($existingRoute instanceof Route) {
                 $this->context->buildViolation("A page at path '{$route->getPath()}' already exists")->atPath('path')->addViolation();
                 return;
             }
         } elseif ($value->getRoute() instanceof Route && $value->getRoute()->getName() !== $routeName) {
             $existingRoute = $this->entityManager->getRepository('CmfRoutingBundle:Route')->findOneByName($routeName);
             if ($existingRoute instanceof Route) {
                 $this->context->buildViolation("A page at path '{$route->getPath()}' already exists")->atPath('path')->addViolation();
                 return;
             }
         }
     }
 }
All Usage Examples Of Doctrine\ORM\EntityManager::getUnitOfWork