public function MessageTemplate::calculateDependencies in Message 8
Calculates dependencies and stores them in the dependency property.
Return value
$this
Overrides ConfigEntityBase::calculateDependencies
See also
\Drupal\Core\Config\Entity\ConfigDependencyManager
File
- src/
Entity/ MessageTemplate.php, line 351
Class
- MessageTemplate
- Defines the Message template entity class.
Namespace
Drupal\message\EntityCode
public function calculateDependencies() {
parent::calculateDependencies();
$text_format_ids = [];
foreach ($this->text as $item) {
if (!empty($item['format']) && !in_array($item['format'], $text_format_ids, TRUE)) {
$text_format_ids[] = $item['format'];
}
}
// The template depends on the text text format config entities, if any.
if ($text_format_ids) {
$text_format_storage = $this
->entityTypeManager()
->getStorage('filter_format');
foreach ($text_format_storage
->loadMultiple($text_format_ids) as $id => $text_format) {
$this
->addDependency($text_format
->getConfigDependencyKey(), $text_format
->getConfigDependencyName());
}
}
return $this;
}