class ContentTypeMeeting in Opigno Moxtra 8
Same name and namespace in other branches
- 3.x src/Plugin/OpignoGroupManagerContentType/ContentTypeMeeting.php \Drupal\opigno_moxtra\Plugin\OpignoGroupManagerContentType\ContentTypeMeeting
Class ContentTypeMeeting.
Plugin annotation
@OpignoGroupManagerContentType(
id = "ContentTypeMeeting",
entity_type = "opigno_moxtra_meeting",
readable_name = "Live Meeting",
description = "Contains the Live Meetings",
allowed_group_types = {
"learning_path"
},
group_content_plugin_id = "opigno_moxtra_meeting_group"
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\opigno_group_manager\ContentTypeBase implements ContentTypeInterface
- class \Drupal\opigno_moxtra\Plugin\OpignoGroupManagerContentType\ContentTypeMeeting
- class \Drupal\opigno_group_manager\ContentTypeBase implements ContentTypeInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of ContentTypeMeeting
File
- src/
Plugin/ OpignoGroupManagerContentType/ ContentTypeMeeting.php, line 26
Namespace
Drupal\opigno_moxtra\Plugin\OpignoGroupManagerContentTypeView source
class ContentTypeMeeting extends ContentTypeBase {
/**
* {@inheritdoc}
*/
public function shouldShowNext() {
return FALSE;
}
/**
* {@inheritdoc}
*/
public function getUserScore($user_id, $entity_id) {
/** @var \Drupal\opigno_moxtra\MeetingResultInterface[] $results */
$results = \Drupal::entityTypeManager()
->getStorage('opigno_moxtra_meeting_result')
->loadByProperties([
'user_id' => $user_id,
'meeting' => $entity_id,
]);
$best_score = 0;
foreach ($results as $result) {
$score = $result
->getScore();
if ($score > $best_score) {
$best_score = $score;
}
}
return $best_score / 100;
}
/**
* {@inheritdoc}
*/
public function getViewContentUrl($entity_id) {
return Url::fromRoute('entity.opigno_moxtra_meeting.canonical', [
'opigno_moxtra_meeting' => $entity_id,
]);
}
/**
* {@inheritdoc}
*/
public function getStartContentUrl($content_id, $group_id = NULL) {
return Url::fromRoute('opigno_moxtra.meeting', [
'opigno_moxtra_meeting' => $content_id,
]);
}
/**
* {@inheritdoc}
*
* @param int|\Drupal\opigno_moxtra\Entity\Meeting $meeting
* The entity ID or entity instance.
*/
public function getContent($meeting) {
// If the value is the meeting ID, load the meeting.
if (is_numeric($meeting)) {
/** @var \Drupal\opigno_moxtra\MeetingInterface $meeting */
$meeting = Meeting::load($meeting);
}
if ($meeting === NULL || $meeting === FALSE) {
return FALSE;
}
return new OpignoGroupContent($this
->getPluginId(), $this
->getEntityType(), $meeting
->id(), $meeting
->label(), $this
->getDefaultModuleImageUrl(), t('Default image'));
}
/**
* Returns default image url.
*/
public function getDefaultModuleImageUrl() {
$request = \Drupal::request();
$path = \Drupal::service('module_handler')
->getModule('opigno_module')
->getPath();
return $request
->getBasePath() . '/' . $path . '/img/img_module.svg';
}
/**
* {@inheritdoc}
*/
public function getContentFromRequest(Request $request) {
$meeting = $request
->get('opigno_moxtra_meeting');
if ($meeting === NULL || $meeting === FALSE) {
return FALSE;
}
return $this
->getContent($meeting);
}
/**
* {@inheritdoc}
*/
public function getFormObject($entity_id = NULL) {
if (empty($entity_id)) {
$form = \Drupal::entityTypeManager()
->getFormObject($this
->getEntityType(), 'add');
$entity = Meeting::create();
}
else {
$form = \Drupal::entityTypeManager()
->getFormObject($this
->getEntityType(), 'edit');
$entity = Meeting::load($entity_id);
}
$form
->setEntity($entity);
return $form;
}
/**
* {@inheritdoc}
*/
public function getAllContents() {
try {
/** @var \Drupal\opigno_moxtra\Entity\Meeting[] $meetings */
$meetings = \Drupal::entityTypeManager()
->getStorage('opigno_moxtra_meeting')
->loadMultiple();
} catch (InvalidPluginDefinitionException $e) {
// TODO: Log the error.
return FALSE;
}
$contents = [];
foreach ($meetings as $meeting) {
$contents[] = $this
->getContent($meeting);
}
return $contents;
}
/**
* {@inheritdoc}
*/
public function getAvailableContents() {
return $this
->getAllContents();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ContentTypeBase:: |
public | function | Returns allowed group types. | |
ContentTypeBase:: |
public | function | Returns description. | |
ContentTypeBase:: |
public | function | Returns entity type. | |
ContentTypeBase:: |
public | function | Returns plugin id. | |
ContentTypeBase:: |
public | function | Returns ID. | |
ContentTypeBase:: |
public | function | Returns readable name. | |
ContentTypeBase:: |
public | function | Answer if the current page should show the "finish" button. | |
ContentTypeMeeting:: |
public | function |
Get all the entities in an array of LearningPathContent. Overrides ContentTypeInterface:: |
|
ContentTypeMeeting:: |
public | function |
Get all the published entities in an array of LearningPathContent. Overrides ContentTypeInterface:: |
|
ContentTypeMeeting:: |
public | function |
Overrides ContentTypeInterface:: |
|
ContentTypeMeeting:: |
public | function |
Try to get the content from a Request object. Overrides ContentTypeInterface:: |
|
ContentTypeMeeting:: |
public | function | Returns default image url. | |
ContentTypeMeeting:: |
public | function |
Get the form object based on the entity ID. Overrides ContentTypeInterface:: |
|
ContentTypeMeeting:: |
public | function |
Get the URL object for starting the quiz. Overrides ContentTypeBase:: |
|
ContentTypeMeeting:: |
public | function |
Get the score of the user for a specific entity. Overrides ContentTypeInterface:: |
|
ContentTypeMeeting:: |
public | function |
Get the URL object of the main view page of a specific entity. Overrides ContentTypeInterface:: |
|
ContentTypeMeeting:: |
public | function |
Return TRUE if the page should show the "next" action button. Overrides ContentTypeInterface:: |
|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PluginBase:: |
public | function | Constructs a \Drupal\Component\Plugin\PluginBase object. | 92 |
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. |