Skip to content
Snippets Groups Projects

Fixed Drupal calls.

6 files
+ 136
30
Compare changes
  • Side-by-side
  • Inline

Files

+ 22
5
@@ -16,6 +16,8 @@ use Drupal\Core\Url;
use Fhaculty\Graph\Graph;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Drupal\field_tools\FieldToolsReferencesInfo;
use Drupal\Core\Extension\ModuleHandlerInterface;
/**
* Outputs a graph of entity reference fields.
@@ -25,6 +27,15 @@ class FieldGraph implements ContainerInjectionInterface, FormInterface {
use StringTranslationTrait;
use FieldListTrait;
protected $fieldreferences;
/**
* The module handler service.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected $moduleHandler;
/**
* The request stack.
*
@@ -79,13 +90,17 @@ class FieldGraph implements ContainerInjectionInterface, FormInterface {
RouteMatchInterface $route_match,
EntityTypeManagerInterface $entity_type_manager,
EntityTypeBundleInfoInterface $entity_bundle_info,
FormBuilderInterface $form_builder
FormBuilderInterface $form_builder,
FieldToolsReferencesInfo $field_references,
ModuleHandlerInterface $module_handler
) {
$this->requestStack = $request_stack;
$this->currentRoute = $route_match->getRouteName();
$this->entityTypeManager = $entity_type_manager;
$this->entityBundleInfo = $entity_bundle_info;
$this->formBuilder = $form_builder;
$this->fieldreferences = $field_references;
$this->moduleHandler = $module_handler;
}
/**
@@ -98,6 +113,8 @@ class FieldGraph implements ContainerInjectionInterface, FormInterface {
$container->get('entity_type.manager'),
$container->get('entity_type.bundle.info'),
$container->get('form_builder'),
$container->get('field_tools.references.info'),
$container->get('module_handler')
);
}
@@ -109,7 +126,7 @@ class FieldGraph implements ContainerInjectionInterface, FormInterface {
$build['form_container']['form'] = $this->formBuilder->getForm($this);
if (!\Drupal::service('module_handler')->moduleExists('mermaid')) {
if (!$this->moduleHandler->moduleExists('mermaid')) {
$build['message'] = [
'#markup' => $this->t('This feature requires Graph API and Mermaid modules.'),
];
@@ -121,7 +138,7 @@ class FieldGraph implements ContainerInjectionInterface, FormInterface {
$index = 0;
$reference_types_filter = $this->requestStack->getCurrentRequest()->query->get('reference_types');
$reference_field_definitions = \Drupal::service('field_tools.references.info')->getReferenceFields(
$reference_field_definitions = $this->fieldreferences->getReferenceFields(
!empty($reference_types_filter['files']),
!empty($reference_types_filter['owners']),
!empty($reference_types_filter['config'])
@@ -130,7 +147,7 @@ class FieldGraph implements ContainerInjectionInterface, FormInterface {
$reference_targets = [];
foreach ($reference_field_definitions as $field_definition) {
$field_referenced_bundles = \Drupal::service('field_tools.references.info')->getReferencedBundles($field_definition);
$field_referenced_bundles = $this->fieldreferences->getReferencedBundles($field_definition);
foreach ($field_referenced_bundles as $target) {
$reference_targets[$target] = TRUE;
@@ -149,7 +166,7 @@ class FieldGraph implements ContainerInjectionInterface, FormInterface {
$graph_nodes[$source_vertex_name] = $graph->createVertex($source_vertex_name);
}
$field_referenced_bundles = \Drupal::service('field_tools.references.info')->getReferencedBundles($field_definition);
$field_referenced_bundles = $this->fieldreferences->getReferencedBundles($field_definition);
foreach ($field_referenced_bundles as $target_vertex_name) {
$target_vertex_name = str_replace(':', '-', $target_vertex_name);
Loading