Verified Commit c28ed377 authored by godotislate's avatar godotislate
Browse files

task: #3613256 Optimize TypedConfigManager::getDefinitionWithReplacements()

By: catch
(cherry picked from commit 57faef3a)
parent 0a2c0e71
Loading
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -42,6 +42,11 @@ class TypedConfigManager extends TypedDataManager implements TypedConfigManagerI
   */
  protected $definitions;

  /**
   * The array of base definitions, keyed by type.
   */
  protected array $baseDefinitions = [];

  /**
   * Creates a new typed configuration manager.
   *
@@ -278,7 +283,10 @@ protected function getDefinitionWithReplacements($base_plugin_id, array $replace
    $definition = $definitions[$type];
    // Check whether this type is an extension of another one and compile it.
    if (isset($definition['type'])) {
      $merge = $this->getDefinition($definition['type'], $exception_on_invalid);
      if (!isset($this->baseDefinitions[$definition['type']])) {
        $this->baseDefinitions[$definition['type']] = $this->getDefinition($definition['type'], $exception_on_invalid);
      }
      $merge = $this->baseDefinitions[$definition['type']];
      // Preserve integer keys on merge, so sequence item types can override
      // parent settings as opposed to adding unused second, third, etc. items.
      $definition = NestedArray::mergeDeepArray([$merge, $definition], TRUE);
@@ -323,6 +331,7 @@ public function getDefinition($base_plugin_id, $exception_on_invalid = TRUE) {
   */
  public function clearCachedDefinitions() {
    $this->schemaStorage->reset();
    $this->baseDefinitions = [];
    parent::clearCachedDefinitions();
  }