Standalone.php in Entity Browser 8.2
File
src/Plugin/EntityBrowser/Display/Standalone.php
View source
<?php
namespace Drupal\entity_browser\Plugin\EntityBrowser\Display;
use Drupal\entity_browser\DisplayBase;
use Drupal\entity_browser\DisplayRouterInterface;
use Drupal\Core\Form\FormStateInterface;
class Standalone extends DisplayBase implements DisplayRouterInterface {
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form['path'] = [
'#type' => 'textfield',
'#title' => $this
->t('Path'),
'#required' => TRUE,
'#description' => $this
->t('The path at which the browser will be accessible. Must begin with a forward slash.'),
'#default_value' => $this->configuration['path'],
];
return $form;
}
public function defaultConfiguration() {
return [
'path' => '',
];
}
public function displayEntityBrowser(array $element, FormStateInterface $form_state, array &$complete_form, array $persistent_data = []) {
parent::displayEntityBrowser($element, $form_state, $complete_form, $persistent_data);
}
public function selectionCompleted(array $entities) {
}
public function path() {
return $this->configuration['path'];
}
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
$path = $form_state
->getValue('path');
if ($path[0] != '/') {
$form_state
->setError($form['path'], $this
->t('The Path field must begin with a forward slash.'));
}
}
}
Classes
Name |
Description |
Standalone |
Presents entity browser as a standalone form. |