You are here

public function CheckoutMerciLineItem::execute in MERCI (Manage Equipment Reservations, Checkout and Inventory) 8.2

Executes the plugin.

Overrides ExecutableInterface::execute

File

modules/merci_line_item/src/Plugin/Action/CheckoutMerciLineItem.php, line 39

Class

CheckoutMerciLineItem
Promotes a merci_line_item.

Namespace

Drupal\merci_line_item\Plugin\Action

Code

public function execute($entity = NULL) {
  $checkout_date = new DrupalDateTime($this->configuration['checkout_date']);
  $checkout_date
    ->setTimezone(new \DateTimezone(DATETIME_STORAGE_TIMEZONE));
  $checkout_string = $checkout_date
    ->format(DATETIME_DATETIME_STORAGE_FORMAT);
  $checkout_date_field = 'field_checkout';
  $entity
    ->set($checkout_date_field, $checkout_string);
  $entity
    ->set('field_reservation_status', 'checked_out');
  $entity
    ->save();
}