class FieldBlockController in Field as Block 8.2
Class FieldBlockController.
@package Drupal\fieldblock\Controller
Hierarchy
- class \Drupal\Core\Controller\ControllerBase implements ContainerInjectionInterface uses LoggerChannelTrait, MessengerTrait, LinkGeneratorTrait, RedirectDestinationTrait, UrlGeneratorTrait, StringTranslationTrait
- class \Drupal\fieldblock\Controller\FieldBlockController
Expanded class hierarchy of FieldBlockController
2 files declare their use of FieldBlockController
- FieldBlockConfigForm.php in src/
Form/ FieldBlockConfigForm.php - FieldBlockDeriver.php in src/
Plugin/ Derivative/ FieldBlockDeriver.php
File
- src/
Controller/ FieldBlockController.php, line 14
Namespace
Drupal\fieldblock\ControllerView source
class FieldBlockController extends ControllerBase {
/**
* Get currently enabled types either from config or module defaults.
*
* @return array
* Entity type ids.
*/
public function getEnabledEntityTypes() {
$entity_types = $this
->config('fieldblock.settings')
->get('enabled_entity_types');
if (!$entity_types) {
return $this
->getDefaultEntityTypes();
}
return array_filter($entity_types);
}
/**
* Determine if Entity Type should have field block created.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $type
* Entity type name.
*
* @return bool
* True if field block should be created.
*/
public function isBlockableEntityType(EntityTypeInterface $type) {
static $entity_types;
if (!$entity_types) {
$entity_types = $this
->getEnabledEntityTypes();
}
return in_array($type
->id(), $entity_types);
}
/**
* Return default entity types to use as blocks.
*
* @return array
* Entity type ids.
*/
protected function getDefaultEntityTypes() {
$default_types = [
'node',
'user',
'taxonomy_term',
];
// @todo Should there by an alter hook to allow other modules to make their entities default?
$all_types = array_keys($this
->entityTypeManager()
->getDefinitions());
// Return all default types that actually exist. "taxonomy_term" at least
// could be disabled.
return array_intersect($default_types, $all_types);
}
/**
* Determine if a Entity is compatible with Field Blocks.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type name.
*
* @return bool
* True if compatible.
*/
public function isFieldBlockCompatible(EntityTypeInterface $entity_type) {
return $entity_type instanceof ContentEntityTypeInterface;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ControllerBase:: |
protected | property | The configuration factory. | |
ControllerBase:: |
protected | property | The current user service. | 1 |
ControllerBase:: |
protected | property | The entity form builder. | |
ControllerBase:: |
protected | property | The entity manager. | |
ControllerBase:: |
protected | property | The entity type manager. | |
ControllerBase:: |
protected | property | The form builder. | 2 |
ControllerBase:: |
protected | property | The key-value storage. | 1 |
ControllerBase:: |
protected | property | The language manager. | 1 |
ControllerBase:: |
protected | property | The module handler. | 2 |
ControllerBase:: |
protected | property | The state service. | |
ControllerBase:: |
protected | function | Returns the requested cache bin. | |
ControllerBase:: |
protected | function | Retrieves a configuration object. | |
ControllerBase:: |
private | function | Returns the service container. | |
ControllerBase:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
40 |
ControllerBase:: |
protected | function | Returns the current user. | 1 |
ControllerBase:: |
protected | function | Retrieves the entity form builder. | |
ControllerBase:: |
protected | function | Retrieves the entity manager service. | |
ControllerBase:: |
protected | function | Retrieves the entity type manager. | |
ControllerBase:: |
protected | function | Returns the form builder service. | 2 |
ControllerBase:: |
protected | function | Returns a key/value storage collection. | 1 |
ControllerBase:: |
protected | function | Returns the language manager service. | 1 |
ControllerBase:: |
protected | function | Returns the module handler. | 2 |
ControllerBase:: |
protected | function |
Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait:: |
|
ControllerBase:: |
protected | function | Returns the state storage service. | |
FieldBlockController:: |
protected | function | Return default entity types to use as blocks. | |
FieldBlockController:: |
public | function | Get currently enabled types either from config or module defaults. | |
FieldBlockController:: |
public | function | Determine if Entity Type should have field block created. | |
FieldBlockController:: |
public | function | Determine if a Entity is compatible with Field Blocks. | |
LinkGeneratorTrait:: |
protected | property | The link generator. | 1 |
LinkGeneratorTrait:: |
protected | function | Returns the link generator. | |
LinkGeneratorTrait:: |
protected | function | Renders a link to a route given a route name and its parameters. | |
LinkGeneratorTrait:: |
public | function | Sets the link generator service. | |
LoggerChannelTrait:: |
protected | property | The logger channel factory service. | |
LoggerChannelTrait:: |
protected | function | Gets the logger for a specific channel. | |
LoggerChannelTrait:: |
public | function | Injects the logger channel factory. | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
RedirectDestinationTrait:: |
protected | property | The redirect destination service. | 1 |
RedirectDestinationTrait:: |
protected | function | Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url. | |
RedirectDestinationTrait:: |
protected | function | Returns the redirect destination service. | |
RedirectDestinationTrait:: |
public | function | Sets the redirect destination service. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
UrlGeneratorTrait:: |
protected | property | The url generator. | |
UrlGeneratorTrait:: |
protected | function | Returns the URL generator service. | |
UrlGeneratorTrait:: |
public | function | Sets the URL generator service. | |
UrlGeneratorTrait:: |
protected | function | Generates a URL or path for a specific route based on the given parameters. |