Skip to content
Snippets Groups Projects

Issue #3373258 by a.dmitriiev, leymannx: Allow to select reference method in...

Open Issue #3373258 by a.dmitriiev, leymannx: Allow to select reference method in...
9 unresolved threads
Open Artem Dmitriiev requested to merge issue/drupal-3373258:3373258-allow-to-select into 11.x
9 unresolved threads

Issue #3373258 by a.dmitriiev, leymannx: Allow to select reference method in link field type for internal links

Closes #3373258

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
110 181 ],
111 182 ];
112 183
184 return $form;
185 }
186
187 /**
188 * Form element validation handler; Invokes selection plugin's validation.
189 *
190 * @param array $form
191 * The form where the settings form is being included in.
192 * @param \Drupal\Core\Form\FormStateInterface $form_state
193 * The form state of the (entire) configuration form.
194 */
195 public static function fieldSettingsFormValidate(array $form, FormStateInterface $form_state) {
  • 193 * The form state of the (entire) configuration form.
    194 */
    195 public static function fieldSettingsFormValidate(array $form, FormStateInterface $form_state) {
    196 /** @var \Drupal\Core\Field\FieldDefinitionInterface $field */
    197 $field = $form_state->getFormObject()->getEntity();
    198 $field->getFieldStorageDefinition()->setSetting('target_type', 'node');
    199 $handler = \Drupal::service('plugin.manager.entity_reference_selection')->getSelectionHandler($field);
    200 $handler->validateConfigurationForm($form, $form_state);
    201 }
    202
    203 /**
    204 * Render API callback: Processes the field settings form.
    205 *
    206 * @see static::fieldSettingsForm()
    207 */
    208 public static function fieldSettingsAjaxProcess($form, FormStateInterface $form_state) {
  • 203 /**
    204 * Render API callback: Processes the field settings form.
    205 *
    206 * @see static::fieldSettingsForm()
    207 */
    208 public static function fieldSettingsAjaxProcess($form, FormStateInterface $form_state) {
    209 static::fieldSettingsAjaxProcessElement($form, $form);
    210 return $form;
    211 }
    212
    213 /**
    214 * Adds the field settings to AJAX form elements.
    215 *
    216 * @see static::fieldSettingsAjaxProcess()
    217 */
    218 public static function fieldSettingsAjaxProcessElement(&$element, $main_form) {
  • 225 }
    226
    227 foreach (Element::children($element) as $key) {
    228 static::fieldSettingsAjaxProcessElement($element[$key], $main_form);
    229 }
    230 }
    231
    232 /**
    233 * Render API callback that moves entity reference elements up a level.
    234 *
    235 * The elements (i.e. 'handler_settings') are moved for easier processing by
    236 * the validation and submission handlers.
    237 *
    238 * @see _entity_reference_field_settings_process()
    239 */
    240 public static function formProcessMergeParent($element) {
  • 237 *
    238 * @see _entity_reference_field_settings_process()
    239 */
    240 public static function formProcessMergeParent($element) {
    241 $parents = $element['#parents'];
    242 array_pop($parents);
    243 $element['#parents'] = $parents;
    113 244 return $element;
    114 245 }
    115 246
    247 /**
    248 * Ajax callback for the handler settings form.
    249 *
    250 * @see static::fieldSettingsForm()
    251 */
    252 public static function settingsAjax($form, FormStateInterface $form_state) {
  • 115 246
    247 /**
    248 * Ajax callback for the handler settings form.
    249 *
    250 * @see static::fieldSettingsForm()
    251 */
    252 public static function settingsAjax($form, FormStateInterface $form_state) {
    253 return NestedArray::getValue($form, $form_state->getTriggeringElement()['#ajax']['element']);
    254 }
    255
    256 /**
    257 * Submit handler for the non-JS case.
    258 *
    259 * @see static::fieldSettingsForm()
    260 */
    261 public static function settingsAjaxSubmit($form, FormStateInterface $form_state) {
  • 349 356 return $element;
    350 357 }
    351 358
    359 /**
    360 * Returns the options for the match operator.
    361 *
    362 * @return array
    363 * List of options.
    364 */
    365 protected function getMatchOperatorOptions() {
  • 16 */
    17 protected $defaultTheme = 'stark';
    18
    19 /**
    20 * {@inheritdoc}
    21 */
    22 protected function setDatabaseDumpFiles() {
    23 $this->databaseDumpFiles = [
    24 __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-9.4.0.filled.standard.php.gz',
    25 ];
    26 }
    27
    28 /**
    29 * Tests update hook setting handler for field type.
    30 */
    31 public function testLinkFieldTypeUpdate() {
  • 32 $config = $this->config('field.field.node.test_content_type.field_test_5');
    33 $this->assertEmpty($config->get('settings.handler'));
    34 $this->assertEmpty($config->get('settings.handler_settings'));
    35
    36 // Run updates.
    37 $this->runUpdates();
    38
    39 $config = $this->config('field.field.node.test_content_type.field_test_5');
    40 $this->assertSame('default', $config->get('settings.handler'));
    41 $this->assertIsArray($config->get('settings.handler_settings'));
    42 }
    43
    44 /**
    45 * Tests update hook setting handler for field type.
    46 */
    47 public function testLinkWidgetMatchSettingsUpdate() {
  • Didn't flag them all but new functions needs typehints

  • Artem Dmitriiev added 1 commit

    added 1 commit

    • a670f409 - Issue #3373258 by a.dmitriiev, leymannx: Add typehints for new functions and their parameters

    Compare with previous version

  • Roman Paska added 1305 commits

    added 1305 commits

    Compare with previous version

  • Roman Paska added 1 commit

    added 1 commit

    • f3d9b354 - Update LinkPostUpdateTest.php

    Compare with previous version

  • Roman Paska added 1 commit

    added 1 commit

    • 4b4b6189 - Update file LinkPostUpdateTest.php

    Compare with previous version

  • Please register or sign in to reply
    Loading