diff options
author | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-04 17:50:34 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-04 17:50:34 +0200 |
commit | 46b77928f746a4231d064774b5b67fd892c7ce86 (patch) | |
tree | e3ea690b3f0def1744ddae758923cf92171ef985 /vendor/symfony/intl/Symfony/Component/Intl/Util/SvnRepository.php | |
parent | 68abd9c71b1d2f7bb2e9d21819584d1d15005b25 (diff) | |
download | wallabag-46b77928f746a4231d064774b5b67fd892c7ce86.tar.gz wallabag-46b77928f746a4231d064774b5b67fd892c7ce86.tar.zst wallabag-46b77928f746a4231d064774b5b67fd892c7ce86.zip |
rm vendor
Diffstat (limited to 'vendor/symfony/intl/Symfony/Component/Intl/Util/SvnRepository.php')
-rw-r--r-- | vendor/symfony/intl/Symfony/Component/Intl/Util/SvnRepository.php | 141 |
1 files changed, 0 insertions, 141 deletions
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Util/SvnRepository.php b/vendor/symfony/intl/Symfony/Component/Intl/Util/SvnRepository.php deleted file mode 100644 index fb44e3c6..00000000 --- a/vendor/symfony/intl/Symfony/Component/Intl/Util/SvnRepository.php +++ /dev/null | |||
@@ -1,141 +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 | |||
12 | namespace Symfony\Component\Intl\Util; | ||
13 | |||
14 | use Symfony\Component\Filesystem\Filesystem; | ||
15 | use Symfony\Component\Intl\Exception\RuntimeException; | ||
16 | |||
17 | /** | ||
18 | * A SVN repository containing ICU data. | ||
19 | * | ||
20 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
21 | */ | ||
22 | class SvnRepository | ||
23 | { | ||
24 | /** | ||
25 | * @var string The path to the repository. | ||
26 | */ | ||
27 | private $path; | ||
28 | |||
29 | /** | ||
30 | * @var \SimpleXMLElement | ||
31 | */ | ||
32 | private $svnInfo; | ||
33 | |||
34 | /** | ||
35 | * @var SvnCommit | ||
36 | */ | ||
37 | private $lastCommit; | ||
38 | |||
39 | /** | ||
40 | * Downloads the ICU data for the given version. | ||
41 | * | ||
42 | * @param string $url The URL to download from. | ||
43 | * @param string $targetDir The directory in which to store the repository. | ||
44 | * | ||
45 | * @return SvnRepository The directory where the data is stored. | ||
46 | * | ||
47 | * @throws RuntimeException If an error occurs during the download. | ||
48 | */ | ||
49 | public static function download($url, $targetDir) | ||
50 | { | ||
51 | exec('which svn', $output, $result); | ||
52 | |||
53 | if ($result !== 0) { | ||
54 | throw new RuntimeException('The command "svn" is not installed.'); | ||
55 | } | ||
56 | |||
57 | $filesystem = new Filesystem(); | ||
58 | |||
59 | if (!$filesystem->exists($targetDir . '/.svn')) { | ||
60 | $filesystem->remove($targetDir); | ||
61 | $filesystem->mkdir($targetDir); | ||
62 | |||
63 | exec('svn checkout ' . $url . ' ' . $targetDir, $output, $result); | ||
64 | |||
65 | if ($result !== 0) { | ||
66 | throw new RuntimeException('The SVN checkout of ' . $url . 'failed.'); | ||
67 | } | ||
68 | } | ||
69 | |||
70 | return new static(realpath($targetDir)); | ||
71 | } | ||
72 | |||
73 | /** | ||
74 | * Reads the SVN repository at the given path. | ||
75 | * | ||
76 | * @param string $path The path to the repository. | ||
77 | */ | ||
78 | public function __construct($path) | ||
79 | { | ||
80 | $this->path = $path; | ||
81 | } | ||
82 | |||
83 | /** | ||
84 | * Returns the path to the repository. | ||
85 | * | ||
86 | * @return string The path to the repository. | ||
87 | */ | ||
88 | public function getPath() | ||
89 | { | ||
90 | return $this->path; | ||
91 | } | ||
92 | |||
93 | /** | ||
94 | * Returns the URL of the repository. | ||
95 | * | ||
96 | * @return string The URL of the repository. | ||
97 | */ | ||
98 | public function getUrl() | ||
99 | { | ||
100 | return (string) $this->getSvnInfo()->entry->url; | ||
101 | } | ||
102 | |||
103 | /** | ||
104 | * Returns the last commit of the repository. | ||
105 | * | ||
106 | * @return SvnCommit The last commit. | ||
107 | */ | ||
108 | public function getLastCommit() | ||
109 | { | ||
110 | if (null === $this->lastCommit) { | ||
111 | $this->lastCommit = new SvnCommit($this->getSvnInfo()->entry->commit); | ||
112 | } | ||
113 | |||
114 | return $this->lastCommit; | ||
115 | } | ||
116 | |||
117 | /** | ||
118 | * Returns information about the SVN repository. | ||
119 | * | ||
120 | * @return \SimpleXMLElement The XML result from the "svn info" command. | ||
121 | * | ||
122 | * @throws RuntimeException If the "svn info" command failed. | ||
123 | */ | ||
124 | private function getSvnInfo() | ||
125 | { | ||
126 | if (null === $this->svnInfo) { | ||
127 | exec('svn info --xml '.$this->path, $output, $result); | ||
128 | |||
129 | $svnInfo = simplexml_load_string(implode("\n", $output)); | ||
130 | |||
131 | if ($result !== 0) { | ||
132 | throw new RuntimeException('svn info failed'); | ||
133 | } | ||
134 | |||
135 | $this->svnInfo = $svnInfo; | ||
136 | } | ||
137 | |||
138 | return $this->svnInfo; | ||
139 | } | ||
140 | |||
141 | } | ||