You are here

class FlagTracker in Flag Lists 8

Same name and namespace in other branches
  1. 4.0.x src/FlagTracker.php \Drupal\flag_lists\FlagTracker

Class FlagTracker.

Tracks updating of flags.

Hierarchy

Expanded class hierarchy of FlagTracker

1 file declares its use of FlagTracker
flag_lists.module in ./flag_lists.module
Contains flag_lists.module.

File

src/FlagTracker.php, line 13

Namespace

Drupal\flag_lists
View source
class FlagTracker {

  /**
   * {@inheritdoc}
   *
   * Add a FlagForLists record in the database.
   *
   * @param array $form
   *   The form associative array.
   * @param Drupal\Core\Form\FormStateInterface $form_state
   *   The formState array.
   */
  public static function save(array $form, FormStateInterface $form_state) {
    $flagValues = $form_state
      ->getValues();
    $build_array = [];
    $build_array['id'] = $flagValues['id'];
    $build_array['label'] = $flagValues['label'];
    $flagForList = new FlagForList($build_array, 'flag_for_list');
    $flagForList
      ->setBaseFlag($flagValues['id']);
    $flagForList
      ->setOwner();
    $flagForList
      ->save();
  }

  /**
   * {@inheritdoc}
   *
   * Update a FlagForLists record in the database.
   *
   * @param array $form
   *   The form associative array.
   * @param Drupal\Core\Form\FormStateInterface $form_state
   *   The formState array.
   * @param Drupal\flag_lists\FlagForList $flagTemplate
   *   The FlagForList to be update.
   */
  public static function update(array $form, FormStateInterface $form_state, FlagForList $flagTemplate) {
    $flagTemplate
      ->set('label', $form_state
      ->getValue('label'));
    $flagTemplate
      ->setOwner();
    $flagTemplate
      ->save();
  }

  /**
   * Delete a FlagForLists record in the database.
   */
  public function delete() {
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FlagTracker::delete public function Delete a FlagForLists record in the database.
FlagTracker::save public static function Add a FlagForLists record in the database.
FlagTracker::update public static function Update a FlagForLists record in the database.