Skip to content

Commit

Permalink
[TASK] Implement internal cache in PageProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
bjo3rnf committed May 19, 2015
1 parent ddbab1a commit 2f6d737
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions Classes/Provider/PageProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ class PageProvider extends AbstractProvider implements ProviderInterface {
*/
protected $configurationService;

/**
* @var array
*/
private static $cache = array();

/**
* CONSTRUCTOR
*/
Expand Down Expand Up @@ -298,22 +303,28 @@ protected function setDefaultValuesInFieldsWithInheritedValues(Form $form, array
* @return array
*/
protected function getInheritedConfiguration(array $row) {
$tree = $this->getInheritanceTree($row);
$data = array();
foreach ($tree as $branch) {
$provider = $this->configurationService->resolvePrimaryConfigurationProvider($this->tableName, self::FIELD_NAME_SUB, $branch);
$form = $provider->getForm($branch);
if (NULL === $form) {
return $data;
}
$fields = $form->getFields();
$values = $provider->getFlexFormValuesSingle($branch);
foreach ($fields as $field) {
$values = $this->unsetInheritedValues($field, $values);
$tableName = $this->getTableName($row);
$tableFieldName = $this->getFieldName($row);
$cacheKey = $tableName . $tableFieldName . $row['uid'];
if (TRUE === empty(self::$cache[$cacheKey])) {
$tree = $this->getInheritanceTree($row);
$data = array();
foreach ($tree as $branch) {
$provider = $this->configurationService->resolvePrimaryConfigurationProvider($this->tableName, self::FIELD_NAME_SUB, $branch);
$form = $provider->getForm($branch);
if (NULL === $form) {
break;
}
$fields = $form->getFields();
$values = $provider->getFlexFormValuesSingle($branch);
foreach ($fields as $field) {
$values = $this->unsetInheritedValues($field, $values);
}
$data = RecursiveArrayUtility::merge($data, $values);
}
$data = RecursiveArrayUtility::merge($data, $values);
self::$cache[$cacheKey] = $data;
}
return $data;
return self::$cache[$cacheKey];
}

/**
Expand Down

0 comments on commit 2f6d737

Please sign in to comment.