protected function BlazyAdminBase::getState in Blazy 8.2
Same name and namespace in other branches
- 8 src/Form/BlazyAdminBase.php \Drupal\blazy\Form\BlazyAdminBase::getState()
- 7 src/Form/BlazyAdminBase.php \Drupal\blazy\Form\BlazyAdminBase::getState()
Get one of the pre-defined states used in this form.
Thanks to SAM152 at colorbox.module for the little sweet idea.
Parameters
string $state: The state to get that matches one of the state class constants.
array $definition: The foem definitions or settings.
Return value
array A corresponding form API state.
2 calls to BlazyAdminBase::getState()
- BlazyAdminBase::baseForm in src/
Form/ BlazyAdminBase.php - Returns simple form elements common for Views field, EB widget, formatters.
- BlazyAdminBase::mediaSwitchForm in src/
Form/ BlazyAdminBase.php - Returns re-usable media switch form elements.
File
- src/
Form/ BlazyAdminBase.php, line 711
Class
- BlazyAdminBase
- A base for blazy admin integration to have re-usable methods in one place.
Namespace
Drupal\blazy\FormCode
protected function getState($state, array $definition = []) {
$lightboxes = [];
foreach ($this->blazyManager
->getLightboxes() as $key => $lightbox) {
$lightboxes[$key]['value'] = $lightbox;
}
$states = [
static::STATE_RESPONSIVE_IMAGE_STYLE_DISABLED => [
'visible' => [
'select[name$="[responsive_image_style]"]' => [
'value' => '',
],
],
],
static::STATE_LIGHTBOX_ENABLED => [
'visible' => [
'select[name*="[media_switch]"]' => $lightboxes,
],
],
static::STATE_LIGHTBOX_CUSTOM => [
'visible' => [
'select[name$="[box_caption]"]' => [
'value' => 'custom',
],
'select[name*="[media_switch]"]' => $lightboxes,
],
],
static::STATE_IFRAME_ENABLED => [
'visible' => [
'select[name*="[media_switch]"]' => [
'value' => 'media',
],
],
],
static::STATE_THUMBNAIL_STYLE_ENABLED => [
'visible' => [
'select[name$="[thumbnail_style]"]' => [
'!value' => '',
],
],
],
static::STATE_IMAGE_RENDERED_ENABLED => [
'visible' => [
'select[name$="[media_switch]"]' => [
'!value' => 'rendered',
],
],
],
];
return $states[$state];
}