Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renames entity_bundle to islandora_entity_bundle to avoid name collision #772

Merged
merged 6 commits into from
Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions islandora.install
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,31 @@ function islandora_update_8001(&$sandbox) {
$action->delete();
}
}

/**
* Replaces 'entity_bundle' conditions with 'islandora_entity_bundle'.
*
* This prevents plugin naming collisions between islandora and ctools.
*/
function islandora_update_8002(&$sandbox) {

// Find contexts that have the old 'entity_bundle' condition.
$results = \Drupal::entityQuery('context')->condition('conditions.entity_bundle.id', 'entity_bundle')->execute();

if (empty($results)) {
return;
}

// Set each context config to use 'islandora_entity_bundle' instead.
foreach ($results as $result) {
$config = \Drupal::configFactory()->getEditable("context.context.$result");
$condition = $config->get('conditions.entity_bundle');
$condition['id'] = 'islandora_entity_bundle';
$config->set('conditions.islandora_entity_bundle', $condition);
$config->clear('conditions.entity_bundle');
$config->save();
}

// Force drupal to reload the config.
\Drupal::service('plugin.manager.condition')->clearCachedDefinitions();
}
4 changes: 3 additions & 1 deletion src/Plugin/Condition/EntityBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
/**
* Provides a 'Entity Bundle' condition.
*
* Namespaced to avoid conflict with ctools entity_bundle plugin.
*
* @Condition(
* id = "entity_bundle",
* id = "islandora_entity_bundle",
* label = @Translation("Entity Bundle"),
* context_definitions = {
* "node" = @ContextDefinition("entity:node", required = FALSE, label = @Translation("Node")),
Expand Down
6 changes: 3 additions & 3 deletions tests/src/Functional/EntityBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public function testEntityBundleType() {
$this->drupalLogin($account);

$this->createContext('Test', 'test');
$this->addCondition('test', 'entity_bundle');
$this->getSession()->getPage()->checkField("edit-conditions-entity-bundle-bundles-test-type");
$this->getSession()->getPage()->findById("edit-conditions-entity-bundle-context-mapping-node")->selectOption("@node.node_route_context:node");
$this->addCondition('test', 'islandora_entity_bundle');
$this->getSession()->getPage()->checkField("edit-conditions-islandora-entity-bundle-bundles-test-type");
$this->getSession()->getPage()->findById("edit-conditions-islandora-entity-bundle-context-mapping-node")->selectOption("@node.node_route_context:node");
$this->getSession()->getPage()->pressButton(t('Save and continue'));
$this->addPresetReaction('test', 'index', 'hello_world');

Expand Down
6 changes: 3 additions & 3 deletions tests/src/Functional/JsonldTypeAlterReactionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ public function testMappingReaction() {
$this->assertSession()
->pageTextContains("The context $context_name has been saved");

$this->addCondition('test', 'entity_bundle');
$this->getSession()->getPage()->checkField("edit-conditions-entity-bundle-bundles-test-type");
$this->getSession()->getPage()->findById("edit-conditions-entity-bundle-context-mapping-node")->selectOption("@node.node_route_context:node");
$this->addCondition('test', 'islandora_entity_bundle');
$this->getSession()->getPage()->checkField("edit-conditions-islandora-entity-bundle-bundles-test-type");
$this->getSession()->getPage()->findById("edit-conditions-islandora-entity-bundle-context-mapping-node")->selectOption("@node.node_route_context:node");
$this->getSession()->getPage()->pressButton(t('Save and continue'));

// The first time a Context is saved, you need to clear the cache.
Expand Down