From 8a6606bef8c0206f106d28f41471eecd6ae670e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Kr=C3=A4mer?= Date: Thu, 19 Nov 2015 11:59:06 +0100 Subject: [PATCH] Split the locator class name getting in a separate method. --- src/ORM/Locator/TableLocator.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/ORM/Locator/TableLocator.php b/src/ORM/Locator/TableLocator.php index 6499677742f..b1ea118f50c 100644 --- a/src/ORM/Locator/TableLocator.php +++ b/src/ORM/Locator/TableLocator.php @@ -146,10 +146,7 @@ public function get($alias, array $options = []) $options += $this->_config[$alias]; } - if (empty($options['className'])) { - $options['className'] = Inflector::camelize($alias); - } - $className = App::className($options['className'], 'Model/Table', 'Table'); + $className = $this->_getClassName($alias, $options); if ($className) { $options['className'] = $className; } else { @@ -175,6 +172,20 @@ public function get($alias, array $options = []) return $this->_instances[$alias]; } + /** + * Gets the table class name. + * + * @param string $alias The alias name you want to get. + * @param array $options Table options array. + * @return string + */ + protected function _getClassName($alias, array $options = []) { + if (empty($options['className'])) { + $options['className'] = Inflector::camelize($alias); + } + return App::className($options['className'], 'Model/Table', 'Table'); + } + /** * Wrapper for creating table instances *