Commit 628c8d72 authored by John Voskuilen's avatar John Voskuilen
Browse files

Issue #3219111: Clean code

parent f77f83c4
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -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'];
  }
+2 −2
Original line number Diff line number Diff line
@@ -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)
@@ -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)
+2 −1
Original line number Diff line number Diff line
@@ -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) {

@@ -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.
+5 −11
Original line number Diff line number Diff line
@@ -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);
+1 −1
Original line number Diff line number Diff line
@@ -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