ResourceFieldEnhancerManager.php in JSON:API Extras 8.3
File
src/Plugin/ResourceFieldEnhancerManager.php
View source
<?php
namespace Drupal\jsonapi_extras\Plugin;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\DefaultPluginManager;
class ResourceFieldEnhancerManager extends DefaultPluginManager {
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
parent::__construct('Plugin/jsonapi/FieldEnhancer', $namespaces, $module_handler, 'Drupal\\jsonapi_extras\\Plugin\\ResourceFieldEnhancerInterface', 'Drupal\\jsonapi_extras\\Annotation\\ResourceFieldEnhancer');
$this
->alterInfo('resource_field_enhancer_info');
$this
->setCacheBackend($cache_backend, 'resource_field_enhancer_plugins');
}
protected function alterDefinitions(&$definitions) {
foreach ($definitions as $definition_key => $definition_info) {
if (!empty($definition_info['dependencies'])) {
$definition_dependencies = $definition_info['dependencies'];
foreach ($definition_dependencies as $dependency) {
if (!$this->moduleHandler
->moduleExists($dependency)) {
unset($definitions[$definition_key]);
continue;
}
}
}
}
parent::alterDefinitions($definitions);
}
}