block_photo_gallery-1.1.0/block_photo_gallery.module

block_photo_gallery.module
<?php

/**
 * @file
 * Contains block_photo_gallery.module.
 */
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
/**
 * Implements hook_preprocess_page(&$variables)
 */
function block_photo_gallery_preprocess_page(&$variables) {
  $variables['#attached']['library'][] = 'block_photo_gallery/slick';
}


/**
 * Implements hook_help().
 */
function block_photo_gallery_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {
    case 'help.page.block_photo_gallery':
      $output = '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('The Block photo gallery module allows users to customize the slider based on their needs by modifying CSS classes in view blocks under advanced section.') . '</p>';
      $output .= '<h3>' . t('Uses') . '</h3>';
      $output .= '<dl>';
      $output .= '<dt>' . t('Changing slider column using CSS classes') . '</dt>';
      $output .= '<dd><p>' . t('Once the module was installed, a new Content type , views & image styles related to the module will be created automatically, By default a Single column slider with & without description text was availble in the form of view blocks, Users needs to add nodes for the newly created content type called "Block photo gallery". Under views "Block photo gallery" view will be created which will have 4 view blocks, Single column with content, Single column without content,  multi column & thumbnail slider') . '</p>';
      $output .= '<a href="../../admin/structure/types/manage/block_photo_gallery" target="_blank">' . t('Block photo gallery content type') . '</a><br/>';
      $output .= '<a href="../../admin/structure/views/view/block_photo_gallery_view" target="_blank">' . t('Block photo gallery view') . '</a><br/>';
      $output .= '<a href="../../admin/config/media/image-styles" target="_blank">' . t('Block photo gallery image styles') . '</a><br/>';
      $output .= '<p>' . t(" Once content was added,Then user needs to place the required view blocks in any of the block region based on thier needs. ") . '</p></dd>';
      $output .= '</dl>';
      $output .= '<a href="../../admin/structure/block" target="_blank">' . t('Place the required gallery view block in the prefered region.') . '</a><br/>';
      return $output;
  }
}


 /**
* Implements hook_uninstall().
*/
function block_photo_gallery_uninstall() {

    $configFactory = \Drupal::configFactory();
    $logger = \Drupal::logger('block_photo_gallery');
  
    $configNames = [
      'image.style.block_photo_gallery_style_banner',
      'image.style.block_photo_gallery_thumbnail_main',
    ];
  
    foreach ($configNames as $configName) {
      try {
        $configFactory->getEditable($configName)->delete();
      }
      catch (\Exception $e) {
        $logger->warning(sprintf('Unable to uninstall config: %s.', $configName));
      }
    }


    // Delete all nodes of given block photo gallery during module uninstall.
    $storage_handler = \Drupal::entityTypeManager()
    ->getStorage('node');
    $nodes = $storage_handler->loadByProperties(['type' => 'block_photo_gallery']);
    $storage_handler->delete($nodes);

    // Delete content type.
    $content_type = \Drupal::entityTypeManager()
      ->getStorage('node_type')
      ->load('block_photo_gallery');
    $content_type->delete();
  }
  

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

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