当前位置: 首页>>代码示例>>PHP>>正文


PHP Loader\ArrayLoader类代码示例

本文整理汇总了PHP中Symfony\Component\Translation\Loader\ArrayLoader的典型用法代码示例。如果您正苦于以下问题:PHP ArrayLoader类的具体用法?PHP ArrayLoader怎么用?PHP ArrayLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ArrayLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: load

 /**
  *
  * {@inheritDoc} @see ArrayLoader::load()
  */
 public function load($resource, $locale, $domain = 'messages')
 {
     $messages = array();
     $catalogue = new MessageCatalogue($locale);
     $catalogue->add($resource, $domain);
     $messages = $this->parse($resource);
     $catalogue = parent::load($messages, $locale, $domain);
     $catalogue->addResource(new FileResource($resource));
     return $catalogue;
 }
开发者ID:sasedev,项目名称:extra-tools-bundle,代码行数:14,代码来源:PotFileLoader.php

示例2: load

 /**
  * {@inheritdoc}
  */
 public function load($resource, $locale, $domain = 'messages')
 {
     if (!stream_is_local($resource)) {
         throw new InvalidResourceException(sprintf('This is not a local file "%s".', $resource));
     }
     if (!file_exists($resource)) {
         throw new NotFoundResourceException(sprintf('File "%s" not found.', $resource));
     }
     $messages = array();
     try {
         $file = new \SplFileObject($resource, 'rb');
     } catch (\RuntimeException $e) {
         throw new NotFoundResourceException(sprintf('Error opening file "%s".', $resource), 0, $e);
     }
     $file->setFlags(\SplFileObject::READ_CSV | \SplFileObject::SKIP_EMPTY);
     $file->setCsvControl($this->delimiter, $this->enclosure, $this->escape);
     foreach ($file as $data) {
         if ('#' !== substr($data[0], 0, 1) && isset($data[1]) && 2 === count($data)) {
             $messages[$data[0]] = $data[1];
         }
     }
     $catalogue = parent::load($messages, $locale, $domain);
     if (class_exists('Symfony\\Component\\Config\\Resource\\FileResource')) {
         $catalogue->addResource(new FileResource($resource));
     }
     return $catalogue;
 }
开发者ID:Dren-x,项目名称:mobit,代码行数:30,代码来源:CsvFileLoader.php

示例3: load

 /**
  * {@inheritdoc}
  *
  * @api
  */
 public function load($resource, $locale, $domain = 'messages')
 {
     $messages = (require $resource);
     $catalogue = parent::load($messages, $locale, $domain);
     $catalogue->addResource(new FileResource($resource));
     return $catalogue;
 }
开发者ID:nickaggarwal,项目名称:sample-symfony2,代码行数:12,代码来源:PhpFileLoader.php

示例4: load

 /**
  * {@inheritdoc}
  */
 public function load($resource, $locale, $domain = 'messages')
 {
     if (!stream_is_local($resource)) {
         throw new InvalidResourceException(sprintf('This is not a local file "%s".', $resource));
     }
     if (!file_exists($resource)) {
         throw new NotFoundResourceException(sprintf('File "%s" not found.', $resource));
     }
     if (!class_exists('Symfony\\Component\\Yaml\\Parser')) {
         throw new \LogicException('Loading translations from the YAML format requires the Symfony Yaml component.');
     }
     if (null === $this->yamlParser) {
         $this->yamlParser = new YamlParser();
     }
     try {
         $messages = $this->yamlParser->parse(file_get_contents($resource));
     } catch (ParseException $e) {
         throw new InvalidResourceException(sprintf('Error parsing YAML, invalid file "%s"', $resource), 0, $e);
     }
     // empty file
     if (null === $messages) {
         $messages = array();
     }
     // not an array
     if (!is_array($messages)) {
         throw new InvalidResourceException(sprintf('The file "%s" must contain a YAML array.', $resource));
     }
     $catalogue = parent::load($messages, $locale, $domain);
     if (class_exists('Symfony\\Component\\Config\\Resource\\FileResource')) {
         $catalogue->addResource(new FileResource($resource));
     }
     return $catalogue;
 }
开发者ID:Dren-x,项目名称:mobit,代码行数:36,代码来源:YamlFileLoader.php

