Mercurial > hg > cmmr2012-drupal-site
comparison vendor/chi-teck/drupal-code-generator/src/LegacyUtilsTrait.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
1 <?php | |
2 | |
3 namespace DrupalCodeGenerator; | |
4 | |
5 /** | |
6 * Contains deprecated Utils methods. | |
7 */ | |
8 trait LegacyUtilsTrait { | |
9 | |
10 /** | |
11 * Returns default questions for module generators. | |
12 * | |
13 * @return \Symfony\Component\Console\Question\Question[] | |
14 * Array of default questions. | |
15 * | |
16 * @deprecated Use Utils::moduleQuestions(). | |
17 */ | |
18 public static function defaultQuestions() { | |
19 @trigger_error('Utils::defaultQuestions() method is deprecated.', E_USER_DEPRECATED); | |
20 return static::moduleQuestions(); | |
21 } | |
22 | |
23 /** | |
24 * Returns default questions for plugin generators. | |
25 * | |
26 * @return \Symfony\Component\Console\Question\Question[] | |
27 * Array of default questions. | |
28 * | |
29 * @deprecated Use Utils::moduleQuestions() and Utils::pluginQuestions(). | |
30 */ | |
31 public static function defaultPluginQuestions() { | |
32 @trigger_error('Utils::defaultPluginQuestions() method is deprecated.', E_USER_DEPRECATED); | |
33 $plugin_questions = static::pluginQuestions(); | |
34 // Plugin class question wasn't in original method implementation. | |
35 unset($plugin_questions['class']); | |
36 return static::moduleQuestions() + $plugin_questions; | |
37 } | |
38 | |
39 /** | |
40 * Returns normalized file path. | |
41 * | |
42 * @codeCoverageIgnore | |
43 * @deprecated | |
44 */ | |
45 public static function normalizePath($path) { | |
46 $parts = []; | |
47 $path = str_replace('\\', '/', $path); | |
48 $path = preg_replace('/\/+/', '/', $path); | |
49 $segments = explode('/', $path); | |
50 foreach ($segments as $segment) { | |
51 if ($segment != '.') { | |
52 $test = array_pop($parts); | |
53 if (is_null($test)) { | |
54 $parts[] = $segment; | |
55 } | |
56 elseif ($segment == '..') { | |
57 if ($test == '..') { | |
58 $parts[] = $test; | |
59 } | |
60 if ($test == '..' || $test == '') { | |
61 $parts[] = $segment; | |
62 } | |
63 } | |
64 else { | |
65 $parts[] = $test; | |
66 $parts[] = $segment; | |
67 } | |
68 } | |
69 } | |
70 return implode('/', $parts); | |
71 } | |
72 | |
73 /** | |
74 * Replaces all tokens in a given string with appropriate values. | |
75 * | |
76 * @param string $text | |
77 * A string potentially containing replaceable tokens. | |
78 * @param array $data | |
79 * An array where keys are token names and values are replacements. | |
80 * | |
81 * @return string | |
82 * Text with tokens replaced. | |
83 * | |
84 * @deprecated Use Utils::replaceTokens instead. | |
85 */ | |
86 public static function tokenReplace($text, array $data) { | |
87 return static::replaceTokens($text, $data); | |
88 } | |
89 | |
90 } |