MediaWiki REL1_34
Finder.php
Go to the documentation of this file.
1<?php
8namespace LocalisationUpdate;
9
14class Finder {
18 private $json;
19
23 private $core;
24
29 public function __construct( $json, $core ) {
30 $this->json = $json;
31 $this->core = $core;
32 }
33
37 public function getComponents() {
38 $components = [];
39
40 foreach ( $this->json as $key => $value ) {
41 foreach ( (array)$value as $subkey => $subvalue ) {
42 // Mediawiki core files
43 $matches = [];
44 if ( preg_match( '~/(?P<path>(?:includes|languages|resources)/.*)$~', $subvalue, $matches ) ) {
45 $components["$key-$subkey"] = [
46 'repo' => 'mediawiki',
47 'orig' => "file://$value/*.json",
48 'path' => "{$matches['path']}/*.json",
49 ];
50 continue;
51 }
52
53 $item = $this->getItem( 'extensions', $subvalue );
54 if ( $item !== null ) {
55 $item['repo'] = 'extension';
56 $components["$key-$subkey"] = $item;
57 continue;
58 }
59
60 $item = $this->getItem( 'skins', $subvalue );
61 if ( $item !== null ) {
62 $item['repo'] = 'skin';
63 $components["$key-$subkey"] = $item;
64 continue;
65 }
66 }
67 }
68
69 return $components;
70 }
71
77 private function getItem( $dir, $subvalue ) {
78 // This ignores magic, alias etc. non message files
79 $matches = [];
80 if ( !preg_match( "~/$dir/(?P<name>[^/]+)/(?P<path>.*)$~", $subvalue, $matches ) ) {
81 return null;
82 }
83
84 return [
85 'name' => $matches['name'],
86 'orig' => "file://$subvalue/*.json",
87 'path' => "{$matches['path']}/*.json",
88 ];
89 }
90}
Interface for classes which provide list of components, which should be included for l10n updates.
Definition Finder.php:14
__construct( $json, $core)
Definition Finder.php:29
getItem( $dir, $subvalue)
Definition Finder.php:77