Loading office_hours.module +6 −6 Original line number Diff line number Diff line Loading @@ -17,13 +17,13 @@ use Drupal\Core\Form\FormStateInterface; * Changes the Field_storage settings form to assure unlimited cardinality. */ function office_hours_form_field_storage_config_edit_form_alter(&$form, FormStateInterface $form_state, $form_id) { $entity = $form_state->getFormObject()->getEntity(); if ($entity->getType() == 'office_hours') { $entity_type = $form_state->getFormObject()->getEntity()->getType(); if ($entity_type == 'office_hours') { $form['cardinality_container']['cardinality'] = [ '#options' => [FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED => t('Unlimited')], '#default_value' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, '#description' => '<p>' . t("This is unlimited by this field's nature. See 'Number of slots' for limiting the number of slots per day."), '#description' => '<p>' . t("This is unlimited by this field's nature. See 'Number of slots' for limiting the number of slots per day.") ] + $form['cardinality_container']['cardinality']; } Loading office_hours.post_update.php +2 −2 Original line number Diff line number Diff line Loading @@ -10,7 +10,7 @@ use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\field\FieldConfigInterface; /** * Adds Office Hours 'default value' schema changes in field config in 8.x-1.3. * Updates Office Hours 'default value' schema in field config in 8.x-1.3. */ function office_hours_post_update_implement_office_hours_default_value_config_schema(&$sandbox = NULL) { \Drupal::classResolver(ConfigEntityUpdater::class) Loading @@ -32,7 +32,7 @@ function office_hours_post_update_implement_office_hours_default_value_config_sc } /** * Adds Office Hours 'formatter.settings' schema changes in entity view display config in 8.x-1.3. * Updates Office Hours 'formatter.settings' schema in entity view display. */ function office_hours_post_update_implement_office_hours_entity_view_display_schema(&$sandbox = NULL) { \Drupal::classResolver(ConfigEntityUpdater::class) Loading src/Element/OfficeHoursDatelist.php +2 −1 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ class OfficeHoursDatelist extends Datelist { * @param \Drupal\Core\Form\FormStateInterface $form_state * * @return array|mixed|null * An array containing 'hour' and 'minute'. */ public static function valueCallback(&$element, $input, FormStateInterface $form_state) { Loading Loading @@ -94,7 +95,7 @@ class OfficeHoursDatelist extends Datelist { * * @param $element * @param \Drupal\Core\Form\FormStateInterface $form_state * @param $complete_form * @param array $complete_form * * @return array * The screen element. Loading src/Element/OfficeHoursDatetime.php +5 −11 Original line number Diff line number Diff line Loading @@ -40,22 +40,16 @@ class OfficeHoursDatetime extends Datetime { /** * Callback for office_hours_select element. * * {@inheritdoc} * * Takes #default_value and dissects it in hours, minutes and ampm indicator. * Mimics the date_parse() function. * - g = 12-hour format of an hour without leading zeros 1 through 12 * - G = 24-hour format of an hour without leading zeros 0 through 23 * - h = 12-hour format of an hour with leading zeros 01 through 12 * - H = 24-hour format of an hour with leading zeros 00 through 23 * * @param array $element * @param mixed $input * @param \Drupal\Core\Form\FormStateInterface $form_state * * @return array|mixed|null * The value, as entered by the user. */ public static function valueCallback(&$element, $input, FormStateInterface $form_state) { $input['time'] = OfficeHoursDatetime::get($element['#default_value'], 'H:i'); $input = parent::valueCallback($element, $input, $form_state); Loading src/Event/OfficeHoursUpdateEvent.php +1 −1 Original line number Diff line number Diff line Loading @@ -2,8 +2,8 @@ namespace Drupal\office_hours\Event; use Symfony\Contracts\EventDispatcher\Event; // use Symfony\Component\EventDispatcher\Event; use Symfony\Contracts\EventDispatcher\Event; /** * Defines an event. Loading Loading
office_hours.module +6 −6 Original line number Diff line number Diff line Loading @@ -17,13 +17,13 @@ use Drupal\Core\Form\FormStateInterface; * Changes the Field_storage settings form to assure unlimited cardinality. */ function office_hours_form_field_storage_config_edit_form_alter(&$form, FormStateInterface $form_state, $form_id) { $entity = $form_state->getFormObject()->getEntity(); if ($entity->getType() == 'office_hours') { $entity_type = $form_state->getFormObject()->getEntity()->getType(); if ($entity_type == 'office_hours') { $form['cardinality_container']['cardinality'] = [ '#options' => [FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED => t('Unlimited')], '#default_value' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, '#description' => '<p>' . t("This is unlimited by this field's nature. See 'Number of slots' for limiting the number of slots per day."), '#description' => '<p>' . t("This is unlimited by this field's nature. See 'Number of slots' for limiting the number of slots per day.") ] + $form['cardinality_container']['cardinality']; } Loading
office_hours.post_update.php +2 −2 Original line number Diff line number Diff line Loading @@ -10,7 +10,7 @@ use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\field\FieldConfigInterface; /** * Adds Office Hours 'default value' schema changes in field config in 8.x-1.3. * Updates Office Hours 'default value' schema in field config in 8.x-1.3. */ function office_hours_post_update_implement_office_hours_default_value_config_schema(&$sandbox = NULL) { \Drupal::classResolver(ConfigEntityUpdater::class) Loading @@ -32,7 +32,7 @@ function office_hours_post_update_implement_office_hours_default_value_config_sc } /** * Adds Office Hours 'formatter.settings' schema changes in entity view display config in 8.x-1.3. * Updates Office Hours 'formatter.settings' schema in entity view display. */ function office_hours_post_update_implement_office_hours_entity_view_display_schema(&$sandbox = NULL) { \Drupal::classResolver(ConfigEntityUpdater::class) Loading
src/Element/OfficeHoursDatelist.php +2 −1 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ class OfficeHoursDatelist extends Datelist { * @param \Drupal\Core\Form\FormStateInterface $form_state * * @return array|mixed|null * An array containing 'hour' and 'minute'. */ public static function valueCallback(&$element, $input, FormStateInterface $form_state) { Loading Loading @@ -94,7 +95,7 @@ class OfficeHoursDatelist extends Datelist { * * @param $element * @param \Drupal\Core\Form\FormStateInterface $form_state * @param $complete_form * @param array $complete_form * * @return array * The screen element. Loading
src/Element/OfficeHoursDatetime.php +5 −11 Original line number Diff line number Diff line Loading @@ -40,22 +40,16 @@ class OfficeHoursDatetime extends Datetime { /** * Callback for office_hours_select element. * * {@inheritdoc} * * Takes #default_value and dissects it in hours, minutes and ampm indicator. * Mimics the date_parse() function. * - g = 12-hour format of an hour without leading zeros 1 through 12 * - G = 24-hour format of an hour without leading zeros 0 through 23 * - h = 12-hour format of an hour with leading zeros 01 through 12 * - H = 24-hour format of an hour with leading zeros 00 through 23 * * @param array $element * @param mixed $input * @param \Drupal\Core\Form\FormStateInterface $form_state * * @return array|mixed|null * The value, as entered by the user. */ public static function valueCallback(&$element, $input, FormStateInterface $form_state) { $input['time'] = OfficeHoursDatetime::get($element['#default_value'], 'H:i'); $input = parent::valueCallback($element, $input, $form_state); Loading
src/Event/OfficeHoursUpdateEvent.php +1 −1 Original line number Diff line number Diff line Loading @@ -2,8 +2,8 @@ namespace Drupal\office_hours\Event; use Symfony\Contracts\EventDispatcher\Event; // use Symfony\Component\EventDispatcher\Event; use Symfony\Contracts\EventDispatcher\Event; /** * Defines an event. Loading