本文整理汇总了PHP中Drupal\Core\Config\Entity\ConfigEntityBase类的典型用法代码示例。如果您正苦于以下问题:PHP ConfigEntityBase类的具体用法?PHP ConfigEntityBase怎么用?PHP ConfigEntityBase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConfigEntityBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postDelete
/**
* {@inheritdoc}
*/
public static function postDelete(EntityStorageInterface $storage, array $entities)
{
parent::postDelete($storage, $entities);
foreach ($entities as $entity) {
entity_invoke_bundle_hook('delete', $entity->getEntityType()->getBundleOf(), $entity->id());
}
}
示例2: postDelete
/**
* {@inheritdoc}
*/
public static function postDelete(EntityStorageInterface $storage, array $entities)
{
parent::postDelete($storage, $entities);
foreach ($entities as $entity) {
$entity->deleteDisplays();
\Drupal::entityManager()->onBundleDelete($entity->id(), $entity->getEntityType()->getBundleOf());
}
}
示例3: preSave
/**
* {@inheritdoc}
*/
public function preSave(EntityStorageInterface $storage)
{
parent::preSave($storage);
$errors = $this->validate();
if (!empty($errors)) {
throw new EncryptException(implode(';', $errors));
}
}
示例4: 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;
}
示例5: 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;
}
示例6: preSave
/**
* Acts on an entity before the presave hook is invoked.
*
* Used before the entity is saved and before invoking the presave hook.
*
* Ensure that config entities which are bundles of other entities cannot have
* their ID changed.
*
* @param \Drupal\Core\Entity\EntityStorageInterface $storage
* The entity storage object.
*
* @throws \Drupal\Core\Config\ConfigNameException
* Thrown when attempting to rename a bundle entity.
*/
public function preSave(EntityStorageInterface $storage)
{
parent::preSave($storage);
// Only handle renames, not creations.
if (!$this->isNew() && $this->getOriginalId() !== $this->id()) {
$bundle_type = $this->getEntityType();
$bundle_of = $bundle_type->getBundleOf();
if (!empty($bundle_of)) {
throw new ConfigNameException("The machine name of the '{$bundle_type->getLabel()}' bundle cannot be changed.");
}
}
}
示例7: 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;
}
示例8: preDelete
/**
* {@inheritdoc}
*/
public static function preDelete(EntityStorageInterface $storage, array $entities)
{
parent::preDelete($storage, $entities);
foreach ($entities as $entity) {
$storage->deleteAssignedShortcutSets($entity);
// Next, delete the shortcuts for this set.
$shortcut_ids = \Drupal::entityQuery('shortcut')->condition('shortcut_set', $entity->id(), '=')->execute();
$controller = \Drupal::entityManager()->getStorage('shortcut');
$entities = $controller->loadMultiple($shortcut_ids);
$controller->delete($entities);
}
}
示例9: testThirdPartySettings
/**
* @covers ::getThirdPartySetting
* @covers ::setThirdPartySetting
* @covers ::getThirdPartySettings
* @covers ::unsetThirdPartySetting
* @covers ::getThirdPartyProviders
*/
public function testThirdPartySettings()
{
$key = 'test';
$third_party = 'test_provider';
$value = $this->getRandomGenerator()->string();
// Test getThirdPartySetting() with no settings.
$this->assertEquals($value, $this->entity->getThirdPartySetting($third_party, $key, $value));
$this->assertNull($this->entity->getThirdPartySetting($third_party, $key));
// Test setThirdPartySetting().
$this->entity->setThirdPartySetting($third_party, $key, $value);
$this->assertEquals($value, $this->entity->getThirdPartySetting($third_party, $key));
$this->assertEquals($value, $this->entity->getThirdPartySetting($third_party, $key, $this->randomGenerator->string()));
// Test getThirdPartySettings().
$this->entity->setThirdPartySetting($third_party, 'test2', 'value2');
$this->assertEquals(array($key => $value, 'test2' => 'value2'), $this->entity->getThirdPartySettings($third_party));
// Test getThirdPartyProviders().
$this->entity->setThirdPartySetting('test_provider2', $key, $value);
$this->assertEquals(array($third_party, 'test_provider2'), $this->entity->getThirdPartyProviders());
// Test unsetThirdPartyProviders().
$this->entity->unsetThirdPartySetting('test_provider2', $key);
$this->assertEquals(array($third_party), $this->entity->getThirdPartyProviders());
}
示例10: postCreate
/**
* {@inheritdoc}
*/
public function postCreate(EntityStorageInterface $storage)
{
parent::postCreate($storage);
// If it was not present in the $values passed to create(), (e.g. for
// programmatic creation), populate the denormalized field_type property
// from the field storage, so that it gets saved in the config record.
if (empty($this->field_type)) {
$this->field_type = $this->getFieldStorageDefinition()->getType();
}
}
示例11: loadMultiple
/**
* Get all states in the system, with options to filter, only where a workflow exists.
*
* @_deprecated WorkflowState::getStates() ==> WorkflowState::loadMultiple()
*
* {@inheritdoc}
*
* @param $wid
* The requested Workflow ID.
* @param bool $reset
* An option to refresh all caches.
*
* @return WorkflowState[] $states
* An array of cached states.
*/
public static function loadMultiple(array $ids = NULL, $wid = '', $reset = FALSE)
{
if ($reset) {
self::$states = array();
}
if (empty(self::$states)) {
self::$states = parent::loadMultiple();
usort(self::$states, ['Drupal\\workflow\\Entity\\WorkflowState', 'sort']);
}
if (!$wid) {
// All states are requested and cached: return them.
$result = self::$states;
} else {
// All states of only 1 Workflow is requested: return this one.
// E.g., when called by Workflow->getStates().
$result = array();
foreach (self::$states as $state) {
/* @var $state WorkflowState */
if ($state->wid == $wid) {
$result[$state->id()] = $state;
}
}
}
return $result;
}
示例12: preDelete
/**
* {@inheritdoc}
*/
public static function preDelete(EntityStorageInterface $storage, array $entities)
{
parent::preDelete($storage, $entities);
\Drupal::entityManager()->clearCachedFieldDefinitions();
}
示例13: postDelete
/**
* {@inheritdoc}
*/
public static function postDelete(EntityStorageInterface $storage, array $entities)
{
parent::postDelete($storage, $entities);
static::routeBuilder()->setRebuildNeeded();
}
示例14: calculateDependencies
/**
* {@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;
}
示例15: getCacheTags
/**
* {@inheritdoc}
*/
public function getCacheTags() {
$tags = parent::getCacheTags();
return Cache::mergeTags($tags, ['block_visibility_group:' . $this->id]);
}