本文整理汇总了PHP中Drupal\Core\Config\Entity\ConfigEntityBase::calculateDependencies方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigEntityBase::calculateDependencies方法的具体用法?PHP ConfigEntityBase::calculateDependencies怎么用?PHP ConfigEntityBase::calculateDependencies使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Config\Entity\ConfigEntityBase
的用法示例。
在下文中一共展示了ConfigEntityBase::calculateDependencies方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: calculateDependencies
/**
* {@inheritdoc}
*/
public function calculateDependencies()
{
parent::calculateDependencies();
$target_entity_type = \Drupal::entityManager()->getDefinition($this->targetEntityType);
$this->addDependency('module', $target_entity_type->getProvider());
return $this;
}
示例2: testCalculateDependenciesWithThirdPartySettings
/**
* @covers ::calculateDependencies
*/
public function testCalculateDependenciesWithThirdPartySettings()
{
$this->entity = $this->getMockForAbstractClass('\\Drupal\\Tests\\Core\\Config\\Entity\\Fixtures\\ConfigEntityBaseWithThirdPartySettings', array(array(), $this->entityTypeId));
$this->entity->setThirdPartySetting('test_provider', 'test', 'test');
$this->entity->setThirdPartySetting('test_provider2', 'test', 'test');
$this->entity->setThirdPartySetting($this->provider, 'test', 'test');
$this->assertEquals(array('test_provider', 'test_provider2'), $this->entity->calculateDependencies()['module']);
}
示例3: calculateDependencies
/**
* {@inheritdoc}
*/
public function calculateDependencies()
{
parent::calculateDependencies();
// Make sure we save any explicit module dependencies.
if ($provider = $this->get('module')) {
$this->addDependency('module', $provider);
}
return $this->dependencies;
}
示例4: calculateDependencies
/**
* {@inheritdoc}
*/
public function calculateDependencies()
{
parent::calculateDependencies();
if ($this->stateFrom) {
$this->addDependency('config', ModerationState::load($this->stateFrom)->getConfigDependencyName());
}
if ($this->stateTo) {
$this->addDependency('config', ModerationState::load($this->stateTo)->getConfigDependencyName());
}
return $this;
}
示例5: calculateDependencies
/**
* {@inheritdoc}
*/
public function calculateDependencies()
{
parent::calculateDependencies();
if (isset($this->breakpointGroup)) {
// @todo Implement toArray() so we do not have reload the
// entity since this property is changed in
// \Drupal\responsive_image\Entity\ResponsiveImageMapping::save().
$breakpoint_group = \Drupal::entityManager()->getStorage('breakpoint_group')->load($this->breakpointGroup);
$this->addDependency('entity', $breakpoint_group->getConfigDependencyName());
}
return $this->dependencies;
}
示例6: calculateDependencies
/**
* {@inheritdoc}
*/
public function calculateDependencies()
{
parent::calculateDependencies();
$prefix = $this->getModerationStateConfigPrefix() . '.';
if ($this->stateFrom) {
$this->addDependency('config', $prefix . $this->stateFrom);
}
if ($this->stateTo) {
$this->addDependency('config', $prefix . $this->stateTo);
}
return $this;
}
示例7: testCalculateDependenciesWithThirdPartySettings
/**
* @covers ::calculateDependencies
* @covers ::getDependencies
* @covers ::onDependencyRemoval
*/
public function testCalculateDependenciesWithThirdPartySettings()
{
$this->entity = $this->getMockForAbstractClass('\\Drupal\\Core\\Config\\Entity\\ConfigEntityBase', array(array(), $this->entityTypeId));
$this->entity->setThirdPartySetting('test_provider', 'test', 'test');
$this->entity->setThirdPartySetting('test_provider2', 'test', 'test');
$this->entity->setThirdPartySetting($this->provider, 'test', 'test');
$this->assertEquals(array('test_provider', 'test_provider2'), $this->entity->calculateDependencies()->getDependencies()['module']);
$changed = $this->entity->onDependencyRemoval(['module' => ['test_provider2']]);
$this->assertTrue($changed, 'Calling onDependencyRemoval with an existing third party dependency provider returns TRUE.');
$changed = $this->entity->onDependencyRemoval(['module' => ['test_provider3']]);
$this->assertFalse($changed, 'Calling onDependencyRemoval with a non-existing third party dependency provider returns FALSE.');
$this->assertEquals(array('test_provider'), $this->entity->calculateDependencies()->getDependencies()['module']);
}
示例8: testCalculateDependenciesWithPluginBags
/**
* @covers ::calculateDependencies
*
* @dataProvider providerCalculateDependenciesWithPluginBags
*/
public function testCalculateDependenciesWithPluginBags($definition, $expected_dependencies)
{
$values = array();
$this->entity = $this->getMockBuilder('\\Drupal\\Tests\\Core\\Config\\Entity\\Fixtures\\ConfigEntityBaseWithPluginBags')->setConstructorArgs(array($values, $this->entityTypeId))->setMethods(array('getPluginBags'))->getMock();
// Create a configurable plugin that would add a dependency.
$instance_id = $this->randomName();
$instance = new TestConfigurablePlugin(array(), $instance_id, $definition);
// Create a plugin bag to contain the instance.
$pluginBag = $this->getMockBuilder('\\Drupal\\Core\\Plugin\\DefaultPluginBag')->disableOriginalConstructor()->setMethods(array('get'))->getMock();
$pluginBag->expects($this->atLeastOnce())->method('get')->with($instance_id)->will($this->returnValue($instance));
$pluginBag->addInstanceId($instance_id);
// Return the mocked plugin bag.
$this->entity->expects($this->once())->method('getPluginBags')->will($this->returnValue(array($pluginBag)));
$this->assertEquals($expected_dependencies, $this->entity->calculateDependencies());
}
示例9: calculateDependencies
/**
* {@inheritdoc}
*/
public function calculateDependencies()
{
parent::calculateDependencies();
$this->addDependency('config', $this->getPage()->getConfigDependencyName());
foreach ($this->getSelectionConditions() as $instance) {
$this->calculatePluginDependencies($instance);
}
return $this->getDependencies();
}
示例10: calculateDependencies
/**
* {@inheritdoc}
*/
public function calculateDependencies()
{
parent::calculateDependencies();
foreach ($this->test_dependencies as $type => $deps) {
foreach ($deps as $dep) {
$this->addDependency($type, $dep);
}
}
}
示例11: calculateDependencies
/**
* {@inheritdoc}
*/
public function calculateDependencies()
{
parent::calculateDependencies();
// Create a dependency on the associated FilterFormat.
$this->addDependency('config', $this->getFilterFormat()->getConfigDependencyName());
// @todo use EntityWithPluginCollectionInterface so configuration between
// config entity and dependency on provider is managed automatically.
$definition = $this->editorPluginManager()->createInstance($this->editor)->getPluginDefinition();
$this->addDependency('module', $definition['provider']);
return $this->dependencies;
}
示例12: calculateDependencies
/**
* {@inheritdoc}
*/
public function calculateDependencies()
{
parent::calculateDependencies();
// Create dependency on the bundle.
$entity_type = \Drupal::entityManager()->getDefinition($this->target_entity_type_id);
$bundle_config_dependency = $entity_type->getBundleConfigDependency($this->target_bundle);
$this->addDependency($bundle_config_dependency['type'], $bundle_config_dependency['name']);
return $this;
}
示例13: getDependencyData
/**
* Retrieves data about this index's dependencies.
*
* The return value is structured as follows:
*
* @code
* array(
* 'config' => array(
* 'CONFIG_DEPENDENCY_KEY' => array(
* 'always' => array(
* 'processors' => array(
* 'PROCESSOR_ID' => $processor,
* ),
* 'datasources' => array(
* 'DATASOURCE_ID_1' => $datasource_1,
* 'DATASOURCE_ID_2' => $datasource_2,
* ),
* ),
* 'optional' => array(
* 'index' => array(
* 'INDEX_ID' => $index,
* ),
* 'tracker' => array(
* 'TRACKER_ID' => $tracker,
* ),
* ),
* ),
* )
* )
* @endcode
*
* @return object[][][][][]
* An associative array containing the index's dependencies. The array is
* first keyed by the config dependency type ("module", "config", etc.) and
* then by the names of the config dependencies of that type which the index
* has. The values are associative arrays with up to two keys, "always" and
* "optional", specifying whether the dependency is a hard one by the plugin
* (or index) in question or potentially depending on the configuration. The
* values on this level are arrays with keys "index", "tracker",
* "datasources" and/or "processors" and values arrays of IDs mapped to
* their entities/plugins.
*/
protected function getDependencyData()
{
$dependency_data = array();
// Since calculateDependencies() will work directly on the $dependencies
// property, we first save its original state and then restore it
// afterwards.
$original_dependencies = $this->dependencies;
parent::calculateDependencies();
foreach ($this->dependencies as $dependency_type => $list) {
foreach ($list as $name) {
$dependency_data[$dependency_type][$name]['always']['index'][$this->id] = $this;
}
}
$this->dependencies = $original_dependencies;
// The server needs special treatment, since it is a dependency of the index
// itself, and not one of its plugins.
if ($this->hasValidServer()) {
$name = $this->getServerInstance()->getConfigDependencyName();
$dependency_data['config'][$name]['optional']['index'][$this->id] = $this;
}
// All other plugins can be treated uniformly.
$plugins = $this->getAllPlugins();
foreach ($plugins as $plugin_type => $type_plugins) {
foreach ($type_plugins as $plugin_id => $plugin) {
// Largely copied from
// \Drupal\Core\Plugin\PluginDependencyTrait::calculatePluginDependencies().
$definition = $plugin->getPluginDefinition();
// First, always depend on the module providing the plugin.
$dependency_data['module'][$definition['provider']]['always'][$plugin_type][$plugin_id] = $plugin;
// Plugins can declare additional dependencies in their definition.
if (isset($definition['config_dependencies'])) {
foreach ($definition['config_dependencies'] as $dependency_type => $list) {
foreach ($list as $name) {
$dependency_data[$dependency_type][$name]['always'][$plugin_type][$plugin_id] = $plugin;
}
}
}
// Finally, add the dynamically-calculated dependencies of the plugin.
foreach ($plugin->calculateDependencies() as $dependency_type => $list) {
foreach ($list as $name) {
$dependency_data[$dependency_type][$name]['optional'][$plugin_type][$plugin_id] = $plugin;
}
}
}
}
return $dependency_data;
}
示例14: calculateDependencies
/**
* {@inheritdoc}
*/
public function calculateDependencies()
{
parent::calculateDependencies();
// Ensure that the Rules component is dependant on the module that
// implements the component.
$this->addDependency('module', $this->module);
// @todo Handle dependencies of plugins that are provided by various modules
// here.
return $this->dependencies;
}
示例15: calculateDependencies
/**
* {@inheritdoc}
*/
public function calculateDependencies()
{
parent::calculateDependencies();
// Ensure that the view is dependant on the module that implements the view.
$this->addDependency('module', $this->module);
// Ensure that the view is dependent on the module that provides the schema
// for the base table.
$schema = $this->drupalGetSchema($this->base_table);
// @todo Entity base tables are no longer registered in hook_schema(). Once
// we automate the views data for entity types add the entity type
// type provider as a dependency. See https://drupal.org/node/1740492.
if ($schema && $this->module != $schema['module']) {
$this->addDependency('module', $schema['module']);
}
$handler_types = array();
foreach (Views::getHandlerTypes() as $type) {
$handler_types[] = $type['plural'];
}
foreach ($this->get('display') as $display) {
// Collect all dependencies of all handlers.
foreach ($handler_types as $handler_type) {
if (!empty($display['display_options'][$handler_type])) {
foreach ($display['display_options'][$handler_type] as $handler) {
// Add the provider as dependency.
if (isset($handler['provider'])) {
$this->addDependency('module', $handler['provider']);
}
// Add the additional dependencies from the handler configuration.
if (!empty($handler['dependencies'])) {
$this->addDependencies($handler['dependencies']);
}
}
}
}
// Collect all dependencies of plugins.
foreach (Views::getPluginTypes('plugin') as $plugin_type) {
if (!empty($display['display_options'][$plugin_type]['options']['dependencies'])) {
$this->addDependencies($display['display_options'][$plugin_type]['options']['dependencies']);
}
}
}
return $this->dependencies;
}