/
githubmirror
/
magento2
Обзор
Документация
Войти
/
githubmirror
/
magento2
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
2.4-develop
setup/src/Magento/Setup/Module/I18n/Dictionary/Writer/Csv.php
64 строки
2 KB
Alexandra Zota
ACP2E-4019: CE copyright updates for 2.4.9-beta1
22 окт 2025, 11:23
22 окт 2025, 11:23
6c2f6e6
Код
Авторство
О чём код?
<?php /** * Copyright 2015 Adobe * All Rights Reserved. */ namespace Magento\Setup\Module\I18n\Dictionary\Writer; use Magento\Setup\Module\I18n\Dictionary\Phrase; use Magento\Setup\Module\I18n\Dictionary\WriterInterface; /** * Csv writer */ class Csv implements WriterInterface { /** * File handler * * @var resource */ protected $_fileHandler; /** * Writer construct * * @param string $outputFilename * @throws \InvalidArgumentException */ public function __construct($outputFilename) { if (false === ($fileHandler = @fopen($outputFilename, 'w'))) { throw new \InvalidArgumentException( sprintf('Cannot open file for write dictionary: "%s"', $outputFilename) ); } $this->_fileHandler = $fileHandler; } /** * {@inheritdoc} */ public function write(Phrase $phrase) { $fields = [$phrase->getCompiledPhrase(), $phrase->getCompiledTranslation()]; if (($contextType = $phrase->getContextType()) && ($contextValue = $phrase->getContextValueAsString())) { $fields[] = $contextType; $fields[] = $contextValue; } fputcsv($this->_fileHandler, $fields, ',', '"', '\\'); } /** * Destructor for closing resource * * @return void */ public function __destruct() { if ($this->_fileHandler !== STDOUT && is_resource($this->_fileHandler)) { fclose($this->_fileHandler); } } }