SHARE
TWEET

Untitled

a guest Jun 19th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
  2.  
  3.   $properties = parent::propertyDefinitions($field_definition);
  4.   $properties['icon_id'] = DataReferenceDefinition::create('entity')
  5.     ->setLabel('Image')
  6.     ->setDescription(new TranslatableMarkup('The referenced entity image'))
  7.     ->setComputed(TRUE)
  8.     ->setReadOnly(FALSE)
  9.     ->setTargetDefinition(EntityDataDefinition::create('media'));
  10.  
  11.   return $properties;
  12. }
  13.  
  14. public static function schema(FieldStorageDefinitionInterface $field_definition) {
  15.     $schema = parent::schema($field_definition);
  16.  
  17.     $schema['columns']['icon_id'] = [
  18.       'description' => 'The icon ID',
  19.       'type' => 'int',
  20.       'unsigned' => TRUE,
  21.     ];
  22.  
  23.     return $schema;
  24.   }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top