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


PHP XmlUtils::convertDomElementToArray方法代码示例

本文整理汇总了PHP中Symfony\Component\Config\Util\XmlUtils::convertDomElementToArray方法的典型用法代码示例。如果您正苦于以下问题:PHP XmlUtils::convertDomElementToArray方法的具体用法?PHP XmlUtils::convertDomElementToArray怎么用?PHP XmlUtils::convertDomElementToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Config\Util\XmlUtils的用法示例。


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

示例1: load

 /**
  * Carga un recurso de tipo Xml
  *
  * @param mixed $file
  * @param null $type
  * @return array
  */
 public function load($file, $type = null)
 {
     $path = $this->locator->locate($file);
     $dom = XmlUtils::loadFile($path);
     $arrayXml = XmlUtils::convertDomElementToArray($dom->documentElement);
     $this->container->addResource(new FileResource($path));
     return $arrayXml;
 }
开发者ID:bosonsymfony,项目名称:excepciones-bundle,代码行数:15,代码来源:XmlFileLoader.php

示例2: provideFullConfiguration

 public function provideFullConfiguration()
 {
     $yaml = Yaml::parse(__DIR__ . '/Fixtures/config/yml/full.yml');
     $yaml = $yaml['doctrine_mongodb'];
     $xml = XmlUtils::loadFile(__DIR__ . '/Fixtures/config/xml/full.xml');
     $xml = XmlUtils::convertDomElementToArray($xml->getElementsByTagName('config')->item(0));
     return array(array($yaml), array($xml));
 }
开发者ID:Wizkunde,项目名称:DoctrineMongoDBBundle,代码行数:8,代码来源:ConfigurationTest.php

示例3: load

 /**
  * Lee el contenido de un fichero XML.
  *
  * @param string $type The resource type
  * @return array.
  */
 public function load($file, $type = null)
 {
     $path = $this->locator->locate($file);
     try {
         $dom = XmlUtils::loadFile($path);
     } catch (\InvalidArgumentException $e) {
         throw new \InvalidArgumentException(sprintf('Unable to parse file "%s".', $file), $e->getCode(), $e);
     }
     $arrayXml = XmlUtils::convertDomElementToArray($dom->documentElement);
     return $arrayXml;
 }
开发者ID:bosonsymfony,项目名称:excepciones-bundle,代码行数:17,代码来源:XmlFileReader.php

示例4: convertDomElementToArray

 /**
  * Converts a \DomElement object to a PHP array.
  *
  * The following rules applies during the conversion:
  *
  *  * Each tag is converted to a key value or an array
  *    if there is more than one "value"
  *
  *  * The content of a tag is set under a "value" key (<foo>bar</foo>)
  *    if the tag also has some nested tags
  *
  *  * The attributes are converted to keys (<foo foo="bar"/>)
  *
  *  * The nested-tags are converted to keys (<foo><foo>bar</foo></foo>)
  *
  * @param \DomElement $element A \DomElement instance
  *
  * @return array A PHP array
  */
 public static function convertDomElementToArray(\DomElement $element)
 {
     return XmlUtils::convertDomElementToArray($element);
 }
开发者ID:ABaldwinHunter,项目名称:symfony-clone,代码行数:23,代码来源:XmlFileLoader.php

示例5: testConvertDomToArray

 /**
  * @dataProvider getDataForConvertDomToArray
  */
 public function testConvertDomToArray($expected, $xml, $root = false, $checkPrefix = true)
 {
     $dom = new \DOMDocument();
     $dom->loadXML($root ? $xml : '<root>' . $xml . '</root>');
     $this->assertSame($expected, XmlUtils::convertDomElementToArray($dom->documentElement, $checkPrefix));
 }
开发者ID:Dren-x,项目名称:mobit,代码行数:9,代码来源:XmlUtilsTest.php

示例6: obtener

 /**
  * Obtiene un arreglo de excepciones dado un path del fichero de excepciones y el formato  con su traducción.
  *
  * @param $file
  * @param $extension
  * @return mixed
  */
 public function obtener($file, $extension)
 {
     if ($extension == 'yml') {
         $trasDir = str_replace("config" . DIRECTORY_SEPARATOR . "excepciones.yml", "translations", $file);
         $traducciones = $this->getTranslationByRoute($trasDir);
         $values = Yaml::parse($file);
         $respuesta = $this->getExceptionsWithTrans($traducciones, $values['excepciones']);
         return $respuesta;
     } else {
         if ($extension == 'xml') {
             $trasDir = str_replace("config" . DIRECTORY_SEPARATOR . "excepciones.xml", "translations", $file);
             $traducciones = $this->getTranslationByRoute($trasDir);
             $xml = XmlUtils::loadFile($file);
             $values = XmlUtils::convertDomElementToArray($xml->documentElement);
             $respuesta = $this->getExceptionsWithTrans($traducciones, $values);
             return $respuesta;
         }
     }
     return false;
 }
开发者ID:bosonsymfony,项目名称:excepciones-bundle,代码行数:27,代码来源:ViewController.php

示例7: provideExceptionConfiguration

 public function provideExceptionConfiguration()
 {
     $yaml = Yaml::parse(file_get_contents(__DIR__ . '/Fixtures/config/yml/exception.yml'));
     $yaml = $yaml['doctrine_mongodb'];
     $xml = XmlUtils::loadFile(__DIR__ . '/Fixtures/config/xml/exception.xml');
     $xml = XmlUtils::convertDomElementToArray($xml->getElementsByTagName('config')->item(0));
     return [[$yaml], [$xml]];
 }
开发者ID:alcaeus,项目名称:DoctrineMongoDBBundle,代码行数:8,代码来源:ConfigurationTest.php


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