示例5: load

 /**
  * {@inheritdoc}
  *
  * @api
  */
 public function load($resource, $locale, $domain = 'messages')
 {
     $messages = array();
     try {
         $file = new \SplFileObject($resource, 'rb');
     } catch (\RuntimeException $e) {
         throw new \InvalidArgumentException(sprintf('Error opening file "%s".', $resource));
     }
     $file->setFlags(\SplFileObject::READ_CSV | \SplFileObject::SKIP_EMPTY);
     $file->setCsvControl($this->delimiter, $this->enclosure, $this->escape);
     foreach ($file as $data) {
         if (substr($data[0], 0, 1) === '#') {
             continue;
         }
         if (!isset($data[1])) {
             continue;
         }
         if (count($data) == 2) {
             $messages[$data[0]] = $data[1];
         } else {
             continue;
         }
     }
     $catalogue = parent::load($messages, $locale, $domain);
     $catalogue->addResource(new FileResource($resource));
     return $catalogue;
 }
开发者ID:robertowest,项目名称:CuteFlow-V4,代码行数:32,代码来源:CsvFileLoader.php

示例6: load

 /**
  * {@inheritdoc}
  */
 public function load($resource, $locale, $domain = 'messages')
 {
     if (!stream_is_local($resource)) {
         throw new InvalidResourceException(sprintf('This is not a local file "%s".', $resource));
     }
     if (!file_exists($resource)) {
         throw new NotFoundResourceException(sprintf('File "%s" not found.', $resource));
     }
     try {
         $messages = Neon\Neon::decode(file_get_contents($resource));
     } catch (Nette\Utils\NeonException $e) {
         throw new InvalidResourceException(sprintf("Error parsing Neon: %s", $e->getMessage()), 0, $e);
     } catch (Nette\Neon\Exception $e) {
         throw new InvalidResourceException(sprintf("Error parsing Neon: %s", $e->getMessage()), 0, $e);
     }
     if (empty($messages)) {
         $messages = array();
     }
     if (!is_array($messages)) {
         throw new InvalidResourceException(sprintf('The file "%s" must contain a Neon array.', $resource));
     }
     $catalogue = parent::load($messages, $locale, $domain);
     $catalogue->addResource(new FileResource($resource));
     return $catalogue;
 }
开发者ID:tomasstrejcek,项目名称:Translation,代码行数:28,代码来源:NeonFileLoader.php

示例7: load

 /**
  * {@inheritdoc}
  *
  * @api
  */
 public function load($resource, $locale, $domain = 'messages')
 {
     if (!stream_is_local($resource)) {
         throw new InvalidResourceException(sprintf('This is not a local file "%s".', $resource));
     }
     if (!file_exists($resource)) {
         throw new NotFoundResourceException(sprintf('File "%s" not found.', $resource));
     }
     if (null === $this->yamlParser) {
         $this->yamlParser = new YamlParser();
     }
     try {
         $messages = $this->yamlParser->parse(file_get_contents($resource));
     } catch (ParseException $e) {
         throw new InvalidResourceException(sprintf('Error parsing YAML, invalid file "%s"', $resource), 0, $e);
     }
     // empty file
     if (null === $messages) {
         $messages = array();
     }
     // not an array
     if (!is_array($messages)) {
         throw new InvalidResourceException(sprintf('The file "%s" must contain a YAML array.', $resource));
     }
     $catalogue = parent::load($messages, $locale, $domain);
     $catalogue->addResource(new FileResource($resource));
     return $catalogue;
 }
开发者ID:tahermarkos,项目名称:Transport,代码行数:33,代码来源:YamlFileLoader.php

示例8: load

    /**
     * {@inheritdoc}
     */
    public function load($resource, $locale, $domain = 'messages')
    {
        $messages = array();
        $file = @fopen($resource, 'rb');
        if (!$file) {
            throw new \InvalidArgumentException(sprintf('Error opening file "%s".', $resource));
        }

        while (($data = fgetcsv($file, 0, ';')) !== false) {
            if (substr($data[0], 0, 1) === '#') {
                continue;
            }

            if (!isset($data[1])) {
                continue;
            }

            if (count($data) == 2) {
                $messages[$data[0]] = $data[1];
            } else {
                 continue;
            }
        }

        $catalogue = parent::load($messages, $locale, $domain);
        $catalogue->addResource(new FileResource($resource));

        return $catalogue;
    }
开发者ID:Gregwar,项目名称:symfony,代码行数:32,代码来源:CsvFileLoader.php

