function ConfigDependencies::calculateDependencies
Same name in other branches
- 9 core/modules/rest/src/Entity/ConfigDependencies.php \Drupal\rest\Entity\ConfigDependencies::calculateDependencies()
- 8.9.x core/modules/rest/src/Entity/ConfigDependencies.php \Drupal\rest\Entity\ConfigDependencies::calculateDependencies()
- 11.x core/modules/rest/src/Entity/ConfigDependencies.php \Drupal\rest\Entity\ConfigDependencies::calculateDependencies()
Calculates dependencies of a specific rest resource configuration.
This function returns dependencies in a non-sorted, non-unique manner. It is therefore the caller's responsibility to sort and remove duplicates from the result prior to saving it with the configuration or otherwise using it in a way that requires that. For example, \Drupal\rest\Entity\RestResourceConfig::calculateDependencies() does this via its \Drupal\Core\Entity\DependencyTrait::addDependency() method.
Parameters
\Drupal\rest\RestResourceConfigInterface $rest_config: The rest configuration.
Return value
string[][] Dependencies keyed by dependency type.
See also
\Drupal\rest\Entity\RestResourceConfig::calculateDependencies()
File
-
core/
modules/ rest/ src/ Entity/ ConfigDependencies.php, line 71
Class
- ConfigDependencies
- Calculates rest resource config dependencies.
Namespace
Drupal\rest\EntityCode
public function calculateDependencies(RestResourceConfigInterface $rest_config) {
$granularity = $rest_config->get('granularity');
// Dependency calculation is the same for either granularity, the most
// notable difference is that for the 'resource' granularity, the same
// authentication providers and formats are supported for every method.
switch ($granularity) {
case RestResourceConfigInterface::METHOD_GRANULARITY:
$methods = $rest_config->getMethods();
break;
case RestResourceConfigInterface::RESOURCE_GRANULARITY:
$methods = array_slice($rest_config->getMethods(), 0, 1);
break;
default:
throw new \InvalidArgumentException('Invalid granularity specified.');
}
// The dependency lists for authentication providers and formats
// generated on container build.
$dependencies = [];
foreach ($methods as $request_method) {
// Add dependencies based on the supported authentication providers.
foreach ($rest_config->getAuthenticationProviders($request_method) as $auth) {
if (isset($this->authProviders[$auth])) {
$module_name = $this->authProviders[$auth];
$dependencies['module'][] = $module_name;
}
}
// Add dependencies based on the supported authentication formats.
foreach ($rest_config->getFormats($request_method) as $format) {
if (isset($this->formatProviders[$format])) {
$module_name = $this->formatProviders[$format];
$dependencies['module'][] = $module_name;
}
}
}
return $dependencies;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.