1 | <?php |
||
14 | class VueJs extends JsCode implements ExtractorInterface |
||
15 | { |
||
16 | /** |
||
17 | * @inheritdoc |
||
18 | * @throws \Exception |
||
19 | */ |
||
20 | public static function fromString($string, Translations $translations, array $options = []) |
||
69 | |||
70 | /** |
||
71 | * @param string $html |
||
72 | * @return DOMDocument |
||
73 | */ |
||
74 | private static function convertHtmlToDom($html) |
||
85 | |||
86 | /** |
||
87 | * Extract translations from script part |
||
88 | * |
||
89 | * @param string $scriptContents Only script tag contents, not the whole template |
||
90 | * @param Translations $translations |
||
91 | * @param array $options |
||
92 | * @param int $lineOffset Number of lines the script is offset in the vue template file |
||
93 | * @throws \Exception |
||
94 | */ |
||
95 | private static function getScriptTranslationsFromString( |
||
105 | |||
106 | /** |
||
107 | * Parse template to extract all translations (element content and dynamic element attributes) |
||
108 | * |
||
109 | * @param DOMElement $dom |
||
110 | * @param Translations $translations |
||
111 | * @param array $options |
||
112 | * @param int $lineOffset Line number where the template part starts in the vue file |
||
113 | * @throws \Exception |
||
114 | */ |
||
115 | private static function getTemplateTranslations( |
||
131 | |||
132 | /** |
||
133 | * Extract JS expressions from element attribute bindings (excluding text within elements) |
||
134 | * For example: <span :title="__('extract this')"> skip element content </span> |
||
135 | * |
||
136 | * @param array $options |
||
137 | * @param DOMElement $dom |
||
138 | * @return string JS code |
||
139 | */ |
||
140 | private static function getTemplateAttributeFakeJs(array $options, DOMElement $dom) |
||
156 | |||
157 | /** |
||
158 | * Loop DOM element recursively and parse out all dynamic vue attributes which are basically JS expressions |
||
159 | * |
||
160 | * @param array $attributePrefixes List of attribute prefixes we parse as JS (may contain translations) |
||
161 | * @param DOMElement $dom |
||
162 | * @param array $expressionByLine [lineNumber => [jsExpression, ..], ..] |
||
163 | * @return array [lineNumber => [jsExpression, ..], ..] |
||
164 | */ |
||
165 | private static function getVueAttributeExpressions( |
||
200 | |||
201 | /** |
||
202 | * Check if this attribute name should be parsed for translations |
||
203 | * |
||
204 | * @param string $attributeName |
||
205 | * @param string[] $attributePrefixes |
||
206 | * @return bool |
||
207 | */ |
||
208 | private static function isAttributeMatching($attributeName, $attributePrefixes) |
||
217 | |||
218 | /** |
||
219 | * Extract JS expressions from within template elements (excluding attributes) |
||
220 | * For example: <span :title="skip attributes"> {{__("extract element content")}} </span> |
||
221 | * |
||
222 | * @param DOMElement $dom |
||
223 | * @return string JS code |
||
224 | */ |
||
225 | private static function getTemplateFakeJs(DOMElement $dom) |
||
239 | |||
240 | /** |
||
241 | * Match JS expressions in a template line |
||
242 | * |
||
243 | * @param string $line |
||
244 | * @return string[] |
||
245 | */ |
||
246 | private static function parseOneTemplateLine($line) |
||
264 | } |
||
265 |
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.