storm-1.x-dev/modules/storm_blocks/modules/storm_block_cta_button/storm_block_cta_button.module

modules/storm_blocks/modules/storm_block_cta_button/storm_block_cta_button.module
<?php

/**
 * @file
 * Provides a CTA Button to directs your visitors to do something specific.
 */

use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\field\Entity\FieldStorageConfig;

/**
 * Set dynamic allowed values for the CTA button field.
 *
 * @param \Drupal\field\Entity\FieldStorageConfig $definition
 *   The field definition.
 * @param \Drupal\Core\Entity\ContentEntityInterface|null $entity
 *   The entity being created if applicable.
 * @param bool $cacheable
 *   Boolean indicating if the results are cacheable.
 *
 * @return array
 *   An array of possible key and value options.
 *
 * @see options_allowed_values()
 */
function storm_cta_button_type_allowed_values(FieldStorageConfig $definition, ContentEntityInterface $entity = NULL, $cacheable) {
  $config = \Drupal::config('storm.cta_button.type.settings')->get('allowed_values');
  foreach (explode("\r\n", $config) as $type) {
    $type = trim($type);
    if (!empty($type)) {
      [$class, $label] = explode('|', $type);
      $options[$class] = $label;
    }
  }

  return $options;
}

/**
 * Sets the default value for the alignment field.
 *
 * @param \Drupal\Core\Entity\ContentEntityInterface $entity
 *   The entity being created.
 * @param \Drupal\Core\Field\FieldDefinitionInterface $definition
 *   The field definition.
 *
 * @return array
 *   An array of default value keys with each entry keyed with the “value” key.
 *
 * @see \Drupal\Core\Field\FieldConfigBase::getDefaultValue()
 */
function storm_cta_button_type_default_values(ContentEntityInterface $entity, FieldDefinitionInterface $definition) {
  $default = 'button--default';

  return [
    ['value' => $default],
  ];
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc