/** * {@inheritdoc} */ public function calculateDependencies() { parent::calculateDependencies(); $target_entity_type = \Drupal::entityManager()->getDefinition($this->targetEntityType); $this->addDependency('module', $target_entity_type->getProvider()); return $this; }
/** * @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']); }
/** * {@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; }
/** * {@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; }
/** * {@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; }
/** * {@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; }
/** * @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']); }
/** * @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()); }
/** * {@inheritdoc} */ public function calculateDependencies() { parent::calculateDependencies(); $this->addDependency('config', $this->getPage()->getConfigDependencyName()); foreach ($this->getSelectionConditions() as $instance) { $this->calculatePluginDependencies($instance); } return $this->getDependencies(); }
/** * {@inheritdoc} */ public function calculateDependencies() { parent::calculateDependencies(); foreach ($this->test_dependencies as $type => $deps) { foreach ($deps as $dep) { $this->addDependency($type, $dep); } } }
/** * {@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; }
/** * {@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; }
/** * 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; }
/** * {@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; }
/** * {@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; }
/** * {@inheritdoc} */ public function calculateDependencies() { parent::calculateDependencies(); $this->addDependency('theme', $this->theme); return $this->dependencies; }
/** * {@inheritdoc} */ public function calculateDependencies() { parent::calculateDependencies(); // Ensure the field is dependent on the providing module. $this->addDependency('module', $this->getTypeProvider()); // Ask the field type for any additional storage dependencies. // @see \Drupal\Core\Field\FieldItemInterface::calculateStorageDependencies() $definition = \Drupal::service('plugin.manager.field.field_type')->getDefinition($this->getType(), FALSE); $this->addDependencies($definition['class']::calculateStorageDependencies($this)); // Ensure the field is dependent on the provider of the entity type. $entity_type = \Drupal::entityManager()->getDefinition($this->entity_type); $this->addDependency('module', $entity_type->getProvider()); return $this; }
/** * {@inheritdoc} */ public function calculateDependencies() { parent::calculateDependencies(); // Ensure the field is dependent on the providing module. $this->addDependency('module', $this->getTypeProvider()); // Ensure the field is dependent on the provider of the entity type. $entity_type = \Drupal::entityManager()->getDefinition($this->entity_type); $this->addDependency('module', $entity_type->getProvider()); return $this->dependencies; }
/** * {@inheritdoc} */ public function calculateDependencies() { parent::calculateDependencies(); $providers = \Drupal::service('breakpoint.manager')->getGroupProviders($this->breakpoint_group); foreach ($providers as $provider => $type) { $this->addDependency($type, $provider); } // Extract all the styles from the image style mappings. $styles = ImageStyle::loadMultiple($this->getImageStyleIds()); array_walk($styles, function ($style) { $this->addDependency('config', $style->getConfigDependencyName()); }); return $this; }
/** * {@inheritdoc} */ public function calculateDependencies() { parent::calculateDependencies(); $entity_type = \Drupal::entityManager()->getDefinition($this->targetEntityType); $this->addDependency('module', $entity_type->getProvider()); $bundle_entity_type_id = $entity_type->getBundleEntityType(); if ($bundle_entity_type_id != 'bundle') { // If the target entity type uses entities to manage its bundles then // depend on the bundle entity. $bundle_entity = \Drupal::entityManager()->getStorage($bundle_entity_type_id)->load($this->bundle); $this->addDependency('config', $bundle_entity->getConfigDependencyName()); } return $this->dependencies; }
/** * {@inheritdoc} */ public function calculateDependencies() { parent::calculateDependencies(); $this->calculatePluginDependencies($this->getSourcePlugin()); $this->calculatePluginDependencies($this->getDestinationPlugin()); // Add dependencies on required migration dependencies. foreach ($this->getMigrationDependencies()['required'] as $dependency) { $this->addDependency('config', $this->getEntityType()->getConfigPrefix() . '.' . $dependency); } return $this->dependencies; }
/** * {@inheritdoc} */ public function calculateDependencies() { parent::calculateDependencies(); $this->dependencies = array(); if ($this->sourceType == Breakpoint::SOURCE_TYPE_MODULE) { $this->addDependency('module', $this->source); } elseif ($this->sourceType == Breakpoint::SOURCE_TYPE_THEME) { $this->addDependency('theme', $this->source); } $breakpoints = $this->getBreakpoints(); foreach ($breakpoints as $breakpoint) { $this->addDependency('entity', $breakpoint->getConfigDependencyName()); } return $this->dependencies; }
/** * {@inheritdoc} */ public function calculateDependencies() { parent::calculateDependencies(); // Add dependencies from the field type plugin. We can not use // self::calculatePluginDependencies() because instantiation of a field item // plugin requires a parent entity. /** @var $field_type_manager \Drupal\Core\Field\FieldTypePluginManagerInterface */ $field_type_manager = \Drupal::service('plugin.manager.field.field_type'); $definition = $field_type_manager->getDefinition($this->getType()); $this->addDependency('module', $definition['provider']); // Plugins can declare additional dependencies in their definition. if (isset($definition['config_dependencies'])) { $this->addDependencies($definition['config_dependencies']); } // Let the field type plugin specify its own dependencies. // @see \Drupal\Core\Field\FieldItemInterface::calculateDependencies() $this->addDependencies($definition['class']::calculateDependencies($this)); // Create dependency on the bundle. $bundle_config_dependency = $this->entityManager()->getDefinition($this->entity_type)->getBundleConfigDependency($this->bundle); $this->addDependency($bundle_config_dependency['type'], $bundle_config_dependency['name']); return $this; }
/** * {@inheritdoc} */ public function calculateDependencies() { parent::calculateDependencies(); $this->calculatePluginDependencies($this->getSourcePlugin()); $this->calculatePluginDependencies($this->getDestinationPlugin()); // Add hard dependencies on required migrations. $dependencies = $this->getEntityManager()->getStorage($this->entityTypeId)->getVariantIds($this->getMigrationDependencies()['required']); foreach ($dependencies as $dependency) { $this->addDependency('config', $this->getEntityType()->getConfigPrefix() . '.' . $dependency); } return $this; }
/** * {@inheritdoc} */ public function calculateDependencies() { parent::calculateDependencies(); if ($this->getPlugin()) { $this->addDependency('module', $this->getPlugin()->getPluginDefinition()['provider']); } return $this; }
/** * {@inheritdoc} */ public function calculateDependencies() { parent::calculateDependencies(); $target_entity_type = $this->entityManager()->getDefinition($this->targetEntityType); $bundle_entity_type_id = $target_entity_type->getBundleEntityType(); if ($bundle_entity_type_id != 'bundle') { // If the target entity type uses entities to manage its bundles then // depend on the bundle entity. if (!($bundle_entity = $this->entityManager()->getStorage($bundle_entity_type_id)->load($this->bundle))) { throw new \LogicException(SafeMarkup::format('Missing bundle entity, entity type %type, entity id %bundle.', array('%type' => $bundle_entity_type_id, '%bundle' => $this->bundle))); } $this->addDependency('config', $bundle_entity->getConfigDependencyName()); } else { // Depend on the provider of the entity type. $this->addDependency('module', $target_entity_type->getProvider()); } // If field.module is enabled, add dependencies on 'field_config' entities // for both displayed and hidden fields. We intentionally leave out base // field overrides, since the field still exists without them. if (\Drupal::moduleHandler()->moduleExists('field')) { $components = $this->content + $this->hidden; $field_definitions = $this->entityManager()->getFieldDefinitions($this->targetEntityType, $this->bundle); foreach (array_intersect_key($field_definitions, $components) as $field_name => $field_definition) { if ($field_definition instanceof ConfigEntityInterface && $field_definition->getEntityTypeId() == 'field_config') { $this->addDependency('config', $field_definition->getConfigDependencyName()); } } } // Depend on configured modes. if ($this->mode != 'default') { $mode_entity = $this->entityManager()->getStorage('entity_' . $this->displayContext . '_mode')->load($target_entity_type->id() . '.' . $this->mode); $this->addDependency('config', $mode_entity->getConfigDependencyName()); } return $this->dependencies; }
/** * {@inheritdoc} */ public function calculateDependencies() { parent::calculateDependencies(); foreach ($this->tipsCollection as $instance) { $definition = $instance->getPluginDefinition(); $this->addDependency('module', $definition['provider']); } $this->addDependency('module', $this->module); return $this; }
/** * {@inheritdoc} */ public function calculateDependencies() { parent::calculateDependencies(); $bundle_entity_type_id = $this->entityManager()->getDefinition($this->target_entity_type_id)->getBundleEntityType(); if ($bundle_entity_type_id != 'bundle') { // If the target entity type uses entities to manage its bundles then // depend on the bundle entity. if (!($bundle_entity = $this->entityManager()->getStorage($bundle_entity_type_id)->load($this->target_bundle))) { throw new \LogicException(String::format('Missing bundle entity, entity type %type, entity id %bundle.', array('%type' => $bundle_entity_type_id, '%bundle' => $this->target_bundle))); } $this->addDependency('config', $bundle_entity->getConfigDependencyName()); } return $this->dependencies; }
/** * Overrides ConfigEntityBase::calculateDependencies(). */ public function calculateDependencies() { parent::calculateDependencies(); // Always add a dependency on the user module. $this->addDependency('module', 'user'); // Add a dependency on an user role in case this protection rule protects // an user role. $protected_entity = $this->getProtectedEntity(); if ($protected_entity instanceof ConfigEntityInterface) { $this->addDependency('config', $protected_entity->getConfigDependencyName()); } return $this->dependencies; }
/** * {@inheritdoc} */ public function calculateDependencies() { parent::calculateDependencies(); $this->calculatePluginDependencies($this->getAliasType()); foreach ($this->getSelectionConditions() as $instance) { $this->calculatePluginDependencies($instance); } return $this->getDependencies(); }