DotsUnited\BundleFu\Bundle::setOptions PHP Method

setOptions() public method

Allows to pass options as array.
public setOptions ( array $options ) : Bundle
$options array
return Bundle
    public function setOptions(array $options)
    {
        foreach ($options as $key => $val) {
            switch ($key) {
                case 'name':
                    $this->setName($val);
                    break;
                case 'doc_root':
                    $this->setDocRoot($val);
                    break;
                case 'bypass':
                    $this->setBypass($val);
                    break;
                case 'force':
                    $this->setForce($val);
                    break;
                case 'render_as_xhtml':
                    $this->setRenderAsXhtml($val);
                    break;
                case 'css_filter':
                    $this->setCssFilter($val);
                    break;
                case 'js_filter':
                    $this->setJsFilter($val);
                    break;
                case 'css_cache_path':
                    $this->setCssCachePath($val);
                    break;
                case 'js_cache_path':
                    $this->setJsCachePath($val);
                    break;
                case 'css_cache_url':
                    $this->setCssCacheUrl($val);
                    break;
                case 'js_cache_url':
                    $this->setJsCacheUrl($val);
                    break;
                case 'css_template':
                    $this->setCssTemplate($val);
                    break;
                case 'js_template':
                    $this->setJsTemplate($val);
                    break;
            }
        }
        return $this;
    }

Usage Example

Beispiel #1
0
 public function testSetOptions()
 {
     $options = array('name' => 'testbundle', 'doc_root' => '/my/custom/docroot', 'bypass' => true, 'force' => true, 'render_as_xhtml' => true, 'css_filter' => $this->getMock('\\DotsUnited\\BundleFu\\Filter\\FilterInterface'), 'js_filter' => $this->getMock('\\DotsUnited\\BundleFu\\Filter\\FilterInterface'), 'css_cache_path' => 'css/cache/path', 'js_cache_path' => 'js/cache/path', 'css_cache_url' => 'css/cache/url', 'js_cache_url' => 'js/cache/url', 'css_template' => '%s%s', 'js_template' => '%s%s');
     $bundle = new Bundle();
     $bundle->setOptions($options);
     foreach ($options as $key => $val) {
         $method = 'get' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key)));
         $this->assertEquals($val, $bundle->{$method}(), ' -> ' . $key);
     }
 }