|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
use Drupal\user\Entity\User; |
|
|
|
|
|
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* @file |
|
7
|
|
|
* Contains core functionality for the DF distribution. |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Implements hook_module_implements_alter(). |
|
12
|
|
|
* |
|
13
|
|
|
* @todo Remove after #2635978 is fixed. |
|
14
|
|
|
*/ |
|
15
|
|
|
function df_core_module_implements_alter(&$implementations, $hook) { |
|
16
|
|
|
// Disable block initialization/inheritance for themes enabled after Lightning |
|
17
|
|
|
// is installed in order to prevent blocks associated with the profile from |
|
18
|
|
|
// bleeding over into scenarios. |
|
19
|
|
|
if ($hook == 'themes_installed') { |
|
20
|
|
|
unset($implementations['block']); |
|
21
|
|
|
} |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Implements hook_menu_local_tasks_alter(). |
|
26
|
|
|
*/ |
|
27
|
|
|
function df_core_menu_local_tasks_alter(&$data, $route_name) { |
|
|
|
|
|
|
28
|
|
|
// Core doesn't currently clean up local tasks created via Views when the View |
|
29
|
|
|
// is disabled/deleted. Remove the core file listing view's local tasks in |
|
30
|
|
|
// order to prevent duplicate 'Files' tabs from appear on admin/content. |
|
31
|
|
|
// @todo: remove this when https://www.drupal.org/node/2027043 is fixed. |
|
32
|
|
|
if (!empty($data['tabs'])) { |
|
33
|
|
|
foreach ($data['tabs'] as $tab_level => $tabs) { |
|
34
|
|
|
foreach ($tabs as $href => $tab_data) { |
|
35
|
|
|
if ($href == 'views_view:view.files.page_1') { |
|
36
|
|
|
$data['tabs'][$tab_level][$href]['#access'] = FALSE; |
|
37
|
|
|
} |
|
38
|
|
|
} |
|
39
|
|
|
} |
|
40
|
|
|
} |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Implements hook_requirements(). |
|
45
|
|
|
*/ |
|
46
|
|
|
function df_requirements($phase) { |
|
|
|
|
|
|
47
|
|
|
if (phpversion() < '7.1') { |
|
48
|
|
|
$requirements = []; |
|
49
|
|
|
$requirements['df_requirements'] = [ |
|
50
|
|
|
'title' => t('DF REQUIREMENTS'), |
|
51
|
|
|
'value' => t("Your PHP installation is too old."), |
|
52
|
|
|
'description' => t("This build requires your cloud env to run PHP7.1+"), |
|
53
|
|
|
'severity' => REQUIREMENT_ERROR, |
|
54
|
|
|
]; |
|
55
|
|
|
return $requirements; |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: