Disrupt Tools


This project is not covered by Drupal’s security advisory policy.

Disrupt Tools

This suite is primarily a set of APIs and tools to improve the developer experience.

For the moment, it includes the following tools:
- ImageStyle -- tools to make it easy for modules to generate Image Styles,
- SlugManager -- tools to make it easy to generate and manage custom Slug,
- TaxonomyHelpers -- Service to make it easy to work with Taxonomy Term,
- (Soon) MenuHelpers -- Service to make it easy to work with Menu.

Examples

ImageStylesGenerator

// Load it with injection on production
$isg = Drupal::service('disrupt_tools.image_style_generator');

// Generate and retrieve image style from Field:
$styles = $isg->fromField($node->field_image, ['thumb' => 'thumbnail']);
var_dump($styles);

// Generate and retrieve image style from File ID:
$fid = $node->field_image->entity->id();
$styles = $isg->fromFile($fid, ['thumb' => 'thumbnail']);
var_dump($styles);

SlugManager

// Load it with injection on production
$sm = Drupal::service('disrupt_tools.slug_manager');

// Retrieve slug from taxonomy alias url:
$slug = $sm->taxonomy2Slug($term, '/work/');
var_dump($slug);

// Retrieve term from slug of name alias:
$term = $sm->slug2Taxonomy('it', '/work/');
var_dump($term);

TaxonomyHelpers

// Load it with injection on production
$th = Drupal::service('disrupt_tools.taxonomy_helpers');

// Get all the siblings terms of a given taxonomy tid.
$siblings = $sm->getSiblings(1);
var_dump($siblings);

// Get the top parent term of given taxonomy term.
$parent = $sm->getTopParent(3);
var_dump($parent);

// Retrieve the depth of a given term id into his vocabulary.
$depth = $sm->getDepth(1);
var_dump($depth);

// Retrieve the all parents of a given term id into his vocabulary.
$parents = $sm->getParents(1);
var_dump($parents);

// Converting a flat array of Drupal\taxonomy\Entity\Term into a nested tree.
$em = \Drupal::service('entity.manager');
$this->taxo = $em->getStorage('taxonomy_term');
$flat = $this->taxo->loadTree('tags', 0, NULL, TRUE);
$nested = $th->buildTree($tree);
var_dump($nested);

MenuHelpers (soon)

// Get the top parent in the menu of the current page.

// Get the full active trail.

Disrupt Tools versions

Disrupt Tools is only available for Drupal 8 !
The module is ready to be used in Drupal 8, there are no known issues.

Dependencies

The Drupal 8 version of Disrupt Tools requires nothing ! Feel free to use it.

Supporting organizations

This project is sponsored by Antistatique. We are a Swiss Web Agency, Visit us at www.antistatique.net or Contact us.

Supporting organizations: 

Disrupt Tools项目的Drush安装命令:复制到剪贴板

注:个别模块仍需开启相关子模块。
周安装量: 
5
维护状态: 
积极维护中
开发状态: 
积极开发中

其他版本下载:

版本下载地址发布日期发布说明翻译下载
8.x-1.2tar.gz (14.83 KB) | zip (21.54 KB)2017年5月30日发布说明简 | 繁 | 更多

开发版本下载:

版本下载地址发布日期发布说明翻译下载
8.x-1.x-devtar.gz (14.85 KB) | zip (21.57 KB)2017年5月30日发布说明简 | 繁 | 更多