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