FOF30\Configuration\Domain\Container::parseDomain PHP Method

parseDomain() public method

Parse the XML data, adding them to the $ret array
public parseDomain ( SimpleXMLElement $xml, array &$ret ) : void
$xml SimpleXMLElement The XML data of the component's configuration area
$ret array
return void
    public function parseDomain(SimpleXMLElement $xml, array &$ret)
    {
        // Initialise
        $ret['container'] = array();
        // Parse the dispatcher configuration
        $containerData = $xml->container;
        // Sanity check
        if (empty($containerData)) {
            return;
        }
        $options = $xml->xpath('container/option');
        if (!empty($options)) {
            foreach ($options as $option) {
                $key = (string) $option['name'];
                $ret['container'][$key] = (string) $option;
            }
        }
    }

Usage Example

Example #1
0
 /**
  * @covers  FOF30\Configuration\Domain\Container::get
  *
  * @dataProvider getTestGet
  *
  * @param   string  $key       Key to read
  * @param   mixed   $default   Default value
  * @param   mixed   $expected  Expected value
  * @param   string  $message   Failure message
  *
  * @return  void
  */
 public function testGet($key, $default, $expected, $message)
 {
     $auth = new Container();
     $ret = array();
     $file = __DIR__ . '/../../_data/configuration/container.xml';
     $xml = simplexml_load_file($file);
     $auth->parseDomain($xml, $ret);
     $actual = $auth->get($ret, $key, $default);
     $this->assertEquals($expected, $actual, $message);
 }