You are here

protected function BaseInstaller::templatePath in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/composer/installers/src/Composer/Installers/BaseInstaller.php \Composer\Installers\BaseInstaller::templatePath()

Replace vars in a path

Parameters

string $path:

array $vars:

Return value

string

2 calls to BaseInstaller::templatePath()
BaseInstaller::getInstallPath in vendor/composer/installers/src/Composer/Installers/BaseInstaller.php
Return the install path based on package type.
SilverStripeInstaller::getInstallPath in vendor/composer/installers/src/Composer/Installers/SilverStripeInstaller.php
Return the install path based on package type.

File

vendor/composer/installers/src/Composer/Installers/BaseInstaller.php, line 98

Class

BaseInstaller

Namespace

Composer\Installers

Code

protected function templatePath($path, array $vars = array()) {
  if (strpos($path, '{') !== false) {
    extract($vars);
    preg_match_all('@\\{\\$([A-Za-z0-9_]*)\\}@i', $path, $matches);
    if (!empty($matches[1])) {
      foreach ($matches[1] as $var) {
        $path = str_replace('{$' . $var . '}', ${$var}, $path);
      }
    }
  }
  return $path;
}