public ConfigDependencies::calculateDependencies(RestResourceConfigInterface $rest_config)
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\Entity
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | 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 ; } |
Please login to continue.