Skip to content

Commit

Permalink
Restoring in memory table cache inside EntityContext
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Feb 28, 2014
1 parent d20cefc commit 39b9c85
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/View/Form/EntityContext.php
Expand Up @@ -326,14 +326,25 @@ protected function _getValidator($parts) {
* 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;
}
Expand All @@ -346,7 +357,7 @@ protected function _getTable($parts) {
$table = $assoc->target();
}

return $table;
return $this->_tables[$path] = $table;
}

/**
Expand Down

0 comments on commit 39b9c85

Please sign in to comment.