/**
  * Edit an existing entry.
  *
  * @param ExtensionCollection                          $extensions
  * @param WidgetExtensionFormBuilder|WidgetFormBuilder $form
  * @param WidgetFormBuilder                            $widget
  * @param ConfigurationFormBuilder                     $configuration
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function edit(ExtensionCollection $extensions, WidgetExtensionFormBuilder $form, WidgetFormBuilder $widget, ConfigurationFormBuilder $configuration, WidgetRepositoryInterface $widgets, $id)
 {
     /* @var WidgetInterface $entry */
     $entry = $widgets->find($id);
     /* @var WidgetExtension $extension */
     $extension = $entry->getExtension();
     $form->setEntry($id);
     $form->addForm('widget', $widget->setEntry($id));
     $form->addForm('configuration', $configuration->setScope($id)->setEntry($extension->getNamespace()));
     return $form->render();
 }
 public function save(WidgetRepositoryInterface $widgets)
 {
     foreach (json_decode($this->request->get('columns')) as $column => $columns) {
         foreach ($columns as $position => $widget) {
             if ($widget = $widgets->find($widget->id)) {
                 $widget->setAttribute('column', $column + 1);
                 $widget->setAttribute('sort_order', $position + 1);
                 $widgets->save($widget);
             }
         }
     }
 }