Completed
Pull Request — master (#16)
by Sergii
03:45
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
     * @param string $entityType
73
     * @param int $id
74
     *
75
     * @return object
76
     */
77
    public static function entityLoad($entityType, $id);
78
79
    /**
80
     * @param object $entity
81
     * @param string $fieldName
82
     *
83
     * @return bool
84
     */
85
    public static function entityHasField($entity, $fieldName);
86
87
    /**
88
     * @param object $entity
89
     * @param string $fieldName
90
     *
91
     * @return mixed
92
     */
93
    public static function entityFieldValue($entity, $fieldName);
94
95
    /**
96
     * Switching the mail system.
97
     *
98
     * @param bool $useTesting
99
     *   Whether testing or standard mail system should be used.
100
     */
101
    public static function switchMailSystem($useTesting);
102
103
    /**
104
     * Get a list of emails, collected by testing mail system.
105
     *
106
     * @return array
107
     */
108
    public static function getEmailMessages();
109
110
    /**
111
     * Check existence of the content type by its machine name or title.
112
     *
113
     * @param string $contentType
114
     *   Machine name or title of the content type.
115
     *
116
     * @return string
117
     *   Machine name.
118
     */
119
    public static function getContentTypeName($contentType);
120
121
    /**
122
     * @param string $file
123
     *   Existing file from "src/JavaScript" without ".js" extension.
124
     * @param bool $delete
125
     *   Whether injection should be deleted.
126
     */
127
    public static function injectCustomJavascript($file, $delete = false);
128
}
129
130
// @codingStandardsIgnoreStart
131
abstract class DrupalKernelPlaceholderBase implements DrupalKernelPlaceholderInterface
132
// @codingStandardsIgnoreEnd
133
{
134
    public static function drupalGetFilename($type, $name, $filename = null)
135
    {
136
        return drupal_get_filename($type, $name, $filename);
137
    }
138
139
    public static function fileUnmanagedDelete($path)
140
    {
141
        return file_unmanaged_delete($path);
142
    }
143
144
    public static function fileUnmanagedCopy($source, $destination = null, $replace = FILE_EXISTS_RENAME)
145
    {
146
        return file_unmanaged_copy($source, $destination, $replace);
147
    }
148
}
149