From aebe3abe68ed9dbb0f86955ff8091966f7a2787d Mon Sep 17 00:00:00 2001 From: shadlaws Date: Sun, 21 Apr 2013 12:34:24 +0300 Subject: [PATCH] Change _initialize() to set the object name only if none predefined. This follows the same pattern as object plural and table name, and gives devs the freedom to set their own name. This is useful, for example, if you want to translate "Model_FooBar" to "foo_bar" instead of "foobar". --- classes/Kohana/ORM.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/classes/Kohana/ORM.php b/classes/Kohana/ORM.php index 716e51d..55b13d7 100644 --- a/classes/Kohana/ORM.php +++ b/classes/Kohana/ORM.php @@ -288,8 +288,11 @@ public function __construct($id = NULL) */ protected function _initialize() { - // Set the object name and plural name - $this->_object_name = strtolower(substr(get_class($this), 6)); + // Set the object name if none predefined + if (empty($this->_object_name)) + { + $this->_object_name = strtolower(substr(get_class($this), 6)); + } // Check if this model has already been initialized if ( ! $init = Arr::get(ORM::$_init_cache, $this->_object_name, FALSE))