filebrowser.install in Filebrowser 8
Same filename and directory in other branches
Install, update and uninstall routines for filebrowser module.
File
filebrowser.installView source
<?php
/**
* @file
* Install, update and uninstall routines for filebrowser module.
*/
/* This file is part of "filebrowser".
* Copyright 2009, arNuméral
* Author : Yoran Brault
* eMail : yoran.brault@bad_arnumeral.fr (remove bad_ before sending an email)
* Site : http://www.arnumeral.fr
*
* "filebrowser" is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* "filebrowser" is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with "filebrowser"; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
/**
* Implements hook_install().
*
* Set the filebrowser type to locked. This
* can't be done in the YAML file, so we have to
* do it in code, here.
*/
function filebrowser_install() {
// Do not allow the locked content type to be deleted.
$locked = Drupal::state()
->get('node.type.locked');
$locked['dir_listing'] = 'dir_listing';
Drupal::state()
->set('node.type.locked', $locked);
}
/**
* Implements hook_uninstall().
*
* Our content types will live on in the Drupal installation, even after this
* module is uninstalled. This is a good thing, since it allows the user to
* make decisions about their fate. Therefore we should give the user the
* option of deleting them.
*
* Since we told Drupal that our locked_content_type is locked, we now have
* to tell it to unlock.
*
*/
function filebrowser_uninstall() {
// Allow dir_listing to be deleted.
$locked = Drupal::state()
->get('node.type.locked');
unset($locked['dir_listing']);
Drupal::state()
->set('node.type.locked', $locked);
}
/**
* Implements hook_schema().
*/
function filebrowser_schema() {
$schema['filebrowser'] = array(
'description' => 'Stores FooBar items.',
'fields' => array(
'filebrowserid' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Unique FooBar item ID.',
),
'uuid' => array(
'description' => 'Unique Key: Universally unique identifier for this entity.',
'type' => 'varchar',
'length' => 128,
'not null' => FALSE,
),
'type' => array(
'description' => 'The bundle of the FooBar entity.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'langcode' => array(
'description' => 'The {language}.langcode of the original variant of this FoBar entity.',
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
),
'name' => array(
'description' => 'The name of the FooBar entity.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'user_id' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
'default' => NULL,
'description' => 'The {users}.uid of the associated user.',
),
'filebrowser_field' => array(
'description' => 'Additional field for the FooBar entity.',
'type' => 'varchar',
'length' => 32,
'not null' => FALSE,
'default' => '',
),
),
'primary key' => array(
'filebrowserid',
),
'unique keys' => array(
'uuid' => array(
'uuid',
),
),
);
return $schema;
}
Functions
Name | Description |
---|---|
filebrowser_install | Implements hook_install(). |
filebrowser_schema | Implements hook_schema(). |
filebrowser_uninstall | Implements hook_uninstall(). |