ConfigTest.php 2.35 KB
Newer Older
1 2 3 4
<?php

/**
 * @file
5
 * Definition of Drupal\config_test\Entity\ConfigTest.
6 7
 */

8
namespace Drupal\config_test\Entity;
9 10

use Drupal\Core\Config\Entity\ConfigEntityBase;
11
use Drupal\Core\Entity\Annotation\EntityType;
12
use Drupal\Core\Annotation\Translation;
13
use Drupal\config_test\ConfigTestInterface;
14 15 16 17

/**
 * Defines the ConfigTest configuration entity.
 *
18
 * @EntityType(
19 20 21
 *   id = "config_test",
 *   label = @Translation("Test configuration"),
 *   module = "config_test",
22 23
 *   controllers = {
 *     "storage" = "Drupal\config_test\ConfigTestStorageController",
24
 *     "list" = "Drupal\config_test\ConfigTestListController",
25
 *     "form" = {
26 27
 *       "default" = "Drupal\config_test\ConfigTestFormController",
 *       "delete" = "Drupal\config_test\Form\ConfigTestDeleteForm"
28 29
 *     },
 *     "access" = "Drupal\config_test\ConfigTestAccessController"
30 31 32 33 34
 *   },
 *   config_prefix = "config_test.dynamic",
 *   entity_keys = {
 *     "id" = "id",
 *     "label" = "label",
35 36
 *     "uuid" = "uuid",
 *     "status" = "status"
37 38 39
 *   },
 *   links = {
 *     "edit-form" = "admin/structure/config_test/manage/{config_test}"
40 41 42
 *   }
 * )
 */
43
class ConfigTest extends ConfigEntityBase implements ConfigTestInterface {
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65

  /**
   * The machine name for the configuration entity.
   *
   * @var string
   */
  public $id;

  /**
   * The UUID for the configuration entity.
   *
   * @var string
   */
  public $uuid;

  /**
   * The human-readable name of the configuration entity.
   *
   * @var string
   */
  public $label;

66 67 68 69 70 71 72
  /**
   * The weight of the configuration entity.
   *
   * @var int
   */
  public $weight = 0;

73 74 75 76 77 78 79
  /**
   * The image style to use.
   *
   * @var string
   */
  public $style;

80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
  /**
   * A protected property of the configuration entity.
   *
   * @var string
   */
  protected $protected_property;

  /**
   * Overrides \Drupal\Core\Config\Entity\ConfigEntityBase::getExportProperties();
   */
  public function getExportProperties() {
    $properties = parent::getExportProperties();
    $protected_names = array(
      'protected_property',
    );
    foreach ($protected_names as $name) {
      $properties[$name] = $this->get($name);
    }
    return $properties;
  }

101 102 103 104
  /**
   * Overrides \Drupal\Core\Config\Entity\ConfigEntityBase::sort().
   */
  public static function sort($a, $b) {
105
    \Drupal::state()->set('config_entity_sort', TRUE);
106 107 108
    return parent::sort($a, $b);
  }

109
}