class PathPrefixMethod in Persistent URL 8
Plugin annotation
@PurlMethod(
id="path_prefix"
)
Hierarchy
- class \Drupal\purl\Plugin\Purl\Method\PathPrefixMethod implements MethodInterface, RequestAlteringInterface
Expanded class hierarchy of PathPrefixMethod
File
- src/
Plugin/ Purl/ Method/ PathPrefixMethod.php, line 14
Namespace
Drupal\purl\Plugin\Purl\MethodView source
class PathPrefixMethod implements MethodInterface, RequestAlteringInterface {
public function contains(Request $request, $modifier) {
$uri = $request
->getRequestUri();
return $this
->pathContains($modifier, $uri);
}
private function pathContains($modifier, $path) {
return strpos($path, '/' . $modifier) === 0;
}
public function alterRequest(Request $request, $identifier) {
$uri = $request
->getRequestUri();
$newPath = substr($uri, strlen($identifier) + 1);
$request->server
->set('REQUEST_URI', $newPath);
}
public function enterContext($modifier, $path, array &$options) {
return '/' . $modifier . $path;
}
public function exitContext($modifier, $path, array &$options) {
if (!$this
->pathContains($modifier, $path)) {
return null;
}
return substr($path, 0, strlen($modifier) + 1);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PathPrefixMethod:: |
public | function |
Overrides RequestAlteringInterface:: |
|
PathPrefixMethod:: |
public | function |
Overrides MethodInterface:: |
|
PathPrefixMethod:: |
public | function |
Overrides MethodInterface:: |
|
PathPrefixMethod:: |
public | function |
Overrides MethodInterface:: |
|
PathPrefixMethod:: |
private | function |