Account created on 1 March 2014, almost 11 years ago
#

Recent comments

πŸ‡ΊπŸ‡ΈUnited States Amerie

From what we have found, this notice is generated any time a view page using facets is accessed with a key in the URL query string that doesn't correspond to a facet. For example if your view is example.com/view, if you go to example.com/view?key=value and "key" is not associated with a facet you have created, it will generate the "The core_views_facets module tried at least once to generically handle..." notice. We have been having issues with bot activity involving a whole bunch of nonsense in the query strings, which has been generating thousands of these notices. Would be nice to have an option to either skip the "generic" handling or at least suppress the notices, but I'm not familiar enough with the workings of this module to be able to figure out how to do that. Advice welcome!

πŸ‡ΊπŸ‡ΈUnited States Amerie

Works great for me, thank you! Here is a patch for 3.0.3 if people need it for composer.

πŸ‡ΊπŸ‡ΈUnited States Amerie

Just wanted to give a heads up that the problem reported by riskogab in comment #105 is still an issue with the latest patch (comment #189). Using a List (text) field with unlimited allowed values using the checkboxes widget as a Controlled By field does not work inside a paragraph, though other field types do, and it does work on a node.

πŸ‡ΊπŸ‡ΈUnited States Amerie

We are using an entity autocomplete field in a custom form (not an entity edit form) and I couldn't find any info about how to use the views selection plugin in that situation so we just created our own selection plugin that extends the default one. Here it is in case anyone else needs it:

<?php

namespace Drupal\YOUR_MODULE\Plugin\EntityReferenceSelection;

use Drupal\Component\Utility\Html;
use Drupal\Core\Entity\EntityReferenceSelection\SelectionWithAutocreateInterface;
use Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection;
use Drupal\Core\Field\EntityReferenceFieldItemListInterface;

/**
 * Custom plugin implementation of the Entity Reference Selection plugin.
 *
 * @EntityReferenceSelection(
 *   id = "default_with_bundle",
 *   label = @Translation("Default (with entity bundle)"),
 *   group = "default",
 *   weight = 0,
 *   deriver = "Drupal\Core\Entity\Plugin\Derivative\DefaultSelectionDeriver"
 * )
 */
class DefaultWithBundleSelection extends DefaultSelection implements SelectionWithAutocreateInterface {

  /**
   * {@inheritdoc}
   */
  public function getReferenceableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) {
    $target_type = $this->getConfiguration()['target_type'];

    $query = $this->buildEntityQuery($match, $match_operator);
    if ($limit > 0) {
      $query->range(0, $limit);
    }

    $result = $query->execute();

    if (empty($result)) {
      return [];
    }

    $options = [];
    $entities = $this->entityTypeManager->getStorage($target_type)->loadMultiple($result);
    foreach ($entities as $entity_id => $entity) {
      $bundle = $entity->bundle();
      $entity_label = $this->entityRepository->getTranslationFromContext($entity)->label() ?? '';
      $bundle_label = $this->getBundleLabel($entity);
      $options[$bundle][$entity_id] = Html::escape($entity_label . ' [' . $bundle_label . ']');
    }

    return $options;
  }

  private function getBundleLabel($entity) {
    $label = '';
    if ($entity) {
      if ($bundle_field_name = $entity->getEntityType()->getKey('bundle')) {
        $bundle_field = $entity->get($bundle_field_name);
        if ($bundle_field instanceof EntityReferenceFieldItemListInterface) {
          $label = $bundle_field->entity->label();
        } else {
          $lable = $entity->bundle();
        }
      }
    }
    return $label;
  }

}
πŸ‡ΊπŸ‡ΈUnited States Amerie

Here is a patch version of the changes in #9 just in case anyone else needs it. :) Also I don't think it says anywhere (or I could have just missed it) but the argument needs to be given with a dash between the workflow name and the moderation state name (e.g. editorial-published).

Production build 0.71.5 2024