Commit ff0fdc46 authored by alexpott's avatar alexpott
Browse files

Issue #2157871 by tim.plunkett: Add ConfigStorageControllerInterface.

parent d78587ef
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
* after the config_prefix in a config name forms the entity ID. Additional or * after the config_prefix in a config name forms the entity ID. Additional or
* custom suffixes are not possible. * custom suffixes are not possible.
*/ */
class ConfigStorageController extends EntityStorageControllerBase { class ConfigStorageController extends EntityStorageControllerBase implements ConfigStorageControllerInterface {
/** /**
* Name of the entity's UUID property. * Name of the entity's UUID property.
...@@ -180,42 +180,21 @@ public function deleteRevision($revision_id) { ...@@ -180,42 +180,21 @@ public function deleteRevision($revision_id) {
} }
/** /**
* Returns an entity query instance. * {@inheritdoc}
*
* @param string $conjunction
* - AND: all of the conditions on the query need to match.
* - OR: at least one of the conditions on the query need to match.
*
* @return \Drupal\Core\Entity\Query\QueryInterface
* The query instance.
*
* @see \Drupal\Core\Entity\EntityStorageControllerInterface::getQueryServicename()
*/ */
public function getQuery($conjunction = 'AND') { public function getQuery($conjunction = 'AND') {
return $this->entityQueryFactory->get($this->entityType, $conjunction); return $this->entityQueryFactory->get($this->entityType, $conjunction);
} }
/** /**
* Returns the config prefix used by the configuration entity type. * {@inheritdoc}
*
* @return string
* The full configuration prefix, for example 'views.view.'.
*/ */
public function getConfigPrefix() { public function getConfigPrefix() {
return $this->entityInfo->getConfigPrefix() . '.'; return $this->entityInfo->getConfigPrefix() . '.';
} }
/** /**
* Extracts the configuration entity ID from the full configuration name. * {@inheritdoc}
*
* @param string $config_name
* The full configuration name to extract the ID from. E.g.
* 'views.view.archive'.
* @param string $config_prefix
* The config prefix of the configuration entity. E.g. 'views.view'
*
* @return string
* The ID of the configuration entity.
*/ */
public static function getIDFromConfigName($config_name, $config_prefix) { public static function getIDFromConfigName($config_name, $config_prefix) {
return substr($config_name, strlen($config_prefix . '.')); return substr($config_name, strlen($config_prefix . '.'));
...@@ -423,17 +402,7 @@ public function getQueryServicename() { ...@@ -423,17 +402,7 @@ public function getQueryServicename() {
} }
/** /**
* Create configuration upon synchronizing configuration changes. * {@inheritdoc}
*
* This callback is invoked when configuration is synchronized between storages
* and allows a module to take over the synchronization of configuration data.
*
* @param string $name
* The name of the configuration object.
* @param \Drupal\Core\Config\Config $new_config
* A configuration object containing the new configuration data.
* @param \Drupal\Core\Config\Config $old_config
* A configuration object containing the old configuration data.
*/ */
public function importCreate($name, Config $new_config, Config $old_config) { public function importCreate($name, Config $new_config, Config $old_config) {
$entity = $this->create($new_config->get()); $entity = $this->create($new_config->get());
...@@ -443,17 +412,7 @@ public function importCreate($name, Config $new_config, Config $old_config) { ...@@ -443,17 +412,7 @@ public function importCreate($name, Config $new_config, Config $old_config) {
} }
/** /**
* Updates configuration upon synchronizing configuration changes. * {@inheritdoc}
*
* This callback is invoked when configuration is synchronized between storages
* and allows a module to take over the synchronization of configuration data.
*
* @param string $name
* The name of the configuration object.
* @param \Drupal\Core\Config\Config $new_config
* A configuration object containing the new configuration data.
* @param \Drupal\Core\Config\Config $old_config
* A configuration object containing the old configuration data.
*/ */
public function importUpdate($name, Config $new_config, Config $old_config) { public function importUpdate($name, Config $new_config, Config $old_config) {
$id = static::getIDFromConfigName($name, $this->entityInfo->getConfigPrefix()); $id = static::getIDFromConfigName($name, $this->entityInfo->getConfigPrefix());
...@@ -474,17 +433,7 @@ public function importUpdate($name, Config $new_config, Config $old_config) { ...@@ -474,17 +433,7 @@ public function importUpdate($name, Config $new_config, Config $old_config) {
} }
/** /**
* Delete configuration upon synchronizing configuration changes. * {@inheritdoc}
*
* This callback is invoked when configuration is synchronized between storages
* and allows a module to take over the synchronization of configuration data.
*
* @param string $name
* The name of the configuration object.
* @param \Drupal\Core\Config\Config $new_config
* A configuration object containing the new configuration data.
* @param \Drupal\Core\Config\Config $old_config
* A configuration object containing the old configuration data.
*/ */
public function importDelete($name, Config $new_config, Config $old_config) { public function importDelete($name, Config $new_config, Config $old_config) {
$id = static::getIDFromConfigName($name, $this->entityInfo->getConfigPrefix()); $id = static::getIDFromConfigName($name, $this->entityInfo->getConfigPrefix());
......
<?php
/**
* @file
* Contains \Drupal\Core\Config\Entity\ConfigStorageControllerInterface.
*/
namespace Drupal\Core\Config\Entity;
use Drupal\Core\Config\Config;
use Drupal\Core\Entity\EntityStorageControllerInterface;
/**
* Provides an interface for configuration entity storage.
*/
interface ConfigStorageControllerInterface extends EntityStorageControllerInterface {
/**
* Create configuration upon synchronizing configuration changes.
*
* This callback is invoked when configuration is synchronized between storages
* and allows a module to take over the synchronization of configuration data.
*
* @param string $name
* The name of the configuration object.
* @param \Drupal\Core\Config\Config $new_config
* A configuration object containing the new configuration data.
* @param \Drupal\Core\Config\Config $old_config
* A configuration object containing the old configuration data.
*/
public function importCreate($name, Config $new_config, Config $old_config);
/**
* Returns an entity query instance.
*
* @param string $conjunction
* - AND: all of the conditions on the query need to match.
* - OR: at least one of the conditions on the query need to match.
*
* @return \Drupal\Core\Entity\Query\QueryInterface
* The query instance.
*
* @see \Drupal\Core\Entity\EntityStorageControllerInterface::getQueryServicename()
*/
public function getQuery($conjunction = 'AND');
/**
* Updates configuration upon synchronizing configuration changes.
*
* This callback is invoked when configuration is synchronized between storages
* and allows a module to take over the synchronization of configuration data.
*
* @param string $name
* The name of the configuration object.
* @param \Drupal\Core\Config\Config $new_config
* A configuration object containing the new configuration data.
* @param \Drupal\Core\Config\Config $old_config
* A configuration object containing the old configuration data.
*/
public function importUpdate($name, Config $new_config, Config $old_config);
/**
* Delete configuration upon synchronizing configuration changes.
*
* This callback is invoked when configuration is synchronized between storages
* and allows a module to take over the synchronization of configuration data.
*
* @param string $name
* The name of the configuration object.
* @param \Drupal\Core\Config\Config $new_config
* A configuration object containing the new configuration data.
* @param \Drupal\Core\Config\Config $old_config
* A configuration object containing the old configuration data.
*/
public function importDelete($name, Config $new_config, Config $old_config);
/**
* Returns the config prefix used by the configuration entity type.
*
* @return string
* The full configuration prefix, for example 'views.view.'.
*/
public function getConfigPrefix();
/**
* Extracts the configuration entity ID from the full configuration name.
*
* @param string $config_name
* The full configuration name to extract the ID from. E.g.
* 'views.view.archive'.
* @param string $config_prefix
* The config prefix of the configuration entity. E.g. 'views.view'
*
* @return string
* The ID of the configuration entity.
*/
public static function getIDFromConfigName($config_name, $config_prefix);
}
...@@ -29,7 +29,7 @@ class BlockStorageUnitTest extends DrupalUnitTestBase { ...@@ -29,7 +29,7 @@ class BlockStorageUnitTest extends DrupalUnitTestBase {
/** /**
* The block storage controller. * The block storage controller.
* *
* @var \Drupal\Core\Config\Entity\ConfigStorageController. * @var \Drupal\Core\Config\Entity\ConfigStorageControllerInterface.
*/ */
protected $controller; protected $controller;
......
...@@ -31,9 +31,7 @@ public static function getInfo() { ...@@ -31,9 +31,7 @@ public static function getInfo() {
* @see \Drupal\block\BlockFormController::getUniqueMachineName() * @see \Drupal\block\BlockFormController::getUniqueMachineName()
*/ */
public function testGetUniqueMachineName() { public function testGetUniqueMachineName() {
$block_storage = $this->getMockBuilder('Drupal\Core\Config\Entity\ConfigStorageController') $block_storage = $this->getMock('Drupal\Core\Config\Entity\ConfigStorageControllerInterface');
->disableOriginalConstructor()
->getMock();
$blocks = array(); $blocks = array();
$blocks['test'] = $this->getBlockMockWithMachineName('test'); $blocks['test'] = $this->getBlockMockWithMachineName('test');
......
...@@ -25,7 +25,7 @@ class ConfigEntityUnitTest extends DrupalUnitTestBase { ...@@ -25,7 +25,7 @@ class ConfigEntityUnitTest extends DrupalUnitTestBase {
/** /**
* The config_test entity storage controller. * The config_test entity storage controller.
* *
* @var \Drupal\config_test\ConfigTestStorageController * @var \Drupal\Core\Config\Entity\ConfigStorageControllerInterface
*/ */
protected $storage; protected $storage;
......
...@@ -38,7 +38,7 @@ class SearchPageRepositoryTest extends UnitTestCase { ...@@ -38,7 +38,7 @@ class SearchPageRepositoryTest extends UnitTestCase {
/** /**
* The search page storage. * The search page storage.
* *
* @var \Drupal\Core\Config\Entity\ConfigStorageController|\PHPUnit_Framework_MockObject_MockObject * @var \Drupal\Core\Config\Entity\ConfigStorageControllerInterface|\PHPUnit_Framework_MockObject_MockObject
*/ */
protected $storage; protected $storage;
...@@ -66,9 +66,7 @@ public static function getInfo() { ...@@ -66,9 +66,7 @@ public static function getInfo() {
public function setUp() { public function setUp() {
$this->query = $this->getMock('Drupal\Core\Entity\Query\QueryInterface'); $this->query = $this->getMock('Drupal\Core\Entity\Query\QueryInterface');
$this->storage = $this->getMockBuilder('Drupal\Core\Config\Entity\ConfigStorageController') $this->storage = $this->getMock('Drupal\Core\Config\Entity\ConfigStorageControllerInterface');
->disableOriginalConstructor()
->getMock();
$this->storage->expects($this->any()) $this->storage->expects($this->any())
->method('getQuery') ->method('getQuery')
->will($this->returnValue($this->query)); ->will($this->returnValue($this->query));
......
...@@ -7,13 +7,12 @@ ...@@ -7,13 +7,12 @@
namespace Drupal\shortcut; namespace Drupal\shortcut;
use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Core\Config\Entity\ConfigStorageControllerInterface;
use Drupal\shortcut\ShortcutSetInterface;
/** /**
* Defines a common interface for shortcut entity controller classes. * Defines a common interface for shortcut entity controller classes.
*/ */
interface ShortcutSetStorageControllerInterface extends EntityStorageControllerInterface { interface ShortcutSetStorageControllerInterface extends ConfigStorageControllerInterface {
/** /**
* Assigns a user to a particular shortcut set. * Assigns a user to a particular shortcut set.
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
use Drupal\Core\Ajax\AjaxResponse; use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\ReplaceCommand; use Drupal\Core\Ajax\ReplaceCommand;
use Drupal\Core\Config\Entity\ConfigStorageController; use Drupal\Core\Config\Entity\ConfigStorageControllerInterface;
use Drupal\Core\Datetime\Date; use Drupal\Core\Datetime\Date;
use Drupal\Core\Language\Language; use Drupal\Core\Language\Language;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
...@@ -46,7 +46,7 @@ abstract class DateFormatFormBase extends EntityFormController { ...@@ -46,7 +46,7 @@ abstract class DateFormatFormBase extends EntityFormController {
/** /**
* The date format storage controller. * The date format storage controller.
* *
* @var \Drupal\Core\Config\Entity\ConfigStorageController * @var \Drupal\Core\Config\Entity\ConfigStorageControllerInterface
*/ */
protected $dateFormatStorage; protected $dateFormatStorage;
...@@ -57,10 +57,10 @@ abstract class DateFormatFormBase extends EntityFormController { ...@@ -57,10 +57,10 @@ abstract class DateFormatFormBase extends EntityFormController {
* The entity query factory. * The entity query factory.
* @param \Drupal\Core\Datetime\Date $date_service * @param \Drupal\Core\Datetime\Date $date_service
* The date service. * The date service.
* @param \Drupal\Core\Config\Entity\ConfigStorageController $date_format_storage * @param \Drupal\Core\Config\Entity\ConfigStorageControllerInterface $date_format_storage
* The date format storage controller. * The date format storage controller.
*/ */
public function __construct(QueryFactory $query_factory, Date $date_service, ConfigStorageController $date_format_storage) { public function __construct(QueryFactory $query_factory, Date $date_service, ConfigStorageControllerInterface $date_format_storage) {
$date = new DrupalDateTime(); $date = new DrupalDateTime();
$this->patternType = $date->canUseIntl() ? DrupalDateTime::INTL : DrupalDateTime::PHP; $this->patternType = $date->canUseIntl() ? DrupalDateTime::INTL : DrupalDateTime::PHP;
......
...@@ -42,7 +42,7 @@ class PathBasedBreadcrumbBuilder extends BreadcrumbBuilderBase { ...@@ -42,7 +42,7 @@ class PathBasedBreadcrumbBuilder extends BreadcrumbBuilderBase {
/** /**
* The menu storage controller. * The menu storage controller.
* *
* @var \Drupal\Core\Config\Entity\ConfigStorageController * @var \Drupal\Core\Config\Entity\ConfigStorageControllerInterface
*/ */
protected $menuStorage; protected $menuStorage;
......
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
namespace Drupal\taxonomy; namespace Drupal\taxonomy;
use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Core\Config\Entity\ConfigStorageControllerInterface;
/** /**
* Defines a common interface for taxonomy vocabulary entity controller classes. * Defines a common interface for taxonomy vocabulary entity controller classes.
*/ */
interface VocabularyStorageControllerInterface extends EntityStorageControllerInterface { interface VocabularyStorageControllerInterface extends ConfigStorageControllerInterface {
/** /**
* Gets top-level term IDs of vocabularies. * Gets top-level term IDs of vocabularies.
......
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
namespace Drupal\user; namespace Drupal\user;
use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Core\Config\Entity\ConfigStorageControllerInterface;
/** /**
* Defines a common interface for roel entity controller classes. * Defines a common interface for roel entity controller classes.
*/ */
interface RoleStorageControllerInterface extends EntityStorageControllerInterface { interface RoleStorageControllerInterface extends ConfigStorageControllerInterface {
/** /**
* Delete role references. * Delete role references.
......
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