You are here

protected static function MenuTreeStorage::schemaDefinition in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Menu/MenuTreeStorage.php \Drupal\Core\Menu\MenuTreeStorage::schemaDefinition()

Defines the schema for the tree table.

Return value

array The schema API definition for the SQL storage table.

3 calls to MenuTreeStorage::schemaDefinition()
MenuTreeStorage::ensureTableExists in core/lib/Drupal/Core/Menu/MenuTreeStorage.php
Checks if the tree table exists and create it if not.
MenuTreeStorage::preSave in core/lib/Drupal/Core/Menu/MenuTreeStorage.php
Fills in all the fields the database save needs, using the link definition.
MenuTreeStorage::serializedFields in core/lib/Drupal/Core/Menu/MenuTreeStorage.php
Determines serialized fields in the storage.

File

core/lib/Drupal/Core/Menu/MenuTreeStorage.php, line 1210
Contains \Drupal\Core\Menu\MenuTreeStorage.

Class

MenuTreeStorage
Provides a menu tree storage using the database.

Namespace

Drupal\Core\Menu

Code

protected static function schemaDefinition() {
  $schema = array(
    'description' => 'Contains the menu tree hierarchy.',
    'fields' => array(
      'menu_name' => array(
        'description' => "The menu name. All links with the same menu name (such as 'tools') are part of the same menu.",
        'type' => 'varchar_ascii',
        'length' => 32,
        'not null' => TRUE,
        'default' => '',
      ),
      'mlid' => array(
        'description' => 'The menu link ID (mlid) is the integer primary key.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'id' => array(
        'description' => 'Unique machine name: the plugin ID.',
        'type' => 'varchar_ascii',
        'length' => 255,
        'not null' => TRUE,
      ),
      'parent' => array(
        'description' => 'The plugin ID for the parent of this link.',
        'type' => 'varchar_ascii',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'route_name' => array(
        'description' => 'The machine name of a defined Symfony Route this menu item represents.',
        'type' => 'varchar_ascii',
        'length' => 255,
      ),
      'route_param_key' => array(
        'description' => 'An encoded string of route parameters for loading by route.',
        'type' => 'varchar',
        'length' => 255,
      ),
      'route_parameters' => array(
        'description' => 'Serialized array of route parameters of this menu link.',
        'type' => 'blob',
        'size' => 'big',
        'not null' => FALSE,
        'serialize' => TRUE,
      ),
      'url' => array(
        'description' => 'The external path this link points to (when not using a route).',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'title' => array(
        'description' => 'The serialized title for the link. May be a TranslatableMarkup.',
        'type' => 'blob',
        'size' => 'big',
        'not null' => FALSE,
        'serialize' => TRUE,
      ),
      'description' => array(
        'description' => 'The serialized description of this link - used for admin pages and title attribute. May be a TranslatableMarkup.',
        'type' => 'blob',
        'size' => 'big',
        'not null' => FALSE,
        'serialize' => TRUE,
      ),
      'class' => array(
        'description' => 'The class for this link plugin.',
        'type' => 'text',
        'not null' => FALSE,
      ),
      'options' => array(
        'description' => 'A serialized array of URL options, such as a query string or HTML attributes.',
        'type' => 'blob',
        'size' => 'big',
        'not null' => FALSE,
        'serialize' => TRUE,
      ),
      'provider' => array(
        'description' => 'The name of the module that generated this link.',
        'type' => 'varchar_ascii',
        'length' => DRUPAL_EXTENSION_NAME_MAX_LENGTH,
        'not null' => TRUE,
        'default' => 'system',
      ),
      'enabled' => array(
        'description' => 'A flag for whether the link should be rendered in menus. (0 = a disabled menu item that may be shown on admin screens, 1 = a normal, visible link)',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 1,
        'size' => 'small',
      ),
      'discovered' => array(
        'description' => 'A flag for whether the link was discovered, so can be purged on rebuild',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'small',
      ),
      'expanded' => array(
        'description' => 'Flag for whether this link should be rendered as expanded in menus - expanded links always have their child links displayed, instead of only when the link is in the active trail (1 = expanded, 0 = not expanded)',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'small',
      ),
      'weight' => array(
        'description' => 'Link weight among links in the same menu at the same depth.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'metadata' => array(
        'description' => 'A serialized array of data that may be used by the plugin instance.',
        'type' => 'blob',
        'size' => 'big',
        'not null' => FALSE,
        'serialize' => TRUE,
      ),
      'has_children' => array(
        'description' => 'Flag indicating whether any enabled links have this link as a parent (1 = enabled children exist, 0 = no enabled children).',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'small',
      ),
      'depth' => array(
        'description' => 'The depth relative to the top level. A link with empty parent will have depth == 1.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'small',
      ),
      'p1' => array(
        'description' => 'The first mlid in the materialized path. If N = depth, then pN must equal the mlid. If depth > 1 then p(N-1) must equal the parent link mlid. All pX where X > depth must equal zero. The columns p1 .. p9 are also called the parents.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'p2' => array(
        'description' => 'The second mlid in the materialized path. See p1.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'p3' => array(
        'description' => 'The third mlid in the materialized path. See p1.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'p4' => array(
        'description' => 'The fourth mlid in the materialized path. See p1.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'p5' => array(
        'description' => 'The fifth mlid in the materialized path. See p1.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'p6' => array(
        'description' => 'The sixth mlid in the materialized path. See p1.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'p7' => array(
        'description' => 'The seventh mlid in the materialized path. See p1.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'p8' => array(
        'description' => 'The eighth mlid in the materialized path. See p1.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'p9' => array(
        'description' => 'The ninth mlid in the materialized path. See p1.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'form_class' => array(
        'description' => 'meh',
        'type' => 'varchar',
        'length' => 255,
      ),
    ),
    'indexes' => array(
      'menu_parents' => array(
        'menu_name',
        'p1',
        'p2',
        'p3',
        'p4',
        'p5',
        'p6',
        'p7',
        'p8',
        'p9',
      ),
      // @todo Test this index for effectiveness.
      //   https://www.drupal.org/node/2302197
      'menu_parent_expand_child' => array(
        'menu_name',
        'expanded',
        'has_children',
        array(
          'parent',
          16,
        ),
      ),
      'route_values' => array(
        array(
          'route_name',
          32,
        ),
        array(
          'route_param_key',
          16,
        ),
      ),
    ),
    'primary key' => array(
      'mlid',
    ),
    'unique keys' => array(
      'id' => array(
        'id',
      ),
    ),
  );
  return $schema;
}