|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @file |
|
5
|
|
|
* Contains df_tools_acquiadam.module. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
use Drupal\Core\Entity\EntityInterface; |
|
|
|
|
|
|
9
|
|
|
use Drupal\Core\Form\FormStateInterface; |
|
10
|
|
|
use Drupal\media\MediaInterface; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Implements hook_form_alter(). |
|
14
|
|
|
*/ |
|
15
|
|
|
function df_tools_acquiadam_form_alter(&$form, FormStateInterface $form_state, $form_id) { |
|
|
|
|
|
|
16
|
|
|
$dam_add_forms = '/^media_acquia_dam_.*_add_form$/'; |
|
17
|
|
|
$dam_edit_forms = '/^media_acquia_dam_.*_edit_form$/'; |
|
18
|
|
|
|
|
19
|
|
|
// Hide DAM fields when creating DAM media entities. |
|
20
|
|
|
if (preg_match($dam_add_forms, $form_id)) { |
|
21
|
|
|
$fields_to_hide = [ |
|
22
|
|
|
'name', |
|
23
|
|
|
'acquia_dam_asset_id', |
|
24
|
|
|
'acquia_dam_alt_text', |
|
25
|
|
|
'status', |
|
26
|
|
|
]; |
|
27
|
|
|
foreach ($fields_to_hide as $field) { |
|
28
|
|
|
if (isset($form[$field])) { |
|
29
|
|
|
$form[$field]['#access'] = FALSE; |
|
30
|
|
|
} |
|
31
|
|
|
} |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
// Disable DAM fields when editing DAM media entities. |
|
35
|
|
|
if (preg_match($dam_edit_forms, $form_id)) { |
|
36
|
|
|
$fields_to_disable = [ |
|
37
|
|
|
'name', |
|
38
|
|
|
'acquia_dam_alt_text', |
|
39
|
|
|
]; |
|
40
|
|
|
foreach ($fields_to_disable as $field) { |
|
41
|
|
|
if (isset($form[$field])) { |
|
42
|
|
|
$form[$field]['#disabled'] = TRUE; |
|
43
|
|
|
} |
|
44
|
|
|
} |
|
45
|
|
|
} |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Implements hook_entity_operation_alter(). |
|
50
|
|
|
*/ |
|
51
|
|
|
function df_tools_acquiadam_entity_operation_alter(array &$operations, EntityInterface $entity) { |
|
52
|
|
|
// Remove the clone operation for DAM media entities. |
|
53
|
|
|
$entityTypeId = $entity->getEntityTypeId(); |
|
54
|
|
|
$bundle = $entity->bundle(); |
|
55
|
|
|
|
|
56
|
|
|
if ($entityTypeId == 'media' || strpos($bundle, 'acquia_dam_') === 0) { |
|
57
|
|
|
unset($operations['clone']); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Implements hook_menu_local_tasks_alter(). |
|
63
|
|
|
*/ |
|
64
|
|
|
function df_tools_acquiadam_menu_local_tasks_alter(&$data, $route_name) { |
|
65
|
|
|
// Remove the clone operation for DAM media entities. |
|
66
|
|
|
$routes = ['entity.media.edit_form', 'entity.media.canonical']; |
|
67
|
|
|
if (in_array($route_name, $routes)) { |
|
68
|
|
|
$route_match = \Drupal::routeMatch(); |
|
69
|
|
|
$media = $route_match->getParameter('media'); |
|
70
|
|
|
|
|
71
|
|
|
if ($media instanceof MediaInterface && strpos($media->bundle(), 'acquia_dam_') === 0) { |
|
72
|
|
|
unset($data['tabs'][0]['entity_clone.clone:media.clone_tab']); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths