You are here

public function ConfigurationHandler::getExportPath in Configuration Management 7.3

File

src/Handlers/ConfigurationHandler.php, line 87

Class

ConfigurationHandler

Namespace

Configuration\Handlers

Code

public function getExportPath(Configuration $configuration) {
  $pattern = $this->configuration_manager
    ->settings()
    ->get('export.default_pattern');
  $overriden_patterns = $this->configuration_manager
    ->settings()
    ->get('export.overriden_patterns');
  foreach ($overriden_patterns as $current_pattern => $replacement) {
    if ($current_pattern == $this
      ->getType() . '.*') {
      $pattern = $replacement;
      break;
    }
    elseif ($current_pattern == $configuration
      ->getIdentifier()) {
      $pattern = $replacement;
      break;
    }
  }
  $tokens = array(
    '[group]' => $configuration
      ->getGroup(),
    '[type]' => $this
      ->getType(),
  );
  $path = strtr($pattern, $tokens);
  $path = rtrim($path, '/');
  $path = ltrim($path, '/');
  return $path . '/';
}