示例9: load

 /**
  * {@inheritdoc}
  */
 public function load($resource, $locale, $domain = 'messages')
 {
     $dataCatalogue = new DataCatalogue();
     $dataCatalogue->load($resource, 'json', $locale);
     $messages = $dataCatalogue->getMessages();
     $catalogue = parent::load($messages, $locale, $domain);
     $catalogue->addResource(new FileResource($resource));
     return $catalogue;
 }
开发者ID:selmanouni,项目名称:blue-lines,代码行数:12,代码来源:JsonFileLoader.php

示例10: load

 /**
  * {@inheritdoc}
  *
  * @api
  */
 public function load($resource, $locale, $domain = 'messages')
 {
     if (!stream_is_local($resource)) {
         throw new \InvalidArgumentException(sprintf('This is not a local file "%s".', $resource));
     }
     $messages = (require $resource);
     $catalogue = parent::load($messages, $locale, $domain);
     $catalogue->addResource(new FileResource($resource));
     return $catalogue;
 }
开发者ID:unkerror,项目名称:Budabot,代码行数:15,代码来源:PhpFileLoader.php

示例11: load

 /**
  * {@inheritdoc}
  */
 public function load($resource, $locale, $domain = 'messages')
 {
     if (!stream_is_local($resource)) {
         throw new InvalidResourceException(sprintf('This is not a local file "%s".', $resource));
     }
     if (!file_exists($resource)) {
         throw new NotFoundResourceException(sprintf('File "%s" not found.', $resource));
     }
     return parent::load(require $resource, $locale, $domain);
 }
开发者ID:vvval,项目名称:spiral,代码行数:13,代码来源:PhpFileLoad.php

示例12: load

 /**
  * {@inheritdoc}
  */
 public function load($resource, $locale, $domain = 'messages')
 {
     if (!is_file($resource)) {
         throw new \InvalidArgumentException(sprintf('Error opening file "%s".', $resource));
     }
     $messages = parse_ini_file($resource, true);
     $catalogue = parent::load($messages, $locale, $domain);
     $catalogue->addResource(new FileResource($resource));
     return $catalogue;
 }
开发者ID:laubosslink,项目名称:lab,代码行数:13,代码来源:IniFileLoader.php

示例13: load

 /**
  * {@inheritdoc}
  */
 public function load($resource, $locale, $domain = 'messages')
 {
     if (!stream_is_local($resource)) {
         throw new InvalidResourceException(sprintf('This is not a local file "%s".', $resource));
     }
     if (!file_exists($resource)) {
         throw new NotFoundResourceException(sprintf('File "%s" not found.', $resource));
     }
     $messages = parse_ini_file($resource, true);
     $catalogue = parent::load($messages, $locale, $domain);
     $catalogue->addResource(new FileResource($resource));
     return $catalogue;
 }
开发者ID:NikoNick,项目名称:EventsBerry,代码行数:16,代码来源:IniFileLoader.php

示例14: load

 /**
  * {@inheritdoc}
  *
  * @api
  */
 public function load($resource, $locale, $domain = 'messages')
 {
     if (!stream_is_local($resource)) {
         throw new InvalidResourceException(sprintf('This is not a local file "%s".', $resource));
     }
     if (!file_exists($resource)) {
         throw new NotFoundResourceException(sprintf('File "%s" not found.', $resource));
     }
     $messages = (require $resource);
     $catalogue = parent::load($messages, $locale, $domain);
     if (class_exists('Symfony\\Component\\Config\\Resource\\FileResource')) {
         $catalogue->addResource(new FileResource($resource));
     }
     return $catalogue;
 }
开发者ID:EnmanuelCode,项目名称:backend-laravel,代码行数:20,代码来源:PhpFileLoader.php

示例15: load

 public function load($resource, $locale, $domain = 'messages')
 {
     $messages = $this->parse($resource);
     // empty file
     if (null === $messages) {
         $messages = array();
     }
     // not an array
     if (!is_array($messages)) {
         throw new \InvalidArgumentException(sprintf('The file "%s" must contain a valid mo file.', $resource));
     }
     $catalogue = parent::load($messages, $locale, $domain);
     $catalogue->addResource(new FileResource($resource));
     return $catalogue;
 }
开发者ID:neokensou,项目名称:symfony,代码行数:15,代码来源:MoFileLoader.php


注:本文中的Symfony\Component\Translation\Loader\ArrayLoader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。