You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.3 KiB
60 lines
1.3 KiB
<?php |
|
|
|
/** |
|
* @file |
|
* Install/update hook implementations. |
|
*/ |
|
|
|
use Drupal\rest\Entity\RestResourceConfig; |
|
|
|
/** |
|
* Implements hook_schema(). |
|
*/ |
|
function islandora_schema() { |
|
$schema = []; |
|
$schema['islandora_version_count'] = [ |
|
'description' => 'Keeps track of the number of changes to an entity', |
|
'fields' => [ |
|
'id' => [ |
|
'description' => 'Autoincrementing id for record', |
|
'type' => 'serial', |
|
'unsigned' => TRUE, |
|
'not null' => TRUE, |
|
], |
|
'uuid' => [ |
|
'description' => 'UUID for an entity', |
|
'type' => 'varchar', |
|
'length' => 128, |
|
'not null' => TRUE, |
|
'unique' => TRUE, |
|
], |
|
'count' => [ |
|
'description' => 'Number of times an entity has been updated.', |
|
'type' => 'int', |
|
'unsigned' => TRUE, |
|
'default' => 0, |
|
], |
|
], |
|
'primary key' => ['id'], |
|
'unique keys' => [ |
|
'uuid' => ['uuid'], |
|
], |
|
]; |
|
return $schema; |
|
} |
|
|
|
/** |
|
* Implemets hook_install(). |
|
*/ |
|
function islandora_install() { |
|
$rest_config = RestResourceConfig::load('entity.node'); |
|
|
|
$configuration = [ |
|
'methods' => ['GET', 'POST', 'PATCH', 'DELETE'], |
|
'formats' => ['hal_json', 'jsonld'], |
|
'authentication' => ['basic_auth', 'jwt_auth', 'cookie'], |
|
]; |
|
|
|
$rest_config->set('configuration', $configuration); |
|
$rest_config->save(TRUE); |
|
}
|
|
|