Same filename in this branch
- 10 core/modules/editor/src/Annotation/Editor.php
- 10 core/modules/editor/src/Entity/Editor.php
- 10 core/modules/editor/src/Attribute/Editor.php
Same filename and directory in other branches
- 8.9.x core/modules/editor/src/Entity/Editor.php
- 9 core/modules/editor/src/Entity/Editor.php
Namespace
Drupal\editor\Entity
File
core/modules/editor/src/Entity/Editor.php
View source
<?php
namespace Drupal\editor\Entity;
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\Core\StreamWrapper\StreamWrapperInterface;
use Drupal\editor\EditorInterface;
class Editor extends ConfigEntityBase implements EditorInterface {
protected $format;
protected $editor;
protected $settings = [];
protected $image_upload = [];
protected $filterFormat;
protected $editorPluginManager;
public function id() {
return $this->format;
}
public function __construct(array $values, $entity_type) {
parent::__construct($values, $entity_type);
try {
$plugin = $this
->editorPluginManager()
->createInstance($this->editor);
$this->settings += $plugin
->getDefaultSettings();
} catch (PluginNotFoundException $e) {
}
}
public function label() {
return $this
->getFilterFormat()
->label();
}
public function calculateDependencies() {
parent::calculateDependencies();
$this
->addDependency('config', $this
->getFilterFormat()
->getConfigDependencyName());
$definition = $this
->editorPluginManager()
->createInstance($this->editor)
->getPluginDefinition();
$this
->addDependency('module', $definition['provider']);
return $this;
}
public function hasAssociatedFilterFormat() {
return $this->format !== NULL;
}
public function getFilterFormat() {
if (!$this->filterFormat) {
$this->filterFormat = \Drupal::entityTypeManager()
->getStorage('filter_format')
->load($this->format);
}
return $this->filterFormat;
}
protected function editorPluginManager() {
if (!$this->editorPluginManager) {
$this->editorPluginManager = \Drupal::service('plugin.manager.editor');
}
return $this->editorPluginManager;
}
public function getEditor() {
return $this->editor;
}
public function setEditor($editor) {
$this->editor = $editor;
return $this;
}
public function getSettings() {
return $this->settings;
}
public function setSettings(array $settings) {
$this->settings = $settings;
return $this;
}
public function getImageUploadSettings() {
return $this->image_upload;
}
public function setImageUploadSettings(array $image_upload_settings) {
$this->image_upload = $image_upload_settings;
return $this;
}
public static function getValidStreamWrappers() : array {
return array_keys(\Drupal::service('stream_wrapper_manager')
->getNames(StreamWrapperInterface::WRITE_VISIBLE));
}
}
Classes
Name |
Description |
Editor |
Defines the configured text editor entity. |