/** * Loads an Xml file. * * @param mixed $file The resource * @param string $type The resource type * * @return array * * @throws \InvalidArgumentException if configuration file not found * @throws \Propel\Common\Config\Exception\InputOutputException if configuration file is not readable * @throws \Propel\Common\Config\Exception\InvalidArgumentException if invalid xml file * @throws \Propel\Common\Config\Exception\XmlParseException if something went wrong while parsing xml file */ public function load($file, $type = null) { $content = XmlToArrayConverter::convert($this->getPath($file)); $content = $this->resolveParams($content); //Resolve parameter placeholders (%name%) return $content; }
/** * Loads an Xml file. * * @param mixed $file The resource * @param string $type The resource type * * @throws \InvalidArgumentException if configuration file not found * @throws Propel\Common\Config\Exception\InputOutputException if configuration file is not readable * @throws Propel\Common\Config\Exception\InvalidArgumentException if invalid xml file * @throws Propel\Common\Config\Exception\XmlParseException if something went wrong while parsing xml file */ public function load($file, $type = null) { $path = $this->locator->locate($file); if (!is_readable($path)) { throw new InputOutputException("You don't have permissions to access configuration file {$file}."); } $content = XmlToArrayConverter::convert($path); $content = $this->resolveParams($content); //Resolve parameter placeholders (%name%) return $content; }
public function testEmptyFileReturnsEmptyArray() { $this->dumpTempFile('empty.xml', ''); $actual = XmlToArrayConverter::convert(sys_get_temp_dir() . '/empty.xml'); $this->assertEquals([], $actual); }