aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer')
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/BundleTransformer.php96
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/CompilationContext.php97
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/CompilationContextInterface.php56
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/CurrencyBundleTransformationRule.php94
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LanguageBundleTransformationRule.php71
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LocaleBundleTransformationRule.php251
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/RegionBundleTransformationRule.php70
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/TransformationRuleInterface.php70
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/StubbingContext.php80
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/StubbingContextInterface.php46
10 files changed, 0 insertions, 931 deletions
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/BundleTransformer.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/BundleTransformer.php
deleted file mode 100644
index 0692d6fe..00000000
--- a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/BundleTransformer.php
+++ /dev/null
@@ -1,96 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Intl\ResourceBundle\Transformer;
13
14use Symfony\Component\Intl\Exception\RuntimeException;
15use Symfony\Component\Intl\ResourceBundle\Transformer\Rule\TransformationRuleInterface;
16use Symfony\Component\Intl\ResourceBundle\Writer\PhpBundleWriter;
17
18/**
19 * Compiles a number of resource bundles based on predefined compilation rules.
20 *
21 * @author Bernhard Schussek <bschussek@gmail.com>
22 */
23class BundleTransformer
24{
25 /**
26 * @var TransformationRuleInterface[]
27 */
28 private $rules = array();
29
30 /**
31 * Adds a new compilation rule.
32 *
33 * @param TransformationRuleInterface $rule The compilation rule.
34 */
35 public function addRule(TransformationRuleInterface $rule)
36 {
37 $this->rules[] = $rule;
38 }
39
40 /**
41 * Runs the compilation with the given compilation context.
42 *
43 * @param CompilationContextInterface $context The context storing information
44 * needed to run the compilation.
45 *
46 * @throws RuntimeException If any of the files to be compiled by the loaded
47 * compilation rules does not exist.
48 */
49 public function compileBundles(CompilationContextInterface $context)
50 {
51 $filesystem = $context->getFilesystem();
52 $compiler = $context->getCompiler();
53
54 $filesystem->remove($context->getBinaryDir());
55 $filesystem->mkdir($context->getBinaryDir());
56
57 foreach ($this->rules as $rule) {
58 $filesystem->mkdir($context->getBinaryDir() . '/' . $rule->getBundleName());
59
60 $resources = (array) $rule->beforeCompile($context);
61
62 foreach ($resources as $resource) {
63 if (!file_exists($resource)) {
64 throw new RuntimeException(sprintf(
65 'The file "%s" to be compiled by %s does not exist.',
66 $resource,
67 get_class($rule)
68 ));
69 }
70
71 $compiler->compile($resource, $context->getBinaryDir() . '/' . $rule->getBundleName());
72 }
73
74 $rule->afterCompile($context);
75 }
76 }
77
78 public function createStubs(StubbingContextInterface $context)
79 {
80 $filesystem = $context->getFilesystem();
81 $phpWriter = new PhpBundleWriter();
82
83 $filesystem->remove($context->getStubDir());
84 $filesystem->mkdir($context->getStubDir());
85
86 foreach ($this->rules as $rule) {
87 $filesystem->mkdir($context->getStubDir() . '/' . $rule->getBundleName());
88
89 $data = $rule->beforeCreateStub($context);
90
91 $phpWriter->write($context->getStubDir() . '/' . $rule->getBundleName(), 'en', $data);
92
93 $rule->afterCreateStub($context);
94 }
95 }
96}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/CompilationContext.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/CompilationContext.php
deleted file mode 100644
index cdc1951b..00000000
--- a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/CompilationContext.php
+++ /dev/null
@@ -1,97 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Intl\ResourceBundle\Transformer;
13
14use Symfony\Component\Filesystem\Filesystem;
15use Symfony\Component\Intl\ResourceBundle\Compiler\BundleCompilerInterface;
16
17/**
18 * Default implementation of {@link CompilationContextInterface}.
19 *
20 * @author Bernhard Schussek <bschussek@gmail.com>
21 */
22class CompilationContext implements CompilationContextInterface
23{
24 /**
25 * @var string
26 */
27 private $sourceDir;
28
29 /**
30 * @var string
31 */
32 private $binaryDir;
33
34 /**
35 * @var FileSystem
36 */
37 private $filesystem;
38
39 /**
40 * @var BundleCompilerInterface
41 */
42 private $compiler;
43
44 /**
45 * @var string
46 */
47 private $icuVersion;
48
49 public function __construct($sourceDir, $binaryDir, Filesystem $filesystem, BundleCompilerInterface $compiler, $icuVersion)
50 {
51 $this->sourceDir = $sourceDir;
52 $this->binaryDir = $binaryDir;
53 $this->filesystem = $filesystem;
54 $this->compiler = $compiler;
55 $this->icuVersion = $icuVersion;
56 }
57
58 /**
59 * {@inheritdoc}
60 */
61 public function getSourceDir()
62 {
63 return $this->sourceDir;
64 }
65
66 /**
67 * {@inheritdoc}
68 */
69 public function getBinaryDir()
70 {
71 return $this->binaryDir;
72 }
73
74 /**
75 * {@inheritdoc}
76 */
77 public function getFilesystem()
78 {
79 return $this->filesystem;
80 }
81
82 /**
83 * {@inheritdoc}
84 */
85 public function getCompiler()
86 {
87 return $this->compiler;
88 }
89
90 /**
91 * {@inheritdoc}
92 */
93 public function getIcuVersion()
94 {
95 return $this->icuVersion;
96 }
97}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/CompilationContextInterface.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/CompilationContextInterface.php
deleted file mode 100644
index f05c2807..00000000
--- a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/CompilationContextInterface.php
+++ /dev/null
@@ -1,56 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Intl\ResourceBundle\Transformer;
13
14/**
15 * Stores contextual information for resource bundle compilation.
16 *
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19interface CompilationContextInterface
20{
21 /**
22 * Returns the directory where the source versions of the resource bundles
23 * are stored.
24 *
25 * @return string An absolute path to a directory.
26 */
27 public function getSourceDir();
28
29 /**
30 * Returns the directory where the binary resource bundles are stored.
31 *
32 * @return string An absolute path to a directory.
33 */
34 public function getBinaryDir();
35
36 /**
37 * Returns a tool for manipulating the filesystem.
38 *
39 * @return \Symfony\Component\Filesystem\Filesystem The filesystem manipulator.
40 */
41 public function getFilesystem();
42
43 /**
44 * Returns a resource bundle compiler.
45 *
46 * @return \Symfony\Component\Intl\ResourceBundle\Compiler\BundleCompilerInterface The loaded resource bundle compiler.
47 */
48 public function getCompiler();
49
50 /**
51 * Returns the ICU version of the bundles being converted.
52 *
53 * @return string The ICU version string.
54 */
55 public function getIcuVersion();
56}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/CurrencyBundleTransformationRule.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/CurrencyBundleTransformationRule.php
deleted file mode 100644
index 95783b3b..00000000
--- a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/CurrencyBundleTransformationRule.php
+++ /dev/null
@@ -1,94 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Intl\ResourceBundle\Transformer\Rule;
13
14use Symfony\Component\Intl\Intl;
15use Symfony\Component\Intl\ResourceBundle\CurrencyBundle;
16use Symfony\Component\Intl\ResourceBundle\Transformer\CompilationContextInterface;
17use Symfony\Component\Intl\ResourceBundle\Transformer\StubbingContextInterface;
18use Symfony\Component\Intl\Util\IcuVersion;
19
20/**
21 * The rule for compiling the currency bundle.
22 *
23 * @author Bernhard Schussek <bschussek@gmail.com>
24 */
25class CurrencyBundleTransformationRule implements TransformationRuleInterface
26{
27 /**
28 * {@inheritdoc}
29 */
30 public function getBundleName()
31 {
32 return 'curr';
33 }
34
35 /**
36 * {@inheritdoc}
37 */
38 public function beforeCompile(CompilationContextInterface $context)
39 {
40 // The currency data is contained in the locales and misc bundles
41 // in ICU <= 4.2
42 if (IcuVersion::compare($context->getIcuVersion(), '4.2', '<=', 1)) {
43 return array(
44 $context->getSourceDir() . '/misc/supplementalData.txt',
45 $context->getSourceDir() . '/locales'
46 );
47 }
48
49 return $context->getSourceDir() . '/curr';
50 }
51
52 /**
53 * {@inheritdoc}
54 */
55 public function afterCompile(CompilationContextInterface $context)
56 {
57 // \ResourceBundle does not like locale names with uppercase chars, so rename
58 // the resource file
59 // See: http://bugs.php.net/bug.php?id=54025
60 $fileName = $context->getBinaryDir() . '/curr/supplementalData.res';
61 $fileNameLower = $context->getBinaryDir() . '/curr/supplementaldata.res';
62
63 $context->getFilesystem()->rename($fileName, $fileNameLower);
64 }
65
66 /**
67 * {@inheritdoc}
68 */
69 public function beforeCreateStub(StubbingContextInterface $context)
70 {
71 $currencies = array();
72 $currencyBundle = Intl::getCurrencyBundle();
73
74 foreach ($currencyBundle->getCurrencyNames('en') as $code => $name) {
75 $currencies[$code] = array(
76 CurrencyBundle::INDEX_NAME => $name,
77 CurrencyBundle::INDEX_SYMBOL => $currencyBundle->getCurrencySymbol($code, 'en'),
78 CurrencyBundle::INDEX_FRACTION_DIGITS => $currencyBundle->getFractionDigits($code),
79 CurrencyBundle::INDEX_ROUNDING_INCREMENT => $currencyBundle->getRoundingIncrement($code),
80 );
81 }
82
83 return array(
84 'Currencies' => $currencies,
85 );
86 }
87
88 /**
89 * {@inheritdoc}
90 */
91 public function afterCreateStub(StubbingContextInterface $context)
92 {
93 }
94}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LanguageBundleTransformationRule.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LanguageBundleTransformationRule.php
deleted file mode 100644
index 5e6f9018..00000000
--- a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LanguageBundleTransformationRule.php
+++ /dev/null
@@ -1,71 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Intl\ResourceBundle\Transformer\Rule;
13
14use Symfony\Component\Intl\Intl;
15use Symfony\Component\Intl\ResourceBundle\Transformer\CompilationContextInterface;
16use Symfony\Component\Intl\ResourceBundle\Transformer\StubbingContextInterface;
17use Symfony\Component\Intl\Util\IcuVersion;
18
19/**
20 * The rule for compiling the language bundle.
21 *
22 * @author Bernhard Schussek <bschussek@gmail.com>
23 */
24class LanguageBundleTransformationRule implements TransformationRuleInterface
25{
26 /**
27 * {@inheritdoc}
28 */
29 public function getBundleName()
30 {
31 return 'lang';
32 }
33
34 /**
35 * {@inheritdoc}
36 */
37 public function beforeCompile(CompilationContextInterface $context)
38 {
39 // The language data is contained in the locales bundle in ICU <= 4.2
40 if (IcuVersion::compare($context->getIcuVersion(), '4.2', '<=', 1)) {
41 return $context->getSourceDir() . '/locales';
42 }
43
44 return $context->getSourceDir() . '/lang';
45 }
46
47 /**
48 * {@inheritdoc}
49 */
50 public function afterCompile(CompilationContextInterface $context)
51 {
52 }
53
54 /**
55 * {@inheritdoc}
56 */
57 public function beforeCreateStub(StubbingContextInterface $context)
58 {
59 return array(
60 'Languages' => Intl::getLanguageBundle()->getLanguageNames('en'),
61 'Scripts' => Intl::getLanguageBundle()->getScriptNames('en'),
62 );
63 }
64
65 /**
66 * {@inheritdoc}
67 */
68 public function afterCreateStub(StubbingContextInterface $context)
69 {
70 }
71}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LocaleBundleTransformationRule.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LocaleBundleTransformationRule.php
deleted file mode 100644
index b2576d6e..00000000
--- a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/LocaleBundleTransformationRule.php
+++ /dev/null
@@ -1,251 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Intl\ResourceBundle\Transformer\Rule;
13
14use Symfony\Component\Intl\Exception\RuntimeException;
15use Symfony\Component\Intl\Intl;
16use Symfony\Component\Intl\ResourceBundle\Transformer\CompilationContextInterface;
17use Symfony\Component\Intl\ResourceBundle\Transformer\StubbingContextInterface;
18use Symfony\Component\Intl\ResourceBundle\Writer\TextBundleWriter;
19
20/**
21 * The rule for compiling the locale bundle.
22 *
23 * @author Bernhard Schussek <bschussek@gmail.com>
24 */
25class LocaleBundleTransformationRule implements TransformationRuleInterface
26{
27 /**
28 * @var \Symfony\Component\Intl\ResourceBundle\LanguageBundleInterface
29 */
30 private $languageBundle;
31
32 /**
33 * @var \Symfony\Component\Intl\ResourceBundle\RegionBundleInterface
34 */
35 private $regionBundle;
36
37 public function __construct()
38 {
39 $this->languageBundle = Intl::getLanguageBundle();
40 $this->regionBundle = Intl::getRegionBundle();
41 }
42
43 /**
44 * {@inheritdoc}
45 */
46 public function getBundleName()
47 {
48 return 'locales';
49 }
50
51 /**
52 * {@inheritdoc}
53 */
54 public function beforeCompile(CompilationContextInterface $context)
55 {
56 $tempDir = sys_get_temp_dir() . '/icu-data-locales';
57
58 $context->getFilesystem()->remove($tempDir);
59 $context->getFilesystem()->mkdir($tempDir);
60
61 $this->generateTextFiles($tempDir, $this->scanLocales($context));
62
63 return $tempDir;
64 }
65
66 /**
67 * {@inheritdoc}
68 */
69 public function afterCompile(CompilationContextInterface $context)
70 {
71 $context->getFilesystem()->remove(sys_get_temp_dir() . '/icu-data-locales');
72 }
73
74 /**
75 * {@inheritdoc}
76 */
77 public function beforeCreateStub(StubbingContextInterface $context)
78 {
79 return array(
80 'Locales' => Intl::getLocaleBundle()->getLocaleNames('en'),
81 );
82 }
83
84 /**
85 * {@inheritdoc}
86 */
87 public function afterCreateStub(StubbingContextInterface $context)
88 {
89 }
90
91 private function scanLocales(CompilationContextInterface $context)
92 {
93 $tempDir = sys_get_temp_dir() . '/icu-data-locales-source';
94
95 $context->getFilesystem()->remove($tempDir);
96 $context->getFilesystem()->mkdir($tempDir);
97
98 // Temporarily generate the resource bundles
99 $context->getCompiler()->compile($context->getSourceDir() . '/locales', $tempDir);
100
101 // Discover the list of supported locales, which are the names of the resource
102 // bundles in the "locales" directory
103 $locales = glob($tempDir . '/*.res');
104
105 // Remove file extension and sort
106 array_walk($locales, function (&$locale) { $locale = basename($locale, '.res'); });
107 sort($locales);
108
109 // Delete unneeded locales
110 foreach ($locales as $key => $locale) {
111 // Delete all aliases from the list
112 // i.e., "az_AZ" is an alias for "az_Latn_AZ"
113 $content = file_get_contents($context->getSourceDir() . '/locales/' . $locale . '.txt');
114
115 // The key "%%ALIAS" is not accessible through the \ResourceBundle class,
116 // so look in the original .txt file instead
117 if (strpos($content, '%%ALIAS') !== false) {
118 unset($locales[$key]);
119 }
120
121 // Delete locales that have no content (i.e. only "Version" key)
122 $bundle = new \ResourceBundle($locale, $tempDir);
123
124 if (null === $bundle) {
125 throw new RuntimeException('The resource bundle for locale ' . $locale . ' could not be loaded from directory ' . $tempDir);
126 }
127
128 // There seems to be no other way for identifying all keys in this specific
129 // resource bundle
130 if (array_keys(iterator_to_array($bundle)) === array('Version')) {
131 unset($locales[$key]);
132 }
133 }
134
135 $context->getFilesystem()->remove($tempDir);
136
137 return $locales;
138 }
139
140 private function generateTextFiles($targetDirectory, array $locales)
141 {
142 $displayLocales = array_unique(array_merge(
143 $this->languageBundle->getLocales(),
144 $this->regionBundle->getLocales()
145 ));
146
147 $txtWriter = new TextBundleWriter();
148
149 // Generate a list of locale names in the language of each display locale
150 // Each locale name has the form: "Language (Script, Region, Variant1, ...)
151 // Script, Region and Variants are optional. If none of them is available,
152 // the braces are not printed.
153 foreach ($displayLocales as $displayLocale) {
154 // Don't include ICU's root resource bundle
155 if ('root' === $displayLocale) {
156 continue;
157 }
158
159 $names = array();
160
161 foreach ($locales as $locale) {
162 // Don't include ICU's root resource bundle
163 if ($locale === 'root') {
164 continue;
165 }
166
167 if (null !== ($name = $this->generateLocaleName($locale, $displayLocale))) {
168 $names[$locale] = $name;
169 }
170 }
171
172 // If no names could be generated for the current locale, skip it
173 if (0 === count($names)) {
174 continue;
175 }
176
177 $txtWriter->write($targetDirectory, $displayLocale, array('Locales' => $names));
178 }
179 }
180
181 private function generateLocaleName($locale, $displayLocale)
182 {
183 $name = null;
184
185 $lang = \Locale::getPrimaryLanguage($locale);
186 $script = \Locale::getScript($locale);
187 $region = \Locale::getRegion($locale);
188 $variants = \Locale::getAllVariants($locale);
189
190 // Currently the only available variant is POSIX, which we don't want
191 // to include in the list
192 if (count($variants) > 0) {
193 return null;
194 }
195
196 // Some languages are translated together with their region,
197 // i.e. "en_GB" is translated as "British English"
198 // we don't include these languages though because they mess up
199 // the name sorting
200 // $name = $this->langBundle->getLanguageName($displayLocale, $lang, $region);
201
202 // Some languages are simply not translated
203 // Example: "az" (Azerbaijani) has no translation in "af" (Afrikaans)
204 if (null === ($name = $this->languageBundle->getLanguageName($lang, null, $displayLocale))) {
205 return null;
206 }
207
208 // "as" (Assamese) has no "Variants" block
209 //if (!$langBundle->get('Variants')) {
210 // continue;
211 //}
212
213 $extras = array();
214
215 // Discover the name of the script part of the locale
216 // i.e. in zh_Hans_MO, "Hans" is the script
217 if ($script) {
218 // Some scripts are not translated into every language
219 if (null === ($scriptName = $this->languageBundle->getScriptName($script, $lang, $displayLocale))) {
220 return null;
221 }
222
223 $extras[] = $scriptName;
224 }
225
226 // Discover the name of the region part of the locale
227 // i.e. in de_AT, "AT" is the region
228 if ($region) {
229 // Some regions are not translated into every language
230 if (null === ($regionName = $this->regionBundle->getCountryName($region, $displayLocale))) {
231 return null;
232 }
233
234 $extras[] = $regionName;
235 }
236
237 if (count($extras) > 0) {
238 // Remove any existing extras
239 // For example, in German, zh_Hans is "Chinesisch (vereinfacht)".
240 // The latter is the script part which is already included in the
241 // extras and will be appended again with the other extras.
242 if (preg_match('/^(.+)\s+\([^\)]+\)$/', $name, $matches)) {
243 $name = $matches[1];
244 }
245
246 $name .= ' ('.implode(', ', $extras).')';
247 }
248
249 return $name;
250 }
251}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/RegionBundleTransformationRule.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/RegionBundleTransformationRule.php
deleted file mode 100644
index 52fdbed8..00000000
--- a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/RegionBundleTransformationRule.php
+++ /dev/null
@@ -1,70 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Intl\ResourceBundle\Transformer\Rule;
13
14use Symfony\Component\Intl\Intl;
15use Symfony\Component\Intl\ResourceBundle\Transformer\CompilationContextInterface;
16use Symfony\Component\Intl\ResourceBundle\Transformer\StubbingContextInterface;
17use Symfony\Component\Intl\Util\IcuVersion;
18
19/**
20 * The rule for compiling the region bundle.
21 *
22 * @author Bernhard Schussek <bschussek@gmail.com>
23 */
24class RegionBundleTransformationRule implements TransformationRuleInterface
25{
26 /**
27 * {@inheritdoc}
28 */
29 public function getBundleName()
30 {
31 return 'region';
32 }
33
34 /**
35 * {@inheritdoc}
36 */
37 public function beforeCompile(CompilationContextInterface $context)
38 {
39 // The region data is contained in the locales bundle in ICU <= 4.2
40 if (IcuVersion::compare($context->getIcuVersion(), '4.2', '<=', 1)) {
41 return $context->getSourceDir() . '/locales';
42 }
43
44 return $context->getSourceDir() . '/region';
45 }
46
47 /**
48 * {@inheritdoc}
49 */
50 public function afterCompile(CompilationContextInterface $context)
51 {
52 }
53
54 /**
55 * {@inheritdoc}
56 */
57 public function beforeCreateStub(StubbingContextInterface $context)
58 {
59 return array(
60 'Countries' => Intl::getRegionBundle()->getCountryNames('en'),
61 );
62 }
63
64 /**
65 * {@inheritdoc}
66 */
67 public function afterCreateStub(StubbingContextInterface $context)
68 {
69 }
70}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/TransformationRuleInterface.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/TransformationRuleInterface.php
deleted file mode 100644
index 3965e0d2..00000000
--- a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/Rule/TransformationRuleInterface.php
+++ /dev/null
@@ -1,70 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Intl\ResourceBundle\Transformer\Rule;
13
14use Symfony\Component\Intl\ResourceBundle\Transformer\CompilationContextInterface;
15use Symfony\Component\Intl\ResourceBundle\Transformer\StubbingContextInterface;
16
17/**
18 * Contains instruction for compiling a resource bundle.
19 *
20 * @author Bernhard Schussek <bschussek@gmail.com>
21 */
22interface TransformationRuleInterface
23{
24 /**
25 * Returns the name of the compiled resource bundle.
26 *
27 * @return string The name of the bundle.
28 */
29 public function getBundleName();
30
31 /**
32 * Runs instructions to be executed before compiling the sources of the
33 * resource bundle.
34 *
35 * @param CompilationContextInterface $context The contextual information of
36 * the compilation.
37 *
38 * @return string[] The source directories/files of the bundle.
39 */
40 public function beforeCompile(CompilationContextInterface $context);
41
42 /**
43 * Runs instructions to be executed after compiling the sources of the
44 * resource bundle.
45 *
46 * @param CompilationContextInterface $context The contextual information of
47 * the compilation.
48 */
49 public function afterCompile(CompilationContextInterface $context);
50
51 /**
52 * Runs instructions to be executed before creating the stub version of the
53 * resource bundle.
54 *
55 * @param StubbingContextInterface $context The contextual information of
56 * the compilation.
57 *
58 * @return mixed The data to include in the stub version.
59 */
60 public function beforeCreateStub(StubbingContextInterface $context);
61
62 /**
63 * Runs instructions to be executed after creating the stub version of the
64 * resource bundle.
65 *
66 * @param StubbingContextInterface $context The contextual information of
67 * the compilation.
68 */
69 public function afterCreateStub(StubbingContextInterface $context);
70}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/StubbingContext.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/StubbingContext.php
deleted file mode 100644
index 25ab68db..00000000
--- a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/StubbingContext.php
+++ /dev/null
@@ -1,80 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Intl\ResourceBundle\Transformer;
13
14use Symfony\Component\Filesystem\Filesystem;
15
16/**
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19class StubbingContext implements StubbingContextInterface
20{
21 /**
22 * @var string
23 */
24 private $binaryDir;
25
26 /**
27 * @var string
28 */
29 private $stubDir;
30
31 /**
32 * @var Filesystem
33 */
34 private $filesystem;
35
36 /**
37 * @var string
38 */
39 private $icuVersion;
40
41 public function __construct($binaryDir, $stubDir, Filesystem $filesystem, $icuVersion)
42 {
43 $this->binaryDir = $binaryDir;
44 $this->stubDir = $stubDir;
45 $this->filesystem = $filesystem;
46 $this->icuVersion = $icuVersion;
47 }
48
49 /**
50 * {@inheritdoc}
51 */
52 public function getBinaryDir()
53 {
54 return $this->binaryDir;
55 }
56
57 /**
58 * {@inheritdoc}
59 */
60 public function getStubDir()
61 {
62 return $this->stubDir;
63 }
64
65 /**
66 * {@inheritdoc}
67 */
68 public function getFilesystem()
69 {
70 return $this->filesystem;
71 }
72
73 /**
74 * {@inheritdoc}
75 */
76 public function getIcuVersion()
77 {
78 return $this->icuVersion;
79 }
80}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/StubbingContextInterface.php b/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/StubbingContextInterface.php
deleted file mode 100644
index dc492556..00000000
--- a/vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Transformer/StubbingContextInterface.php
+++ /dev/null
@@ -1,46 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Intl\ResourceBundle\Transformer;
13
14/**
15 * @author Bernhard Schussek <bschussek@gmail.com>
16 */
17interface StubbingContextInterface
18{
19 /**
20 * Returns the directory where the binary resource bundles are stored.
21 *
22 * @return string An absolute path to a directory.
23 */
24 public function getBinaryDir();
25
26 /**
27 * Returns the directory where the stub resource bundles are stored.
28 *
29 * @return string An absolute path to a directory.
30 */
31 public function getStubDir();
32
33 /**
34 * Returns a tool for manipulating the filesystem.
35 *
36 * @return \Symfony\Component\Filesystem\Filesystem The filesystem manipulator.
37 */
38 public function getFilesystem();
39
40 /**
41 * Returns the ICU version of the bundles being converted.
42 *
43 * @return string The ICU version string.
44 */
45 public function getIcuVersion();
46}