View source
<?php
use Drupal\flickity\Entity\FlickityGroup;
function flickity_theme() {
return array(
'flickity' => array(
'function' => 'theme_flickity',
'variables' => array(
'items' => array(),
'settings' => array(),
),
'file' => 'theme/flickity.theme.inc',
),
'flickity_item' => array(
'variables' => array(
'item' => array(),
'attributes' => array(),
),
),
'flickity_wrapper' => array(
'variables' => array(
'output' => array(),
'attributes' => array(),
),
),
);
}
function flickity_settings($id) {
$config = flickity_load($id);
$settings = $config
->getSettings();
$group = array(
'id' => $config
->id(),
'label' => $config
->label(),
'settings' => array(
'imagesLoaded' => $settings['images_loaded'],
'cellSelector' => $settings['cell_selector'],
'initialIndex' => $settings['initial_index'],
'accessibility' => (bool) $settings['accessibility'],
'setGallerySize' => (bool) $settings['set_gallery_size'],
'resize' => (bool) $settings['resize'],
'cellAlign' => $settings['cell_align'],
'contain' => (bool) $settings['contain'],
'percentPosition' => (bool) $settings['percent_position'],
'rightToLeft' => (bool) $settings['right_to_left'],
'draggable' => (bool) $settings['draggable'],
'freeScroll' => (bool) $settings['free_scroll'],
'wrapAround' => (bool) $settings['wrap_around'],
'groupCells' => $settings['group_cells'],
'adaptiveHeight' => $settings['adaptive_height'],
'lazyLoad' => $settings['lazy_load'],
'dragThreshold' => $settings['drag_threshold'],
'autoPlay' => $settings['auto_play'],
'watchCSS' => (bool) $settings['watch_css'],
'asNavFor' => $settings['as_nav_for'],
'selectedAttraction' => $settings['selected_attraction'],
'friction' => $settings['friction'],
'freeScrollFriction' => $settings['free_scroll_friction'],
'prevNextButtons' => (bool) $settings['prev_next_buttons'],
'pageDots' => (bool) $settings['page_dots'],
),
);
\Drupal::moduleHandler()
->alter('settings', $group);
return $group;
}
function flickity_load($id) {
return FlickityGroup::load($id);
}
function flickity_load_multiple($ids = NULL) {
return FlickityGroup::loadMultiple($ids);
}
function flickity_settings_list() {
$options = array();
foreach (flickity_load_multiple() as $group) {
$options[$group
->id()] = $group
->label();
}
return $options;
}
function flickity_form_flickity_group_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state) {
if ($form['id']['#default_value'] == 'default_group') {
hide($form['actions']['delete']);
}
}