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