Menu.php 1.42 KB
Newer Older
1 2 3 4
<?php

/**
 * @file
5
 * Contains \Drupal\system\Entity\Menu.
6 7
 */

8
namespace Drupal\system\Entity;
9 10

use Drupal\Core\Config\Entity\ConfigEntityBase;
11
use Drupal\Core\Entity\EntityStorageInterface;
12
use Drupal\system\MenuInterface;
13 14 15 16

/**
 * Defines the Menu configuration entity class.
 *
17
 * @ConfigEntityType(
18 19
 *   id = "menu",
 *   label = @Translation("Menu"),
20
 *   controllers = {
21
 *     "access" = "Drupal\system\MenuAccessController"
22
 *   },
23
 *   admin_permission = "administer menu",
24 25
 *   entity_keys = {
 *     "id" = "id",
26
 *     "label" = "label"
27 28 29
 *   }
 * )
 */
30
class Menu extends ConfigEntityBase implements MenuInterface {
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52

  /**
   * The menu machine name.
   *
   * @var string
   */
  public $id;

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

  /**
   * The menu description.
   *
   * @var string
   */
  public $description;

53 54 55 56 57 58 59 60 61 62
  /**
   * The locked status of this menu.
   *
   * @var bool
   */
  protected $locked = FALSE;

  /**
   * {@inheritdoc}
   */
63 64
  public function toArray() {
    $properties = parent::toArray();
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
    // @todo Make $description protected and include it here, see
    //   https://drupal.org/node/2030645.
    $names = array(
      'locked',
    );
    foreach ($names as $name) {
      $properties[$name] = $this->get($name);
    }
    return $properties;
  }

  /**
   * {@inheritdoc}
   */
  public function isLocked() {
    return (bool) $this->locked;
  }

83
}