/** * {@inheritdoc} */ public static function schema(FieldStorageDefinitionInterface $field_definition) { $schema = parent::schema($field_definition); $schema['columns']['status'] = array('description' => 'A flag indicating whether the user is subscribed (1) or unsubscribed (0).', 'type' => 'int', 'size' => 'tiny', 'not null' => FALSE); $schema['columns']['timestamp'] = array('description' => 'UNIX timestamp of when the user is (un)subscribed.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE); $schema['columns']['source'] = array('description' => 'The source via which the user is (un)subscription.', 'type' => 'varchar', 'length' => 24, 'not null' => FALSE); return $schema; }
/** * {@inheritdoc} */ public static function schema(FieldStorageDefinitionInterface $field_definition) { $schema = parent::schema($field_definition); $schema['columns']['handler'] = array('description' => 'The issue handler.', 'type' => 'varchar', 'length' => 255, 'not null' => FALSE); $schema['columns']['handler_settings'] = array('description' => 'The issue handler settings.', 'type' => 'blob', 'size' => 'big', 'not null' => FALSE, 'serialize' => TRUE); $schema['columns']['status'] = array('description' => 'A flag indicating whether the issue is published (3), ready (2), pending (1) or not (0).', 'type' => 'int', 'size' => 'tiny', 'not null' => FALSE); $schema['columns']['sent_count'] = array('description' => 'Counter of already sent newsletters.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE); $schema['columns']['subscribers'] = array('description' => 'Counter of subscribers.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE); return $schema; }
/** * {@inheritdoc} */ public static function schema(FieldStorageDefinitionInterface $field_definition) { $target_type = $field_definition->getSetting('target_type'); $target_type_info = \Drupal::entityTypeManager()->getDefinition($target_type); $schema = parent::schema($field_definition); if ($target_type_info->getKey('revision')) { $schema['columns']['target_revision_id'] = array('description' => 'The revision ID of the target entity.', 'type' => 'int', 'unsigned' => TRUE); $schema['indexes']['target_revision_id'] = array('target_revision_id'); } return $schema; }
/** * Helper method to mock all store definitions. */ protected function setupFieldStorageDefinition() { $id_field_storage_definition = $this->getMock('Drupal\\Core\\Field\\FieldStorageDefinitionInterface'); $id_field_storage_definition->expects($this->any())->method('getSchema')->willReturn(IntegerItem::schema($id_field_storage_definition)); $uuid_field_storage_definition = $this->getMock('Drupal\\Core\\Field\\FieldStorageDefinitionInterface'); $uuid_field_storage_definition->expects($this->any())->method('getSchema')->willReturn(UuidItem::schema($uuid_field_storage_definition)); $type_field_storage_definition = $this->getMock('Drupal\\Core\\Field\\FieldStorageDefinitionInterface'); $type_field_storage_definition->expects($this->any())->method('getSchema')->willReturn(StringItem::schema($type_field_storage_definition)); $langcode_field_storage_definition = $this->getMock('Drupal\\Core\\Field\\FieldStorageDefinitionInterface'); $langcode_field_storage_definition->expects($this->any())->method('getSchema')->willReturn(LanguageItem::schema($langcode_field_storage_definition)); $name_field_storage_definition = $this->getMock('Drupal\\Core\\Field\\FieldStorageDefinitionInterface'); $name_field_storage_definition->expects($this->any())->method('getSchema')->willReturn(StringItem::schema($name_field_storage_definition)); $description_field_storage_definition = $this->getMock('Drupal\\Core\\Field\\FieldStorageDefinitionInterface'); $description_field_storage_definition->expects($this->any())->method('getSchema')->willReturn(TextLongItem::schema($description_field_storage_definition)); $homepage_field_storage_definition = $this->getMock('Drupal\\Core\\Field\\FieldStorageDefinitionInterface'); $homepage_field_storage_definition->expects($this->any())->method('getSchema')->willReturn(UriItem::schema($homepage_field_storage_definition)); // Setup the user_id entity reference field. $this->entityManager->expects($this->any())->method('getDefinition')->willReturnMap([['user', TRUE, static::userEntityInfo()]]); $user_id_field_storage_definition = $this->getMock('Drupal\\Core\\Field\\FieldStorageDefinitionInterface'); $user_id_field_storage_definition->expects($this->any())->method('getSetting')->with('target_type')->willReturn('user'); $user_id_field_storage_definition->expects($this->any())->method('getSettings')->willReturn(['target_type' => 'user']); $user_id_field_storage_definition->expects($this->any())->method('getSchema')->willReturn(EntityReferenceItem::schema($user_id_field_storage_definition)); $revision_id_field_storage_definition = $this->getMock('Drupal\\Core\\Field\\FieldStorageDefinitionInterface'); $revision_id_field_storage_definition->expects($this->any())->method('getSchema')->willReturn(IntegerItem::schema($revision_id_field_storage_definition)); $this->entityManager->expects($this->any())->method('getFieldStorageDefinitions')->willReturn(['id' => $id_field_storage_definition, 'uuid' => $uuid_field_storage_definition, 'type' => $type_field_storage_definition, 'langcode' => $langcode_field_storage_definition, 'name' => $name_field_storage_definition, 'description' => $description_field_storage_definition, 'homepage' => $homepage_field_storage_definition, 'user_id' => $user_id_field_storage_definition, 'revision_id' => $revision_id_field_storage_definition]); }
/** * {@inheritdoc} */ public static function schema(FieldStorageDefinitionInterface $field_definition) { $schema = parent::schema($field_definition); $target_type = $field_definition->getSetting('target_type'); $target_type_info = \Drupal::entityManager()->getDefinition($target_type); $properties = static::propertyDefinitions($field_definition)['target_id']; $schema['columns']['display_id'] = array( 'description' => 'The ID of the display.', 'type' => 'varchar_ascii', // If the target entities act as bundles for another entity type, // their IDs should not exceed the maximum length for bundles. 'length' => $target_type_info->getBundleOf() ? EntityTypeInterface::BUNDLE_MAX_LENGTH : 255, ); $schema['columns']['argument'] = array( 'description' => 'An optional argument.', 'type' => 'varchar_ascii', 'length' => 255 ); $schema['indexes']['display_id'] = array('display_id'); return $schema; }
/** * {@inheritdoc} */ public static function schema(FieldStorageDefinitionInterface $field_definition) { $schema = parent::schema($field_definition); $target_type = $field_definition->getSetting('target_type'); $target_type_info = \Drupal::entityManager()->getDefinition($target_type); if ($target_type_info->isSubclassOf('\\Drupal\\Core\\Entity\\ContentEntityInterface') && $field_definition instanceof FieldStorageConfigInterface) { $schema['columns']['revision_id'] = array('description' => 'The revision ID of the target entity.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE); } return $schema; }