Skip to content
Snippets Groups Projects
Commit c523d857 authored by daffie's avatar daffie
Browse files

Issue #3506110: Add support for the paragraphs module

parent 1dd53384
No related branches found
No related tags found
1 merge request!39Add support for the paragraphs module
Pipeline #422167 failed
......@@ -49,6 +49,10 @@ class MongodbHooks {
$entity_types['node']->setStorageClass('Drupal\mongodb\modules\node\NodeStorage');
}
if (!empty($entity_types['paragraph'])) {
$entity_types['paragraph']->setHandlerClass('storage_schema', 'Drupal\mongodb\modules\paragraphs\ParagraphStorageSchema');
}
if (!empty($entity_types['user'])) {
$entity_types['user']->setStorageClass('Drupal\mongodb\modules\user\UserStorage');
}
......
<?php
namespace Drupal\mongodb\modules\paragraphs;
use Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
/**
* Extends the paragraphs schema handler.
*/
class ParagraphStorageSchema extends SqlContentEntityStorageSchema {
/**
* {@inheritdoc}
*/
protected function getSharedTableFieldSchema(FieldStorageDefinitionInterface $storage_definition, $table_name, array $column_mapping) {
// Setting the initial value to 1 when we add a 'status' field.
// @todo this is a workaround for https://www.drupal.org/node/2346019
$schema = parent::getSharedTableFieldSchema($storage_definition, $table_name, $column_mapping);
if ($storage_definition->getName() == 'status') {
$schema['fields']['status']['initial'] = 1;
}
if ($storage_definition->getName() == 'behavior_settings') {
$schema['fields']['behavior_settings']['initial'] = serialize([]);
}
return $schema;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment