Problem/Motivation

In discussion with @chr.fritsch, @daniel.bosen and @mtodor we realised that there was a need to reliably get the ID of the active entity for a specific feature. This allows code to work with selected configuration without caring which one is selected.

Proposed resolution

Add a service to provide this functionality.

Remaining tasks

User interface changes

None

API changes

New service

Data model changes

None

Comments

alexpott created an issue. See original summary.

alexpott’s picture

Status: Active » Needs review
StatusFileSize
new13.51 KB

Initial work - one @todo where we have multiply active entities.

alexpott’s picture

StatusFileSize
new12.56 KB

Updated to deal with the situation when there are two active configurations. The config_selector.active service will always select the one with the highest priority. Which I think is inline with the expectations set by the module.

chr.fritsch’s picture

Status: Needs review » Needs work
+++ b/src/Active.php
@@ -0,0 +1,99 @@
+   * Gets the ID of the active entity.
...
+  public function getEntityFromEntity(ConfigEntityInterface $entity) {

This does not correspond. Also, the method name getEntityFromEntity is not really expressive.

alexpott’s picture

Status: Needs work » Needs review
StatusFileSize
new13.95 KB
new9.81 KB

Good point. Cleaned it up to have less surface area and a cleaner API.
\Drupal\config_selector\ActiveEntity::get($entity_type_id, $feature);
\Drupal\config_selector\ActiveEntity::getFromEntity($entity);

chr.fritsch’s picture

Status: Needs review » Needs work

Nice, thats much more intuitive now.

One nitpick:

+++ b/src/ActiveEntity.php
@@ -0,0 +1,75 @@
+   * Active constructor.

ActiveEntity now

alexpott’s picture

Status: Needs work » Needs review
StatusFileSize
new400 bytes
new9.82 KB

Fixed! @chr.fritsch eagle eyes!

chr.fritsch’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the reivew @chr.fritsch

  • alexpott committed 92dfa9f on 8.x-1.x
    Issue #2946544 by alexpott, chr.fritsch: Add a service to get the active...

  • alexpott committed 9d958cd on 8.x-1.x
    Issue #2946544 by alexpott, chr.fritsch: Add a service to get the active...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.