Conditions | 4 |
Paths | 6 |
Total Lines | 25 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
27 | public function writeXml($xml) { |
||
28 | |||
29 | @unlink($this->getTmpXmlFile(false)); |
||
30 | $res = file_put_contents($this->getTmpXmlFile(false), $xml); |
||
31 | if(static::GZIP) { |
||
32 | unlink($this->getTmpXmlFile()); |
||
33 | chdir(pathinfo($this->getTmpXmlFile(), PATHINFO_DIRNAME)); |
||
34 | exec("gzip " . self::XML_FILE); |
||
35 | } |
||
36 | |||
37 | if($res) { |
||
38 | |||
39 | //TODO: check size !!! |
||
40 | $command = sprintf("mv %s %s", $this->getTmpXmlFile(), $this->getXmlFile()); |
||
41 | exec($command); |
||
42 | |||
43 | } else { |
||
44 | /** @var LoggerInterface $logger */ |
||
45 | $logger = $this->getLogger(); |
||
46 | if($logger) { |
||
47 | $logger->error($this->getName() . ' ERROR: unable write file!'); |
||
48 | } |
||
49 | } |
||
50 | |||
51 | return $res; |
||
52 | } |
||
54 |