Exemplo n.º 1
0
 public function testOptions()
 {
     $this->assertEquals([], $this->widget->getOptions());
     $options['foo'] = 'bar';
     $this->widget->setOptions($options);
     $this->assertSame($options, $this->widget->getOptions());
 }
 /**
  * @param Widget $widget
  */
 protected function updateOptions(Widget $widget)
 {
     $options = $widget->getOptions();
     if (!isset($options['subWidgets'])) {
         return;
     }
     $items = array_map(function ($subWidget) {
         return ['id' => $subWidget, 'show' => true, 'order' => 0];
     }, $options['subWidgets']);
     $options['subWidgets'] = ['items' => $items];
     $widget->setOptions($options);
 }
Exemplo n.º 3
0
 /**
  * Copy widget model by entity
  *
  * @param Widget $sourceWidget
  *
  * @return WidgetModel
  */
 protected function copyWidgetModel(Widget $sourceWidget)
 {
     $widget = new Widget();
     $widget->setLayoutPosition($sourceWidget->getLayoutPosition());
     $widget->setName($sourceWidget->getName());
     $widget->setOptions($sourceWidget->getOptions());
     return $this->getWidgetModel($widget);
 }