You are here

ConfigEntityRevisionFields.php in Config Entity Revisions 1.x

File

src/ConfigEntityRevisionFields.php
View source
<?php

namespace Drupal\config_entity_revisions;

class ConfigEntityRevisionFields implements ConfigEntityRevisionFieldsInterface {

  /**
   * Should new revisions created by default?
   *
   * @return bool
   *   No new revision by default.
   */
  public static function getNewRevisionDefault() {
    return FALSE;
  }

  /**
   * Adds the revision form fields to the form.
   *
   * @param &$form
   *   The form to which the fields should be added.
   */
  public static function addRevisionFormFields(&$form) {

    // Add a log field if the "Create new revision" option is checked, or if the
    // current user has the ability to check that option.
    $new_revision_default = self::getNewRevisionDefault();
    $form['revision'] = [
      '#type' => 'checkbox',
      '#title' => t('Create new revision'),
      '#default_value' => $new_revision_default,
      '#group' => 'revision_information',
    ];
  }

}

Classes