DataSift\Storyplayer\ConfigLib\ConfigList::addEntry PHP Метод

addEntry() публичный Метод

useful for adding in hard-coded config options
public addEntry ( string $name, object $config )
$name string the name of the config to inject
$config object the config to inject into our list
    public function addEntry($name, $config)
    {
        // make sure $config is the right type
        $classname = $this->getWrappedConfigClassname();
        if (!$config instanceof $classname) {
            throw new E4xx_IncompatibleConfigClass($classname, get_class($config));
        }
        // if we get here, all is good
        $this->list[$name] = $config;
        // keep the configs sorted
        ksort($this->list);
    }

Usage Example

Пример #1
0
 /**
  * @covers DataSift\Storyplayer\ConfigLib\ConfigList::__construct
  * @covers DataSift\Storyplayer\ConfigLib\ConfigList::addEntry
  * @expectedException DataSift\Storyplayer\ConfigLib\E4xx_IncompatibleConfigClass
  */
 public function testManuallyAddedConfigsMustBeCompatibleType()
 {
     // ----------------------------------------------------------------
     // setup your test
     $obj = new ConfigList("DataSift\\Storyplayer\\ConfigLib\\StoryplayerConfig", __DIR__ . '/ConfigListTestData1');
     $obj->findConfigs();
     $expectedName = 'injected-1';
     $expectedConfig = new WrappedConfig();
     // ----------------------------------------------------------------
     // perform the change
     $obj->addEntry($expectedName, $expectedConfig);
 }