function MenuTreeStorage::schemaDefinition

Same name in other branches
  1. 9 core/lib/Drupal/Core/Menu/MenuTreeStorage.php \Drupal\Core\Menu\MenuTreeStorage::schemaDefinition()
  2. 10 core/lib/Drupal/Core/Menu/MenuTreeStorage.php \Drupal\Core\Menu\MenuTreeStorage::schemaDefinition()
  3. 11.x core/lib/Drupal/Core/Menu/MenuTreeStorage.php \Drupal\Core\Menu\MenuTreeStorage::schemaDefinition()

Defines the schema for the tree table.

@internal

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 1219

Class

MenuTreeStorage
Provides a menu tree storage using the database.

Namespace

Drupal\Core\Menu

Code

protected static function schemaDefinition() {
    $schema = [
        'description' => 'Contains the menu tree hierarchy.',
        'fields' => [
            'menu_name' => [
                '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' => [
                'description' => 'The menu link ID (mlid) is the integer primary key.',
                'type' => 'serial',
                'unsigned' => TRUE,
                'not null' => TRUE,
            ],
            'id' => [
                'description' => 'Unique machine name: the plugin ID.',
                'type' => 'varchar_ascii',
                'length' => 255,
                'not null' => TRUE,
            ],
            'parent' => [
                'description' => 'The plugin ID for the parent of this link.',
                'type' => 'varchar_ascii',
                'length' => 255,
                'not null' => TRUE,
                'default' => '',
            ],
            'route_name' => [
                'description' => 'The machine name of a defined Symfony Route this menu item represents.',
                'type' => 'varchar_ascii',
                'length' => 255,
            ],
            'route_param_key' => [
                'description' => 'An encoded string of route parameters for loading by route.',
                'type' => 'varchar',
                'length' => 255,
            ],
            'route_parameters' => [
                'description' => 'Serialized array of route parameters of this menu link.',
                'type' => 'blob',
                'size' => 'big',
                'not null' => FALSE,
                'serialize' => TRUE,
            ],
            'url' => [
                'description' => 'The external path this link points to (when not using a route).',
                'type' => 'varchar',
                'length' => 255,
                'not null' => TRUE,
                'default' => '',
            ],
            'title' => [
                'description' => 'The serialized title for the link. May be a TranslatableMarkup.',
                'type' => 'blob',
                'size' => 'big',
                'not null' => FALSE,
                'serialize' => TRUE,
            ],
            'description' => [
                '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' => [
                'description' => 'The class for this link plugin.',
                'type' => 'text',
                'not null' => FALSE,
            ],
            'options' => [
                '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' => [
                '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' => [
                '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' => [
                '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' => [
                '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' => [
                'description' => 'Link weight among links in the same menu at the same depth.',
                'type' => 'int',
                'not null' => TRUE,
                'default' => 0,
            ],
            'metadata' => [
                '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' => [
                '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' => [
                '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' => [
                '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' => [
                'description' => 'The second mlid in the materialized path. See p1.',
                'type' => 'int',
                'unsigned' => TRUE,
                'not null' => TRUE,
                'default' => 0,
            ],
            'p3' => [
                'description' => 'The third mlid in the materialized path. See p1.',
                'type' => 'int',
                'unsigned' => TRUE,
                'not null' => TRUE,
                'default' => 0,
            ],
            'p4' => [
                'description' => 'The fourth mlid in the materialized path. See p1.',
                'type' => 'int',
                'unsigned' => TRUE,
                'not null' => TRUE,
                'default' => 0,
            ],
            'p5' => [
                'description' => 'The fifth mlid in the materialized path. See p1.',
                'type' => 'int',
                'unsigned' => TRUE,
                'not null' => TRUE,
                'default' => 0,
            ],
            'p6' => [
                'description' => 'The sixth mlid in the materialized path. See p1.',
                'type' => 'int',
                'unsigned' => TRUE,
                'not null' => TRUE,
                'default' => 0,
            ],
            'p7' => [
                'description' => 'The seventh mlid in the materialized path. See p1.',
                'type' => 'int',
                'unsigned' => TRUE,
                'not null' => TRUE,
                'default' => 0,
            ],
            'p8' => [
                'description' => 'The eighth mlid in the materialized path. See p1.',
                'type' => 'int',
                'unsigned' => TRUE,
                'not null' => TRUE,
                'default' => 0,
            ],
            'p9' => [
                'description' => 'The ninth mlid in the materialized path. See p1.',
                'type' => 'int',
                'unsigned' => TRUE,
                'not null' => TRUE,
                'default' => 0,
            ],
            'form_class' => [
                'description' => 'meh',
                'type' => 'varchar',
                'length' => 255,
            ],
        ],
        'indexes' => [
            'menu_parents' => [
                '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' => [
                'menu_name',
                'expanded',
                'has_children',
                [
                    'parent',
                    16,
                ],
            ],
            'route_values' => [
                [
                    'route_name',
                    32,
                ],
                [
                    'route_param_key',
                    16,
                ],
            ],
        ],
        'primary key' => [
            'mlid',
        ],
        'unique keys' => [
            'id' => [
                'id',
            ],
        ],
    ];
    return $schema;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.