PushNotificationStorageSchema.php in Push Notifications 8
File
src/PushNotificationStorageSchema.php
View source
<?php
namespace Drupal\push_notifications;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema;
class PushNotificationStorageSchema extends SqlContentEntityStorageSchema {
protected function getSharedTableFieldSchema(FieldStorageDefinitionInterface $storage_definition, $table_name, array $column_mapping) {
$schema = parent::getSharedTableFieldSchema($storage_definition, $table_name, $column_mapping);
$field_name = $storage_definition
->getName();
if ($table_name == 'push_notifications') {
switch ($field_name) {
case 'title':
case 'langcode':
case 'created':
$this
->addSharedTableFieldIndex($storage_definition, $schema, TRUE);
break;
}
}
if ($table_name == 'push_notifications') {
switch ($field_name) {
case 'langcode':
case 'created':
case 'user_id':
$schema['fields'][$field_name]['not null'] = TRUE;
break;
}
}
return $schema;
}
}