public function UpdateController::drop in FullCalendar 8.5
Same name and namespace in other branches
- 8 src/Controller/UpdateController.php \Drupal\fullcalendar\Controller\UpdateController::drop()
- 8.2 src/Controller/UpdateController.php \Drupal\fullcalendar\Controller\UpdateController::drop()
- 8.3 src/Controller/UpdateController.php \Drupal\fullcalendar\Controller\UpdateController::drop()
- 8.4 src/Controller/UpdateController.php \Drupal\fullcalendar\Controller\UpdateController::drop()
@todo.
Parameters
\Drupal\Core\Entity\EntityInterface $entity:
string $field:
int $index:
\Symfony\Component\HttpFoundation\Request $request:
Return value
\Symfony\Component\HttpFoundation\JsonResponse
1 string reference to 'UpdateController::drop'
File
- src/
Controller/ UpdateController.php, line 29
Class
- UpdateController
- @todo.
Namespace
Drupal\fullcalendar\ControllerCode
public function drop(EntityInterface $entity, $field, $index, Request $request) {
if ($request->request
->has('day_delta') && $request->request
->has('minute_delta')) {
$day_delta = Html::escape($request->request
->get('day_delta'));
$minute_delta = Html::escape($request->request
->get('minute_delta'));
$delta = " {$day_delta} days {$minute_delta} minutes";
$field_item = $entity->{$field}
->get($index);
$value = $field_item->value;
$field_item
->set('value', date(DateTimeItemInterface::DATETIME_STORAGE_FORMAT, strtotime($value . $delta)));
// Save the new start/end values.
$entity
->save();
$url = Url::fromUserInput('/');
$link = Link::fromTextAndUrl($this
->t('Close'), $url);
$link = $link
->toRenderable();
$link['#attributes']['class'][] = 'fullcalendar-status-close';
$message = $this
->t('The new event time has been saved.');
$message .= ' [' . \Drupal::service('renderer')
->render($link) . ']';
}
else {
$message = $this
->t('The event has not been updated.');
}
return new JsonResponse([
'msg' => $message,
'dom_id' => $request->request
->get('dom_id'),
]);
}