public function DynamicLayoutController::addColumn in Dynamic Layouts 8
Callback for adding a column.
Parameters
string $dynamic_layout_id: The dynamic layout id.
int $row_id: The row number we need to delete the column.
Return value
object The ajax response.
1 string reference to 'DynamicLayoutController::addColumn'
File
- src/
Controller/ DynamicLayoutController.php, line 128
Class
- DynamicLayoutController
- DynamicLayoutController class.
Namespace
Drupal\dynamic_layouts\ControllerCode
public function addColumn($dynamic_layout_id, $row_id) {
$response = new AjaxResponse();
/* @var \Drupal\dynamic_layouts\DynamicLayoutInterface $config_entity */
if ($config_entity = $this->entityTypeManager
->getStorage(Constants::DYNAMIC_LAYOUT)
->load($dynamic_layout_id)) {
// Add a column to the config entity.
$config_entity
->addColumn($row_id);
// Save the entity.
$config_entity
->save();
// Replace the layout form with newly updated values.
/* @var \Drupal\dynamic_layouts\Form\DynamicLayoutForm $layout_form */
$layout_form = $this->entityFormBuilder
->getForm($config_entity);
$response
->addCommand(new ReplaceCommand(Constants::DYNAMIC_LAYOUT_FORM_CLASS, $layout_form));
}
return $response;
}