Skip to content
Permalink
Browse files

Optimize class name check.

  • Loading branch information...
robertpustulka committed Feb 3, 2017
1 parent 45cc8da commit 58c8b6a110721b7cd41eb262d87df989aac0d910
Showing with 7 additions and 3 deletions.
  1. +7 −3 src/ORM/Association.php
@@ -402,12 +402,14 @@ public function getTarget()
}
$this->_targetTable = $tableLocator->get($registryAlias, $config);
$targetClassName = get_class($this->_targetTable);
$className = $this->_getClassName($registryAlias, ['className' => $this->_className]);
if (!is_a($this->_targetTable, $className)) {
if ($targetClassName !== $className) {
throw new RuntimeException(sprintf(
'Invalid Table retrieved from a registry. Requested: %s, got: %s',
$className,
get_class($this->_targetTable)
$targetClassName
));
}
}
@@ -1301,7 +1303,9 @@ protected function _getClassName($alias, array $options = [])
$options['className'] = Inflector::camelize($alias);
}
return App::className($options['className'], 'Model/Table', 'Table') ?: 'Cake\ORM\Table';
$className = App::className($options['className'], 'Model/Table', 'Table') ?: 'Cake\ORM\Table';
return ltrim($className, '\\');
}
/**

0 comments on commit 58c8b6a

Please sign in to comment.
You can’t perform that action at this time.