public function AliasGet::buildResponseObject in Services 8.4
Same name and namespace in other branches
- 9.0.x src/Plugin/ServiceDefinition/AliasGet.php \Drupal\services\Plugin\ServiceDefinition\AliasGet::buildResponseObject()
Builds the response object to be returned. This will be a node.
Parameters
$request:
Return value
\Symfony\Component\HttpFoundation\Response
1 call to AliasGet::buildResponseObject()
- AliasGet::processRequest in src/
Plugin/ ServiceDefinition/ AliasGet.php - Processes the request and returns an array of data as appropriate.
File
- src/
Plugin/ ServiceDefinition/ AliasGet.php, line 75
Class
- AliasGet
- Plugin annotation @ServiceDefinition( id = "alias_get", methods = { "GET" }, translatable = true, deriver = "\Drupal\services\Plugin\Deriver\AliasGet" )
Namespace
Drupal\services\Plugin\ServiceDefinitionCode
public function buildResponseObject($request) {
$alias = $request->query
->get('path');
$path = $this->aliasManager
->getPathByAlias($alias);
// If $path does not contain /node/ it's a result of no alias existing
// for any nodes in Drupal.
if (!strstr('/node/', $path)) {
throw new HttpException(404);
}
$parts = explode('/', $path);
$this->entity = Node::load($parts[2]);
return TRUE;
}