ソースを参照

Restoring in memory table cache inside EntityContext

Jose Lorenzo Rodriguez 12 年 前
コミット
39b9c85dc4
1 ファイル変更17 行追加6 行削除
  1. 17 6
      src/View/Form/EntityContext.php

+ 17 - 6
src/View/Form/EntityContext.php

@@ -326,14 +326,25 @@ class EntityContext implements ContextInterface {
  * property name in the second position
  */
 	protected function _getTable($parts) {
-		if ($parts[0] === $this->_rootName) {
-			$parts = array_slice($parts, 1);
+		if (count($parts) === 1) {
+			return $this->_tables[$this->_rootName];
 		}
 
-		$table = $this->_tables[$this->_rootName];
+		$normalized = array_slice(array_filter($parts, function($part) {
+			return !is_numeric($part);
+		}), 0, -1);
+
+		$path = implode('.', $normalized);
+		if (isset($this->_tables[$path])) {
+			return $this->_tables[$path];
+		}
 
-		$normalized = array_filter()
-		foreach ($parts as $part) {
+		if (current($normalized) === $this->_rootName) {
+			$normalized = array_slice($normalized, 1);
+		}
+
+		$table = $this->_tables[$this->_rootName];
+		foreach ($normalized as $part) {
 			if (is_numeric($part)) {
 				continue;
 			}
@@ -346,7 +357,7 @@ class EntityContext implements ContextInterface {
 			$table = $assoc->target();
 		}
 
-		return $table;
+		return $this->_tables[$path] = $table;
 	}
 
 /**