class CalendarEventEmbeddedDisplay in Opigno calendar event 8
Same name and namespace in other branches
- 3.x src/CalendarEventEmbeddedDisplay.php \Drupal\opigno_calendar_event\CalendarEventEmbeddedDisplay
Provides a display to attach a calendar event to an entity.
Hierarchy
- class \Drupal\opigno_calendar_event\CalendarEventEmbeddedDisplay uses StringTranslationTrait
Expanded class hierarchy of CalendarEventEmbeddedDisplay
1 file declares its use of CalendarEventEmbeddedDisplay
- opigno_calendar_event.module in ./
opigno_calendar_event.module - Main file for the "Calendar event" module.
File
- src/
CalendarEventEmbeddedDisplay.php, line 12
Namespace
Drupal\opigno_calendar_eventView source
class CalendarEventEmbeddedDisplay {
use StringTranslationTrait;
/**
* The widget element name.
*
* @var string
*/
const ELEMENT_NAME = 'opigno_calendar_event_embedded_display';
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* CalendarEventManager constructor.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
}
/**
* Builds en embedded calendar event display.
*
* @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
* Field definition.
* @param \Drupal\opigno_calendar_event\CalendarEventInterface[] $calendar_events
* Calendar events.
*
* @return array
* Calendar events build.
*/
public function build(FieldDefinitionInterface $field_definition, array $calendar_events) {
$build = [];
$element =& $build[static::ELEMENT_NAME];
$element = $this->entityTypeManager
->getViewBuilder(CalendarEventInterface::ENTITY_TYPE_ID)
->viewMultiple($calendar_events, 'embedded_display');
$element['#field_name'] = $field_definition
->getName();
$element['#bundle'] = $field_definition
->getTargetBundle();
return $build;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CalendarEventEmbeddedDisplay:: |
protected | property | The entity type manager. | |
CalendarEventEmbeddedDisplay:: |
public | function | Builds en embedded calendar event display. | |
CalendarEventEmbeddedDisplay:: |
constant | The widget element name. | ||
CalendarEventEmbeddedDisplay:: |
public | function | CalendarEventManager constructor. | |
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. |