Completed
Pull Request — master (#16)
by Sergii
03:53
created

DrupalKernelPlaceholderBase   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 18
c 0
b 0
f 0
wmc 3
lcom 0
cbo 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A drupalGetFilename() 0 4 1
A fileUnmanagedDelete() 0 4 1
A fileUnmanagedCopy() 0 4 1
1
<?php
2
/**
3
 * @author Sergii Bondarenko, <[email protected]>
4
 */
5
6
use Behat\Behat\Hook\Scope\BeforeFeatureScope;
7
use Drupal\TqExtension\Context\TqContext;
8
9
// @codingStandardsIgnoreStart
10
interface DrupalKernelPlaceholderInterface
11
// @codingStandardsIgnoreEnd
12
{
13
    /**
14
     * Version-related implementation of @BeforeFeature hook for TqContext.
15
     *
16
     * @param BeforeFeatureScope $scope
17
     *
18
     * @see TqContext::beforeFeature()
19
     */
20
    public static function beforeFeature(BeforeFeatureScope $scope);
21
22
    public static function t($string, array $args = [], array $options = []);
23
24
    public static function arg();
25
26
    public static function formatString($string, array $args = []);
27
28
    public static function tokenReplace($text, array $data = [], array $options = []);
29
30
    public static function sitePath();
31
32
    public static function jsonEncode($data);
33
34
    public static function setCurrentUser($user);
35
36
    public static function setCurrentPath($path);
37
38
    /**
39
     * Locate user ID by its name.
40
     *
41
     * @param string $username
42
     *
43
     * @return int
44
     */
45
    public static function getUidByName($username);
46
47
    /**
48
     * @param int $user_id
49
     */
50
    public static function deleteUser($user_id);
51
52
    /**
53
     * @param string $table
54
     * @param string $alias
55
     * @param array $options
56
     *
57
     * @return object
58
     */
59
    public static function selectQuery($table, $alias = null, array $options = []);
60
61
    /**
62
     * @param string $entityType
63
     * @param string $bundle
64
     *
65
     * @return array[]
66
     *   An associative array where key - machine-name of a field and
67
     *   value - an array with two keys: "label" and "required".
68
     */
69
    public static function getFieldDefinitions($entityType, $bundle);
70
71
    /**
72
     * Get information about database connections.
73
     *
74
     * Impossible to use $GLOBALS['databases'] in Drupal 8 since {@link https://www.drupal.org/node/2176621}.
75
     *
76
     * @param string $connection
77
     *   Connection name.
78
     *
79
     * @return array[]
80
     */
81
    public static function getDatabaseConnectionInfo($connection);
82
83
    /**
84
     * @param string $entityType
85
     * @param int $id
86
     *
87
     * @return object
88
     */
89
    public static function entityLoad($entityType, $id);
90
91
    /**
92
     * @param object $entity
93
     * @param string $fieldName
94
     *
95
     * @return bool
96
     */
97
    public static function entityHasField($entity, $fieldName);
98
99
    /**
100
     * @param object $entity
101
     * @param string $fieldName
102
     *
103
     * @return mixed
104
     */
105
    public static function entityFieldValue($entity, $fieldName);
106
107
    /**
108
     * Switching the mail system.
109
     *
110
     * @param bool $useTesting
111
     *   Whether testing or standard mail system should be used.
112
     */
113
    public static function switchMailSystem($useTesting);
114
115
    /**
116
     * Get a list of emails, collected by testing mail system.
117
     *
118
     * @return array
119
     */
120
    public static function getEmailMessages();
121
122
    /**
123
     * Check existence of the content type by its machine name or title.
124
     *
125
     * @param string $contentType
126
     *   Machine name or title of the content type.
127
     *
128
     * @return string
129
     *   Machine name.
130
     */
131
    public static function getContentTypeName($contentType);
132
133
    /**
134
     * @param string $file
135
     *   Existing file from "src/JavaScript" without ".js" extension.
136
     * @param bool $delete
137
     *   Whether injection should be deleted.
138
     */
139
    public static function injectCustomJavascript($file, $delete = false);
140
}
141
142
// @codingStandardsIgnoreStart
143
abstract class DrupalKernelPlaceholderBase implements DrupalKernelPlaceholderInterface
144
// @codingStandardsIgnoreEnd
145
{
146
    public static function drupalGetFilename($type, $name, $filename = null)
147
    {
148
        return drupal_get_filename($type, $name, $filename);
149
    }
150
151
    public static function fileUnmanagedDelete($path)
152
    {
153
        return file_unmanaged_delete($path);
154
    }
155
156
    public static function fileUnmanagedCopy($source, $destination = null, $replace = FILE_EXISTS_RENAME)
157
    {
158
        return file_unmanaged_copy($source, $destination, $replace);
159
    }
160
}
161