You are here

function VimeoSettingsForm::AddContentTypeField in Vimeo Video Uploader 8

Same name and namespace in other branches
  1. 8.4 src/Form/VimeoSettingsForm.php \Drupal\vimeo_video_uploader\Form\VimeoSettingsForm::addContentTypeField()
1 call to VimeoSettingsForm::AddContentTypeField()
VimeoSettingsForm::submitForm in src/Form/VimeoSettingsForm.php
Form submission handler.

File

src/Form/VimeoSettingsForm.php, line 130
Contains \Drupal\vimeo_video_uploader\Form\SettingsForm.

Class

VimeoSettingsForm
Provide configuration form for user to provide vimeo API information for a

Namespace

Drupal\vimeo_video_uploader\Form

Code

function AddContentTypeField($bundle) {
  \Drupal\field\Entity\FieldStorageConfig::create(array(
    'field_name' => 'field_vimeo_file_browse',
    'entity_type' => 'node',
    'type' => 'file',
  ))
    ->save();
  \Drupal\field\Entity\FieldConfig::create([
    'field_name' => 'field_vimeo_file_browse',
    'entity_type' => 'node',
    'bundle' => $bundle,
    'settings' => array(
      'file_extensions' => 'mp4',
    ),
    'label' => 'Browse video for uploading to Vimeo',
  ])
    ->save();
  entity_get_form_display('node', $bundle, 'default')
    ->setComponent('field_vimeo_file_browse', array(
    'type' => 'file_generic',
  ))
    ->save();
  entity_get_display('node', $bundle, 'default')
    ->setComponent('field_vimeo_file_browse', array(
    'type' => 'file_default',
  ))
    ->save();

  //add embedded video input field
  \Drupal\field\Entity\FieldStorageConfig::create(array(
    'field_name' => 'field_embeddedvideo',
    'entity_type' => 'node',
    'type' => 'video_embed_field',
  ))
    ->save();
  \Drupal\field\Entity\FieldConfig::create([
    'field_name' => 'field_embeddedvideo',
    'entity_type' => 'node',
    'bundle' => $bundle,
    'label' => 'Vimeo video link',
  ])
    ->save();
  entity_get_form_display('node', $bundle, 'default')
    ->setComponent('field_embeddedvideo', array(
    'type' => 'video_embed_field_textfield',
    'class' => 'neera',
  ))
    ->save();
  entity_get_display('node', $bundle, 'default')
    ->setComponent('field_embeddedvideo', array(
    'type' => 'video_embed_field_video',
  ))
    ->save();
}