Commit c560898a authored by alexpott's avatar alexpott

Issue #2331019 by slashrsm: Implement ThirdPartySettingsInterface in Vocabulary.

parent f8d961ec
......@@ -33,6 +33,11 @@ taxonomy.vocabulary.*:
weight:
type: integer
label: 'Weight'
third_party_settings:
type: sequence
label: 'Third party settings'
sequence:
- type: taxonomy.vocabulary.third_party.[%key]
field.taxonomy_term_reference.settings:
type: base_entity_reference_field_settings
......
......@@ -8,6 +8,7 @@
namespace Drupal\taxonomy\Entity;
use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
use Drupal\Core\Config\Entity\ThirdPartySettingsTrait;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\taxonomy\VocabularyInterface;
......@@ -44,6 +45,7 @@
* )
*/
class Vocabulary extends ConfigEntityBundleBase implements VocabularyInterface {
use ThirdPartySettingsTrait;
/**
* The taxonomy vocabulary ID.
......
......@@ -21,7 +21,7 @@ class VocabularyCrudTest extends TaxonomyTestBase {
*
* @var array
*/
public static $modules = array('field_test');
public static $modules = array('field_test', 'taxonomy_crud');
protected function setUp() {
parent::setUp();
......@@ -43,8 +43,6 @@ function testTaxonomyVocabularyDeleteWithTerms() {
// Assert that there are no terms left.
$this->assertEqual(0, db_query('SELECT COUNT(*) FROM {taxonomy_term_data}')->fetchField(), 'There are no terms remaining.');
// Create a new vocabulary and add a few terms to it.
$vocabulary = $this->createVocabulary();
$terms = array();
for ($i = 0; $i < 5; $i++) {
$terms[$i] = $this->createTerm($vocabulary);
......@@ -110,6 +108,11 @@ function testTaxonomyVocabularyLoadMultiple() {
$vocabulary3->weight = 2;
$vocabulary3->save();
// Check if third party settings exist.
$this->assertEqual('bar', $vocabulary1->getThirdPartySetting('taxonomy_crud', 'foo'), 'Third party settings were added to the vocabulary.');
$this->assertEqual('bar', $vocabulary2->getThirdPartySetting('taxonomy_crud', 'foo'), 'Third party settings were added to the vocabulary.');
$this->assertEqual('bar', $vocabulary3->getThirdPartySetting('taxonomy_crud', 'foo'), 'Third party settings were added to the vocabulary.');
// Fetch the names for all vocabularies, confirm that they are keyed by
// machine name.
$names = taxonomy_vocabulary_get_names();
......
......@@ -8,10 +8,11 @@
namespace Drupal\taxonomy;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
use Drupal\Core\Config\Entity\ThirdPartySettingsInterface;
/**
* Provides an interface defining a taxonomy vocabulary entity.
*/
interface VocabularyInterface extends ConfigEntityInterface {
interface VocabularyInterface extends ConfigEntityInterface, ThirdPartySettingsInterface {
}
taxonomy.vocabulary.third_party.taxonomy_crud:
type: mapping
label: 'Schema for taxonomy_crud module additions to vocabulary entity'
mapping:
foo:
type: string
label: 'Label for foo'
name: 'Taxonomy CRUD tests'
type: module
description: 'Provides 3rd party settings for vocabulary.'
package: Testing
version: VERSION
core: 8.x
dependencies:
- taxonomy
<?php
/**
* @file
* Provides hook implementations for testing purposes.
*/
/**
* Implements hook_ENTITY_TYPE_presave() for taxonomy_vocabulary entities.
*/
function taxonomy_crud_taxonomy_vocabulary_presave(\Drupal\taxonomy\VocabularyInterface $vocabulary) {
$vocabulary->setThirdPartySetting('taxonomy_crud', 'foo', 'bar');
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment