public function addWidget($name, $type, array $values = array())
 {
     // Create the widget
     $widget = new Widget();
     $widget->setId($this->id);
     $widget->setCollectionName($this->collectionName);
     $widget->setName($name);
     $widget->setType(strtolower($type));
     $widget->setPosition(count($this->collection));
     $widget->setValues($values);
     $widget->setClassName(str_replace('widget.', '', strtolower($type)));
     if ($this->parent !== null && $this->parent->getType() == 'widget.responsivecolumns') {
         $this->parent->setValues(array_merge($this->parent->getValues(), array('isEmpty' => 0)));
     }
     // Append the widget to the zone's collection
     $this->collection[count($this->collection)] = $widget;
     return $widget;
 }
 public function __construct($columns, Widget $widget)
 {
     // Construct an ID to be used by the column widget's collections
     $idPrefix = $widget->getId() . '-' . $widget->getCollectionName() . '__' . $widget->getName();
     $zones = $widget->getCollection('zones');
     // Add column collections to the widget
     for ($column = 0; $column < $columns; ++$column) {
         $name = 'column' . ($column > 0 ? $column : '');
         $id = $idPrefix . '-zones__' . $name;
         // Add a column widget
         $zone = new Widget();
         $zone->setId($idPrefix);
         $zone->setCollectionName('zones');
         $zone->setName($name);
         $zone->setType('Widget.Columns.Column');
         $zone->setPosition($column);
         $zones[$column] = $zone;
         $collection = new Collection();
         $zone->addCollection('widgets', $collection);
         $this->columns[] = new CollectionBuilder($id, 'widgets', $collection, $widget);
     }
 }