class FractionsliderConfigurableTextBlock in Views FractionSlider 8
Provides a 'Example: configurable text string' block.
Drupal\Core\Block\BlockBase gives us a very useful set of basic functionality for this configurable block. We can just fill in a few of the blanks with defaultConfiguration(), blockForm(), blockSubmit(), and build().
Plugin annotation
@Block(
id = "fractionslider_configurable_text",
admin_label = @Translation("Fractionslider Block")
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Component\Plugin\ContextAwarePluginBase implements ContextAwarePluginInterface
- class \Drupal\Core\Plugin\ContextAwarePluginBase implements CacheableDependencyInterface, ContextAwarePluginInterface uses DependencySerializationTrait, StringTranslationTrait, TypedDataTrait
- class \Drupal\Core\Block\BlockBase implements BlockPluginInterface, PluginWithFormsInterface, PreviewFallbackInterface uses BlockPluginTrait, ContextAwarePluginAssignmentTrait
- class \Drupal\fractionslider\Plugin\Block\FractionsliderConfigurableTextBlock
- class \Drupal\Core\Block\BlockBase implements BlockPluginInterface, PluginWithFormsInterface, PreviewFallbackInterface uses BlockPluginTrait, ContextAwarePluginAssignmentTrait
- class \Drupal\Core\Plugin\ContextAwarePluginBase implements CacheableDependencyInterface, ContextAwarePluginInterface uses DependencySerializationTrait, StringTranslationTrait, TypedDataTrait
- class \Drupal\Component\Plugin\ContextAwarePluginBase implements ContextAwarePluginInterface
Expanded class hierarchy of FractionsliderConfigurableTextBlock
File
- src/
Plugin/ Block/ FractionsliderConfigurableTextBlock.php, line 20
Namespace
Drupal\fractionslider\Plugin\BlockView source
class FractionsliderConfigurableTextBlock extends BlockBase {
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
$path = '/' . drupal_get_path('module', 'fractionslider');
$slider = '<div class="slider-wrapper">
<div class="responisve-container">
<div class="slider">
<div class="fs_loader"></div>
<div class="slide"> <img src="' . $path . '/images/01_box_top.png" width="361" height="354" data-position="-152,142" data-in="left" data-delay="200" data-out="right"> <img src="' . $path . '/images/01_box_bottom.png" width="422" height="454" data-position="138,-152" data-in="bottomRight" data-delay="200"> <img src="' . $path . '/images/01_waves.png" width="1449" height="115" data-position="240,17" data-in="left" data-delay="" data-out="left"> <img src="' . $path . '/images/01_outofthebox.png" data-position="20,330" data-in="bottomLeft" data-delay="500" data-out="fade" style="width:auto; height:auto">
<p data-ease-in="easeOutBounce" data-out="top" data-time="1000" data-step="1" data-in="top" data-position="20,30" class="claim light-green" rel="0">jQuery FractionSlider</p>
<p class="teaser orange" data-position="90,30" data-in="left" data-step="2" data-delay="500">animate multiple elements</p>
<p class="teaser green" data-position="90,30" data-in="left" data-step="2" data-special="cycle" data-delay="3000">full control over each element</p>
<p class="teaser turky" data-position="90,30" data-in="left" data-step="2" data-special="cycle" data-delay="5500" data-out="none">opensource and free</p>
</div>
<div class="slide" data-in="slideLeft"> <img src="' . $path . '/images/02_big_boxes.png" data-fixed data-position="25,445" data-in="fade" data-delay="0" data-out="right"> <img src="' . $path . '/images/02_small_boxes.png" data-position="80,220" data-in="fade" data-delay="500" data-out="bottomRight"> <img src="' . $path . '/images/01_box_bottom.png" data-position="138,-152" data-in="bottomRight" data-delay="200" data-out="bottomRight">
<p class="claim light-green small" data-position="30,30" data-in="top" data-step="1" data-out="top">What to expect</p>
<p class="teaser turky small" data-position="90,30" data-in="bottom" data-step="2" data-delay="500">unlimited elements</p>
<p class="teaser turky small" data-position="120,30" data-in="bottom" data-step="2" data-delay="1500">many transitions</p>
<p class="teaser turky small" data-position="150,30" data-in="bottom" data-step="2" data-delay="2500">unlimited slides</p>
<p class="teaser turky small" data-position="180,30" data-in="bottom" data-step="2" data-delay="3500">background animation</p>
<p class="teaser turky small" data-position="210,30" data-in="bottom" data-step="2" data-delay="4500">easy to use</p>
</div>
</div>
</div>
</div>';
return [
'fractionslider_string' => $slider,
'fractionslider_dimensions' => '1000, 400',
];
}
/**
* {@inheritdoc}
*/
public function blockForm($form, FormStateInterface $form_state) {
$form['fractionslider_string_text'] = [
'#type' => 'textarea',
'#title' => $this
->t('FractionSlider HTML'),
'#rows' => 25,
'#description' => $this
->t('This is what HTML structure for FractionSlider. Change elements/text under < div class="slide"> to see changes.'),
'#default_value' => $this->configuration['fractionslider_string'],
];
$form['fractionslider_controls'] = [
'#type' => 'select',
'#title' => $this
->t('Controls'),
'#options' => [
'true' => $this
->t('True'),
'false' => $this
->t('False'),
],
'#default_value' => $this->configuration['fractionslider_controls'],
'#description' => $this
->t('Controls on/off'),
];
$form['fractionslider_pager'] = [
'#type' => 'select',
'#title' => $this
->t('Pager'),
'#options' => [
'true' => $this
->t('True'),
'false' => $this
->t('False'),
],
'#default_value' => $this->configuration['fractionslider_pager'],
'#description' => $this
->t("Pager inside of the slider on/off."),
];
$form['fractionslider_dimensions'] = [
'#type' => 'textfield',
'#title' => $this
->t('Dimensions'),
'#default_value' => $this->configuration['fractionslider_dimensions'],
'#description' => $this
->t('Default: 1000, 400'),
];
$form['fractionslider_fullwidth'] = [
'#type' => 'select',
'#title' => $this
->t('Full width'),
'#options' => [
'true' => $this
->t('True'),
'false' => $this
->t('False'),
],
'#default_value' => $this->configuration['fractionslider_fullwidth'],
'#description' => $this
->t('Default: false'),
];
$form['fractionslider_responsive'] = [
'#type' => 'select',
'#title' => $this
->t('Responsive'),
'#options' => [
'true' => $this
->t('True'),
'false' => $this
->t('False'),
],
'#default_value' => $this->configuration['fractionslider_responsive'],
'#description' => $this
->t('Default: true'),
];
$form['fractionslider_pausehover'] = [
'#type' => 'select',
'#title' => $this
->t('Pause on Hover'),
'#options' => [
'false' => $this
->t('False'),
'true' => $this
->t('True'),
],
'#default_value' => $this->configuration['fractionslider_pausehover'],
'#description' => $this
->t('Default: false'),
];
$form['fractionslider_increase'] = [
'#type' => 'select',
'#title' => $this
->t('Increase'),
'#options' => [
'true' => $this
->t('True'),
'false' => $this
->t('False'),
],
'#default_value' => $this->configuration['fractionslider_increase'],
'#description' => $this
->t('Default: false'),
];
return $form;
}
/**
* {@inheritdoc}
*/
public function blockSubmit($form, FormStateInterface $form_state) {
$this->configuration['fractionslider_string'] = $form_state
->getValue('fractionslider_string_text');
$this->configuration['fractionslider_controls'] = $form_state
->getValue('fractionslider_controls');
$this->configuration['fractionslider_pager'] = $form_state
->getValue('fractionslider_pager');
$this->configuration['fractionslider_dimensions'] = $form_state
->getValue('fractionslider_dimensions');
$this->configuration['fractionslider_fullwidth'] = $form_state
->getValue('fractionslider_fullwidth');
$this->configuration['fractionslider_responsive'] = $form_state
->getValue('fractionslider_responsive');
$this->configuration['fractionslider_increase'] = $form_state
->getValue('fractionslider_increase');
$this->configuration['fractionslider_pausehover'] = $form_state
->getValue('fractionslider_pausehover');
\Drupal::state()
->set('fractionslider_controls', $form_state
->getValue('fractionslider_controls'));
\Drupal::state()
->set('fractionslider_pager', $form_state
->getValue('fractionslider_pager'));
\Drupal::state()
->set('fractionslider_dimensions', $form_state
->getValue('fractionslider_dimensions'));
\Drupal::state()
->set('fractionslider_fullwidth', $form_state
->getValue('fractionslider_fullwidth'));
\Drupal::state()
->set('fractionslider_responsive', $form_state
->getValue('fractionslider_responsive'));
\Drupal::state()
->set('fractionslider_increase', $form_state
->getValue('fractionslider_increase'));
\Drupal::state()
->set('fractionslider_pausehover', $form_state
->getValue('fractionslider_pausehover'));
}
/**
* {@inheritdoc}
*/
public function build() {
return [
'#type' => 'markup',
'#markup' => $this->configuration['fractionslider_string'],
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BlockPluginInterface:: |
constant | Indicates the block label (title) should be displayed to end users. | ||
BlockPluginTrait:: |
protected | property | The transliteration service. | |
BlockPluginTrait:: |
public | function | ||
BlockPluginTrait:: |
protected | function | Returns generic default configuration for block plugins. | |
BlockPluginTrait:: |
protected | function | Indicates whether the block should be shown. | 16 |
BlockPluginTrait:: |
public | function | 3 | |
BlockPluginTrait:: |
public | function | Creates a generic configuration form for all block types. Individual block plugins can add elements to this form by overriding BlockBase::blockForm(). Most block plugins should not override this method unless they need to alter the generic form elements. | 2 |
BlockPluginTrait:: |
public | function | ||
BlockPluginTrait:: |
public | function | 1 | |
BlockPluginTrait:: |
public | function | 1 | |
BlockPluginTrait:: |
public | function | 3 | |
BlockPluginTrait:: |
public | function | ||
BlockPluginTrait:: |
public | function | ||
BlockPluginTrait:: |
public | function | ||
BlockPluginTrait:: |
public | function | Sets the transliteration service. | |
BlockPluginTrait:: |
public | function | Most block plugins should not override this method. To add submission handling for a specific block type, override BlockBase::blockSubmit(). | |
BlockPluginTrait:: |
protected | function | Wraps the transliteration service. | |
BlockPluginTrait:: |
public | function | Most block plugins should not override this method. To add validation for a specific block type, override BlockBase::blockValidate(). | 1 |
BlockPluginTrait:: |
public | function | 22 | |
ContextAwarePluginAssignmentTrait:: |
protected | function | Builds a form element for assigning a context to a given slot. | |
ContextAwarePluginAssignmentTrait:: |
protected | function | Wraps the context handler. | |
ContextAwarePluginBase:: |
protected | property | The data objects representing the context of this plugin. | |
ContextAwarePluginBase:: |
private | property | Data objects representing the contexts passed in the plugin configuration. | |
ContextAwarePluginBase:: |
protected | function |
Overrides ContextAwarePluginBase:: |
|
ContextAwarePluginBase:: |
public | function |
The cache contexts associated with this object. Overrides CacheableDependencyInterface:: |
9 |
ContextAwarePluginBase:: |
public | function |
The maximum age for which this object may be cached. Overrides CacheableDependencyInterface:: |
7 |
ContextAwarePluginBase:: |
public | function |
The cache tags associated with this object. Overrides CacheableDependencyInterface:: |
4 |
ContextAwarePluginBase:: |
public | function |
This code is identical to the Component in order to pick up a different
Context class. Overrides ContextAwarePluginBase:: |
|
ContextAwarePluginBase:: |
public | function |
Overrides ContextAwarePluginBase:: |
|
ContextAwarePluginBase:: |
public | function |
Overrides ContextAwarePluginBase:: |
|
ContextAwarePluginBase:: |
public | function |
Gets a mapping of the expected assignment names to their context names. Overrides ContextAwarePluginInterface:: |
|
ContextAwarePluginBase:: |
public | function |
Gets the defined contexts. Overrides ContextAwarePluginInterface:: |
|
ContextAwarePluginBase:: |
public | function |
Gets the value for a defined context. Overrides ContextAwarePluginInterface:: |
|
ContextAwarePluginBase:: |
public | function |
Gets the values for all defined contexts. Overrides ContextAwarePluginInterface:: |
|
ContextAwarePluginBase:: |
public | function |
Set a context on this plugin. Overrides ContextAwarePluginBase:: |
|
ContextAwarePluginBase:: |
public | function |
Sets a mapping of the expected assignment names to their context names. Overrides ContextAwarePluginInterface:: |
|
ContextAwarePluginBase:: |
public | function |
Sets the value for a defined context. Overrides ContextAwarePluginBase:: |
|
ContextAwarePluginBase:: |
public | function |
Validates the set values for the defined contexts. Overrides ContextAwarePluginInterface:: |
|
ContextAwarePluginBase:: |
public | function | Implements magic __get() method. | |
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
FractionsliderConfigurableTextBlock:: |
public | function |
Overrides BlockPluginTrait:: |
|
FractionsliderConfigurableTextBlock:: |
public | function |
Overrides BlockPluginTrait:: |
|
FractionsliderConfigurableTextBlock:: |
public | function |
Builds and returns the renderable array for this block plugin. Overrides BlockPluginInterface:: |
|
FractionsliderConfigurableTextBlock:: |
public | function |
Overrides BlockPluginTrait:: |
|
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PluginWithFormsTrait:: |
public | function | ||
PluginWithFormsTrait:: |
public | function | ||
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. | |
TypedDataTrait:: |
protected | property | The typed data manager used for creating the data types. | |
TypedDataTrait:: |
public | function | Gets the typed data manager. | 2 |
TypedDataTrait:: |
public | function | Sets the typed data manager. | 2 |