<commit_before><?php

namespace ATPViz\Widget;

class Container extends \Zend\View\Model\ViewModel
{
	private $_allWidgets = array();
	private $_sm = null;

	public function __construct($config, $sm)
	{
		//Initialize the view
		parent::__construct();
		
		//Get the widget definitions
		$this->_allWidgets = $config['viz']['widgets'];
		$this->setServiceLocator($sm);
		
		//Set the template
		$this->setTemplate('atp-viz/widget/container.phtml');		
	}
	
	public function setServiceLocator($sm)
	{
		$this->_sm = $sm;
	}
	
	public function getServiceLocator()
	{
		return $this->_sm;
	}
	
	public function addWidget($name)
	{
		if(isset($this->_allWidgets[$name]))
		{
			$widgetInfo = $this->_allWidgets[$name];
			$widgetClass = $widgetInfo['class'];
			$widget = new $widgetClass();
			$widget->setServiceLocator($this->getServiceLocator());
			$widget->setOptions($widgetInfo['options']);
			$widget->name = $name;
			$widget->setDataSource($this->getServiceLocator()->get('DataSourceFactory')->getInstance($widgetInfo['dataSource']));
		}
		else
		{
			$widget = new \ATPViz\Widget\PlaceHolderWidget();
			$widget->text = $name;
			$widget->name = $name;
		}
		$this->addChild($widget, 'widgets', true);
		$widget->data = $widget->getData();
	}
}
<commit_msg>Allow additional options to be added to widgets<commit_after><?php

namespace ATPViz\Widget;

class Container extends \Zend\View\Model\ViewModel
{
	private $_allWidgets = array();
	private $_sm = null;

	public function __construct($config, $sm)
	{
		//Initialize the view
		parent::__construct();
		
		//Get the widget definitions
		$this->_allWidgets = $config['viz']['widgets'];
		$this->setServiceLocator($sm);
		
		//Set the template
		$this->setTemplate('atp-viz/widget/container.phtml');		
	}
	
	public function setServiceLocator($sm)
	{
		$this->_sm = $sm;
	}
	
	public function getServiceLocator()
	{
		return $this->_sm;
	}
	
	public function addWidget($name, $options)
	{
		if(isset($this->_allWidgets[$name]))
		{
			$widgetInfo = $this->_allWidgets[$name];
			$widgetInfo['options'] = array_merge($widgetInfo['options'], $options);
			$widgetClass = $widgetInfo['class'];
			$widget = new $widgetClass();
			$widget->setServiceLocator($this->getServiceLocator());
			$widget->setOptions($widgetInfo['options']);
			$widget->name = $name;
			$widget->setDataSource($this->getServiceLocator()->get('DataSourceFactory')->getInstance($widgetInfo['dataSource']));
		}
		else
		{
			$widget = new \ATPViz\Widget\PlaceHolderWidget();
			$widget->text = $name;
			$widget->name = $name;
		}
		$this->addChild($widget, 'widgets', true);
		$widget->data = $widget->getData();
	}
}

{'fraction_non_alphanumeric': 0.17186366932559827, 'fraction_numerical': 0.0, 'mean_word_length': 3.7162393162393164, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2991164', 'n_tokens_mistral': 1013, 'n_tokens_neox': 881, 'n_words': 153}