class LingotekMediaBulkForm in Lingotek Translation 8.2
Same name and namespace in other branches
- 4.0.x src/Form/LingotekMediaBulkForm.php \Drupal\lingotek\Form\LingotekMediaBulkForm
- 3.0.x src/Form/LingotekMediaBulkForm.php \Drupal\lingotek\Form\LingotekMediaBulkForm
- 3.1.x src/Form/LingotekMediaBulkForm.php \Drupal\lingotek\Form\LingotekMediaBulkForm
- 3.2.x src/Form/LingotekMediaBulkForm.php \Drupal\lingotek\Form\LingotekMediaBulkForm
- 3.3.x src/Form/LingotekMediaBulkForm.php \Drupal\lingotek\Form\LingotekMediaBulkForm
- 3.4.x src/Form/LingotekMediaBulkForm.php \Drupal\lingotek\Form\LingotekMediaBulkForm
- 3.5.x src/Form/LingotekMediaBulkForm.php \Drupal\lingotek\Form\LingotekMediaBulkForm
- 3.6.x src/Form/LingotekMediaBulkForm.php \Drupal\lingotek\Form\LingotekMediaBulkForm
- 3.7.x src/Form/LingotekMediaBulkForm.php \Drupal\lingotek\Form\LingotekMediaBulkForm
- 3.8.x src/Form/LingotekMediaBulkForm.php \Drupal\lingotek\Form\LingotekMediaBulkForm
Special treatment for Media in bulk form.
@package Drupal\lingotek\Form
Hierarchy
- class \Drupal\lingotek\Form\LingotekMediaBulkForm uses StringTranslationTrait
Expanded class hierarchy of LingotekMediaBulkForm
1 string reference to 'LingotekMediaBulkForm'
1 service uses LingotekMediaBulkForm
File
- src/
Form/ LingotekMediaBulkForm.php, line 15
Namespace
Drupal\lingotek\FormView source
class LingotekMediaBulkForm {
use StringTranslationTrait;
/**
* Adds the thumbnail for a media item as the first column.
*
* @param array &$form
* The form definition array.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
*/
public function form(array &$form, FormStateInterface $form_state) {
$build_info = $form_state
->getBuildInfo();
if ($form['#form_id'] === 'lingotek_management' && $build_info && isset($build_info['form_id']) && $build_info['form_id'] === 'lingotek_management') {
$formObject = $build_info['callback_object'];
if ($formObject
->getEntityTypeId() === 'media') {
$thumbnailExists = ImageStyle::load('thumbnail');
$mids = array_keys($form['table']['#options']);
/** @var \Drupal\media\MediaInterface[] $medias */
$medias = Media::loadMultiple($mids);
$form['table']['#header'] = [
'thumbnail' => $this
->t('Thumbnail'),
] + $form['table']['#header'];
foreach ($medias as $id => $media) {
$displayOptions = [
'label' => 'hidden',
];
if ($thumbnailExists) {
$displayOptions['settings']['image_style'] = 'thumbnail';
}
$form['table']['#options'][$id]['thumbnail']['data'] = $media
->get('thumbnail')
->view($displayOptions);
}
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LingotekMediaBulkForm:: |
public | function | Adds the thumbnail for a media item as the first column. | |
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. |