TargetInterface.php
2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
namespace Drupal\drupalmoduleupgrader;
use Pharborist\Node;
/**
* Represents a Drupal 7 module being run through the DMU.
*/
interface TargetInterface {
/**
* Returns the machine name of the target module.
*
* @return string
*/
public function id();
/**
* Returns the base path of the target module.
*
* @return string
*/
public function getBasePath();
/**
* Returns the path to a particular file, relative to the CWD.
*
* @param string $file
* The file, relative to the module root. If $file begins with a period,
* it will be prefixed with the module name (.module --> MODULE.module)
*
* @return string
*/
public function getPath($file);
/**
* Returns a fully configured Finder which can iterate over the target
* module's code files. Any file type which doesn't contain PHP code
* should be ignored.
*
* @return \Symfony\Component\Finder\Finder
*/
public function getFinder();
/**
* Returns an indexer for this target.
*
* @param string $which
* The type of indexer to get. Should be the ID of an indexer plugin.
*
* @return IndexerInterface
*/
public function getIndexer($which);
/**
* Returns services defined by the target module.
*
* @return \Doctrine\Common\Collections\ArrayCollection
*/
public function getServices();
/**
* Returns if the target module implements a particular hook.
*
* @param string $hook
* The hook to look for, without the hook_ prefix.
*
* @return boolean
*/
public function implementsHook($hook);
/**
* Executes a hook implementation and returns the result.
*
* @param string $hook
* The hook to execute, without the hook_ prefix.
* @param array $arguments
* Additional parameters to pass to the hook implementation.
*
* @return mixed
*
* @throws
* \InvalidArgumentException if the module doesn't implement the hook.
* \LogicException if the hook contains non-executable logic.
*/
public function executeHook($hook, array $arguments = []);
/**
* Parses a file into a syntax tree, keeping a reference to it, and
* returns it.
*
* @param string $file
* The path of the file to open, relative to the CWD.
*
* @return \Pharborist\RootNode|NULL
*/
public function open($file);
/**
* Saves the file in which a particular node appears.
*
* @param \Pharborist\Node|NULL $node
* The node to save. This can be positioned anywhere in the
* syntax tree. If NULL, all open files will be saved.
*
* @throws \Drupal\drupalmoduleupgrader\IOException
*/
public function save(Node $node = NULL);
/**
* Creates a new, empty document.
*
* @param string $file
* The path of the file to create, relative to the CWD.
*
* @return \Pharborist\RootNode
*/
public function create($file);
/**
* Clears internal references to all open documents, discarding changes.
*/
public function flush();
}