X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fvideo_embed_field%2Fsrc%2FPlugin%2FField%2FFieldType%2FVideoEmbedField.php;fp=web%2Fmodules%2Fcontrib%2Fvideo_embed_field%2Fsrc%2FPlugin%2FField%2FFieldType%2FVideoEmbedField.php;h=48b1b541731b25dc41667fa30883e2c0ac0ac7d5;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/modules/contrib/video_embed_field/src/Plugin/Field/FieldType/VideoEmbedField.php b/web/modules/contrib/video_embed_field/src/Plugin/Field/FieldType/VideoEmbedField.php new file mode 100644 index 000000000..48b1b5417 --- /dev/null +++ b/web/modules/contrib/video_embed_field/src/Plugin/Field/FieldType/VideoEmbedField.php @@ -0,0 +1,105 @@ +providerManager = $provider_manager; + } + + /** + * {@inheritdoc} + */ + public static function createInstance($definition, $name = NULL, TraversableTypedDataInterface $parent = NULL) { + $provider_manager = \Drupal::service('video_embed_field.provider_manager'); + return new static($definition, $name, $parent, $provider_manager); + } + + /** + * {@inheritdoc} + */ + public static function schema(FieldStorageDefinitionInterface $field_definition) { + return [ + 'columns' => [ + 'value' => [ + 'type' => 'varchar', + 'length' => 256, + ], + ], + ]; + } + + /** + * {@inheritdoc} + */ + public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { + $properties['value'] = DataDefinition::create('string') + ->setLabel(t('Video url')) + ->setRequired(TRUE); + return $properties; + } + + /** + * {@inheritdoc} + */ + public function isEmpty() { + $value = $this->get('value')->getValue(); + return empty($value); + } + + /** + * {@inheritdoc} + */ + public function fieldSettingsForm(array $form, FormStateInterface $form_state) { + $form = []; + $form['allowed_providers'] = [ + '#title' => $this->t('Allowed Providers'), + '#description' => $this->t('Restrict users from entering information from the following providers. If none are selected any video provider can be used.'), + '#type' => 'checkboxes', + '#default_value' => $this->getSetting('allowed_providers'), + '#options' => $this->providerManager->getProvidersOptionList(), + ]; + return $form; + } + + /** + * {@inheritdoc} + */ + public static function defaultFieldSettings() { + return [ + 'allowed_providers' => [], + ]; + } + +}