Browse Source

Merge pull request #4763 from ceeram/3.0-get

Fix docblocks and minor refactoring of __get() method
Mark Story 11 years ago
parent
commit
ee793eb028
1 changed files with 4 additions and 5 deletions
  1. 4 5
      src/Controller/Controller.php

+ 4 - 5
src/Controller/Controller.php

@@ -355,15 +355,14 @@ class Controller implements EventListener {
  * Magic accessor for model autoloading.
  *
  * @param string $name Property name
- * @return bool
+ * @return bool|object The model instance or false
  */
 	public function __get($name) {
 		list($plugin, $class) = pluginSplit($this->modelClass, true);
-		if ($class === $name) {
-			$this->loadModel($plugin . $class);
-			return $this->{$class};
+		if ($class !== $name) {
+			return false;
 		}
-		return false;
+		return $this->loadModel($plugin . $class);
 	}
 
 /**