Jarves\Configuration\Bundle::toArray PHP Method

toArray() public method

public toArray ( boolean $printDefaults = false ) : array
$printDefaults boolean
return array
    public function toArray($printDefaults = false)
    {
        $value['name'] = $this->getBundleName();
        $value['class'] = get_class($this->getBundleClass());
        $value = array_merge($value, parent::toArray($printDefaults));
        return $value;
    }

Usage Example

コード例 #1
0
ファイル: BundleConfigTest.php プロジェクト: jarves/jarves
    public function testBundle()
    {
        $config = new Bundle('DummyBundle', $this->getJarves());
        $events = [['key' => 'core/object/modify', 'desc' => 'foo'], ['key' => 'core/object/update', 'desc' => 'bar']];
        foreach ($events as $item) {
            $items[] = new Event($item, $this->getJarves());
        }
        $config->setEvents($items);
        $config->setBundleName('FooBar');
        $caches = [new BundleCache(['key' => 'foo', 'method' => 'bar'], $this->getJarves()), new BundleCache(['key' => 'foo2'], $this->getJarves())];
        $config->setCaches($caches);
        $array = array('name' => 'FooBar', 'class' => 'Jarves\\Configuration\\Bundle', 'caches' => array(array('key' => 'foo', 'method' => 'bar'), array('key' => 'foo2')), 'events' => array(array('key' => 'core/object/modify', 'desc' => 'foo'), array('key' => 'core/object/update', 'desc' => 'bar')));
        $xml = '<bundle>
  <caches>
    <cache method="bar">foo</cache>
    <cache>foo2</cache>
  </caches>
  <events>
    <event key="core/object/modify">
      <desc>foo</desc>
    </event>
    <event key="core/object/update">
      <desc>bar</desc>
    </event>
  </events>
</bundle>';
        $this->assertEquals($array, $config->toArray());
        $this->assertEquals($xml, $config->toXml());
    }