Loading bookable_calendar.install +14 −1 Original line number Diff line number Diff line Loading @@ -114,3 +114,16 @@ function bookable_calendar_update_8105() { \Drupal::entityDefinitionUpdateManager() ->installFieldStorageDefinition('checked_in', 'booking_contact', 'booking_contact', $field_storage_definition); } /** * Add Slots field to Opening Instance */ function bookable_calendar_update_8106() { $field_storage_definition = BaseFieldDefinition::create('integer') ->setLabel(t('Slots')) ->setDescription(t('The number of available slots for this instance. If empty (NB not zero), will use calendar\'s defaults.')) ->setCardinality(1) ->setDefaultValue(NULL); \Drupal::entityDefinitionUpdateManager() ->installFieldStorageDefinition('slots', 'bookable_calendar_opening_inst', 'bookable_calendar_opening_inst', $field_storage_definition); } src/Entity/BookableCalendarOpeningInstance.php +13 −1 Original line number Diff line number Diff line Loading @@ -154,6 +154,18 @@ class BookableCalendarOpeningInstance extends ContentEntityBase implements Booka ->setClass('\Drupal\bookable_calendar\MaxSlotsItemList') ->setDisplayConfigurable('view', TRUE); $fields['slots'] = BaseFieldDefinition::create('integer') ->setLabel(t('Slots')) ->setDescription(t('The number of available slots for this instance. If empty (NB not zero), will use calendar\'s defaults.')) ->setCardinality(1) ->setDisplayOptions('form', [ 'type' => 'integer', 'weight' => 10, ]) ->setSetting('min', 0) ->setDisplayConfigurable('form', TRUE) ->setDisplayConfigurable('view', TRUE); return $fields; } Loading Loading @@ -185,7 +197,7 @@ class BookableCalendarOpeningInstance extends ContentEntityBase implements Booka } public function maxSlotsAvailable() { return (int) $this->getParentCalendar()->slots_per_opening->value; return (int) $this->slots->isEmpty() ? $this->getParentCalendar()->slots_per_opening->value : $this->slots->value; } public function maxPartySize() { Loading Loading
bookable_calendar.install +14 −1 Original line number Diff line number Diff line Loading @@ -114,3 +114,16 @@ function bookable_calendar_update_8105() { \Drupal::entityDefinitionUpdateManager() ->installFieldStorageDefinition('checked_in', 'booking_contact', 'booking_contact', $field_storage_definition); } /** * Add Slots field to Opening Instance */ function bookable_calendar_update_8106() { $field_storage_definition = BaseFieldDefinition::create('integer') ->setLabel(t('Slots')) ->setDescription(t('The number of available slots for this instance. If empty (NB not zero), will use calendar\'s defaults.')) ->setCardinality(1) ->setDefaultValue(NULL); \Drupal::entityDefinitionUpdateManager() ->installFieldStorageDefinition('slots', 'bookable_calendar_opening_inst', 'bookable_calendar_opening_inst', $field_storage_definition); }
src/Entity/BookableCalendarOpeningInstance.php +13 −1 Original line number Diff line number Diff line Loading @@ -154,6 +154,18 @@ class BookableCalendarOpeningInstance extends ContentEntityBase implements Booka ->setClass('\Drupal\bookable_calendar\MaxSlotsItemList') ->setDisplayConfigurable('view', TRUE); $fields['slots'] = BaseFieldDefinition::create('integer') ->setLabel(t('Slots')) ->setDescription(t('The number of available slots for this instance. If empty (NB not zero), will use calendar\'s defaults.')) ->setCardinality(1) ->setDisplayOptions('form', [ 'type' => 'integer', 'weight' => 10, ]) ->setSetting('min', 0) ->setDisplayConfigurable('form', TRUE) ->setDisplayConfigurable('view', TRUE); return $fields; } Loading Loading @@ -185,7 +197,7 @@ class BookableCalendarOpeningInstance extends ContentEntityBase implements Booka } public function maxSlotsAvailable() { return (int) $this->getParentCalendar()->slots_per_opening->value; return (int) $this->slots->isEmpty() ? $this->getParentCalendar()->slots_per_opening->value : $this->slots->value; } public function maxPartySize() { Loading