You are here

class BlazyAdminFormatter in Blazy 8

Same name and namespace in other branches
  1. 8.2 src/Form/BlazyAdminFormatter.php \Drupal\blazy\Form\BlazyAdminFormatter
  2. 7 src/Form/BlazyAdminFormatter.php \Drupal\blazy\Form\BlazyAdminFormatter

Provides admin form specific to Blazy admin formatter.

Hierarchy

Expanded class hierarchy of BlazyAdminFormatter

1 file declares its use of BlazyAdminFormatter
BlazyAdminFormatterUnitTest.php in tests/src/Unit/Form/BlazyAdminFormatterUnitTest.php
1 string reference to 'BlazyAdminFormatter'
blazy.services.yml in ./blazy.services.yml
blazy.services.yml
1 service uses BlazyAdminFormatter
blazy.admin.formatter in ./blazy.services.yml
Drupal\blazy\Form\BlazyAdminFormatter

File

src/Form/BlazyAdminFormatter.php, line 10

Namespace

Drupal\blazy\Form
View source
class BlazyAdminFormatter extends BlazyAdminFormatterBase {

  /**
   * Defines re-usable form elements.
   */
  public function buildSettingsForm(array &$form, $definition = []) {
    $definition['namespace'] = 'blazy';
    $definition['responsive_image'] = isset($definition['responsive_image']) ? $definition['responsive_image'] : TRUE;
    $this
      ->openingForm($form, $definition);
    $this
      ->imageStyleForm($form, $definition);
    if (!empty($definition['media_switch_form']) && !isset($form['media_switch'])) {
      $this
        ->mediaSwitchForm($form, $definition);
    }
    if (!empty($definition['grid_form']) && !isset($form['grid'])) {
      $this
        ->gridForm($form, $definition);

      // Blazy doesn't need complex grid with multiple groups.
      unset($form['preserve_keys'], $form['visible_items']);
      if (isset($form['grid'])) {
        $form['grid']['#description'] = $this
          ->t('The amount of block grid columns for large monitors 64.063em+. <br /><strong>Requires</strong>:<ol><li>Display style.</li><li>A reasonable amount of contents.</li></ol>Leave empty to DIY, or to not build grids.');
      }
    }
    if (!empty($definition['breakpoints'])) {
      $this
        ->breakpointsForm($form, $definition);
    }
    if (isset($form['responsive_image_style'])) {
      $form['responsive_image_style']['#description'] = $this
        ->t('Not compatible with below breakpoints, aspect ratio, yet. However it can still lazyload by checking <strong>Responsive image</strong> option via Blazy UI. Leave empty to disable.');
      if ($this
        ->blazyManager()
        ->getModuleHandler()
        ->moduleExists('blazy_ui')) {
        $form['responsive_image_style']['#description'] .= ' ' . $this
          ->t('<a href=":url" target="_blank">Enable lazyloading Responsive image</a>.', [
          ':url' => Url::fromRoute('blazy.settings')
            ->toString(),
        ]);
      }
    }
    $this
      ->closingForm($form, $definition);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BlazyAdminBase::$blazyManager protected property The blazy manager service.
BlazyAdminBase::$entityDisplayRepository protected property The entity type manager service.
BlazyAdminBase::$typedConfig protected property The typed config manager service.
BlazyAdminBase::baseForm public function Returns simple form elements common for Views field, EB widget, formatters.
BlazyAdminBase::blazyManager public function Returns the blazy manager.
BlazyAdminBase::breakpointElements public function Defines re-usable breakpoints form.
BlazyAdminBase::breakpointsForm public function Defines re-usable breakpoints form.
BlazyAdminBase::closingForm public function Returns shared ending form elements across field formatter and Views. 1
BlazyAdminBase::create public static function
BlazyAdminBase::finalizeForm public function Returns re-usable logic, styling and assets across fields and Views.
BlazyAdminBase::getCacheOptions public function Returns time in interval for select options.
BlazyAdminBase::getEntityDisplayRepository public function Returns the entity display repository.
BlazyAdminBase::getOptionsetOptions public function Returns available optionsets for select options.
BlazyAdminBase::getState protected function Get one of the pre-defined states used in this form.
BlazyAdminBase::getTypedConfig public function Returns the typed config.
BlazyAdminBase::getViewModeOptions public function Returns available view modes for select options.
BlazyAdminBase::gridForm public function Returns re-usable grid elements across field formatter and Views.
BlazyAdminBase::mediaSwitchForm public function Returns re-usable media switch form elements.
BlazyAdminBase::openingForm public function Returns shared form elements across field formatter and Views. 1
BlazyAdminBase::STATE_IFRAME_ENABLED constant A state that represents the media switch iframe is enabled.
BlazyAdminBase::STATE_IMAGE_RENDERED_ENABLED constant A state that represents the image rendered switch is enabled.
BlazyAdminBase::STATE_LIGHTBOX_CUSTOM constant A state that represents the custom lightbox caption is enabled.
BlazyAdminBase::STATE_LIGHTBOX_ENABLED constant A state that represents the media switch lightbox is enabled.
BlazyAdminBase::STATE_RESPONSIVE_IMAGE_STYLE_DISABLED constant A state that represents the responsive image style is disabled.
BlazyAdminBase::STATE_THUMBNAIL_STYLE_ENABLED constant A state that represents the thumbnail style is enabled.
BlazyAdminBase::__construct public function Constructs a BlazyAdminBase object.
BlazyAdminFormatter::buildSettingsForm public function Defines re-usable form elements.
BlazyAdminFormatterBase::getExcludedFieldOptions public function Declutters options from less relevant options.
BlazyAdminFormatterBase::getExcludedSettingsSummary public function Exclude the field formatter settings summary as required.
BlazyAdminFormatterBase::getFieldOptions public function Returns available fields for select options.
BlazyAdminFormatterBase::getResponsiveImageOptions public function Returns Responsive image for select options.
BlazyAdminFormatterBase::getSettingsSummary public function Return the field formatter settings summary.
BlazyAdminFormatterBase::imageStyleForm public function Returns re-usable image formatter form elements.
BlazyAdminFormatterBase::settingsSummary Deprecated public function Return the field formatter settings summary.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.