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' => [], ]; } }