ConfigTest.php 2.02 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
<?php

/**
 * @file
 * Definition of Drupal\config_test\Plugin\Core\Entity\ConfigTest.
 */

namespace Drupal\config_test\Plugin\Core\Entity;

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

/**
 * Defines the ConfigTest configuration entity.
 *
17
 * @EntityType(
18
19
20
 *   id = "config_test",
 *   label = @Translation("Test configuration"),
 *   module = "config_test",
21
22
23
24
25
26
 *   controllers = {
 *     "storage" = "Drupal\config_test\ConfigTestStorageController",
 *     "list" = "Drupal\Core\Config\Entity\ConfigEntityListController",
 *     "form" = {
 *       "default" = "Drupal\config_test\ConfigTestFormController"
 *     }
27
28
29
30
31
32
 *   },
 *   uri_callback = "config_test_uri",
 *   config_prefix = "config_test.dynamic",
 *   entity_keys = {
 *     "id" = "id",
 *     "label" = "label",
33
34
 *     "uuid" = "uuid",
 *     "status" = "status"
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
 *   }
 * )
 */
class ConfigTest extends ConfigEntityBase {

  /**
   * 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;

  /**
   * The image style to use.
   *
   * @var string
   */
  public $style;

68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
  /**
   * 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;
  }

89
90
91
92
93
94
95
96
  /**
   * Overrides \Drupal\Core\Config\Entity\ConfigEntityBase::sort().
   */
  public static function sort($a, $b) {
    state()->set('config_entity_sort', TRUE);
    return parent::sort($a, $b);
  }

97
}