You are here

public function PharInvocationResolver::resolve in Drupal 7

Resolves PharInvocation value object (baseName and optional alias).

Phar aliases are intended to be used only inside Phar archives, however PharStreamWrapper needs this information exposed outside of Phar as well It is possible that same alias is used for different $baseName values. That's why PharInvocationCollection behaves like a stack when resolving base-name for a given alias. On the other hand it is not possible that one $baseName is referring to multiple aliases.

Parameters

string $path:

int|null $flags:

Return value

null|PharInvocation

Overrides Resolvable::resolve

See also

https://secure.php.net/manual/en/phar.setalias.php

https://secure.php.net/manual/en/phar.mapphar.php

File

misc/typo3/phar-stream-wrapper/src/Resolver/PharInvocationResolver.php, line 59

Class

PharInvocationResolver

Namespace

TYPO3\PharStreamWrapper\Resolver

Code

public function resolve($path, $flags = null) {
  $hasPharPrefix = Helper::hasPharPrefix($path);
  if ($flags === null) {
    $flags = static::RESOLVE_REALPATH | static::RESOLVE_ALIAS;
  }
  if ($hasPharPrefix && $flags & static::RESOLVE_ALIAS) {
    $invocation = $this
      ->findByAlias($path);
    if ($invocation !== null) {
      return $invocation;
    }
  }
  $baseName = $this
    ->resolveBaseName($path, $flags);
  if ($baseName === null) {
    return null;
  }
  if ($flags & static::RESOLVE_REALPATH) {
    $baseName = $this->baseNames[$baseName];
  }
  return $this
    ->retrieveInvocation($baseName, $flags);
}