Browse Source

don't update private variable unless repo exists. (#9009)

Thinking Media 9 years ago
parent
commit
1fb128b1ca
1 changed files with 4 additions and 5 deletions
  1. 4 5
      src/ORM/Rule/ExistsIn.php

+ 4 - 5
src/ORM/Rule/ExistsIn.php

@@ -64,16 +64,15 @@ class ExistsIn
     public function __invoke(EntityInterface $entity, array $options)
     {
         if (is_string($this->_repository)) {
-            $alias = $this->_repository;
-            $this->_repository = $options['repository']->association($alias);
-
-            if (empty($this->_repository)) {
+            $repository = $options['repository']->association($this->_repository);
+            if (empty($repository)) {
                 throw new RuntimeException(sprintf(
                     "ExistsIn rule for '%s' is invalid. The '%s' association is not defined.",
                     implode(', ', $this->_fields),
-                    $alias
+                    $this->_repository
                 ));
             }
+            $this->_repository = $repository;
         }
 
         $source = $target = $this->_repository;