當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。