本文整理汇总了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;
}
示例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));
}
示例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;
}
示例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);
}
示例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));
}
示例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;
}
示例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]];
}