Skip to content

Instantly share code, notes, and snippets.

@mootari
mootari / components.md
Last active December 30, 2017 02:37
TypeDoc documentation covering components, events and options.

Components

Instantiation

Components that extend from ChildableComponent may specify a childClass. Any included/required component extending from that class will automatically be added to the parent component's _defaultComponents and instantiated along with its parent. This behavior is provided by the Component decorator.

Converter Components

All default converter components extend from ConverterComponent. When the converter component is instantiated any converter component that has been required at this point will be added to it.

@mootari
mootari / gist:65c5c55b265130d8f61412890f38b072
Created December 11, 2017 16:42
Drupal 7 packages that depend on paragraphs
apachesolr_paragraphs (drupal/apachesolr_paragraphs)
classy_paragraphs (drupal/classy_paragraphs)
edgy (drupal/edgy)
entity_background (drupal/entity_background)
entity_behaviors (drupal/entity_behaviors)
feeds_para_mapper (drupal/feeds_para_mapper)
field_image_tooltips (drupal/field_image_tooltips)
oa_core (drupal/oa_core)
oa_discussion (drupal/oa_discussion)
oa_events (drupal/oa_events)
@mootari
mootari / output.txt
Last active January 18, 2018 23:08
Packages that depend on drupal/search_api (D7).
$ node query.js required drupal/search_api
ads_features (drupal/ads_search)
ads_features (drupal/ads_search_db)
ads_features (drupal/ads_search_solr)
ajax_facets (drupal/ajax_facets)
ajax_facets_extra (drupal/ajax_facets_extra)
angularjs (drupal/angularjs_map)
bassets_server (drupal/bassets_server_search_api)
bat (drupal/bat_facets)
bear_hunt (drupal/bear_hunt)
@mootari
mootari / MODULE.php
Last active August 16, 2017 09:06
Generating PDFs in Drupal 7 with a custom theme. (WkHtmlToPdf only extended to make getData() public.) ALL CAPS (like MY_MODULE, NODE_TYPE_A ...) are meant as placeholders.
<?php
/**
* Implements hook_menu().
*/
function MY_MODULE_menu() {
$items = array();
$items['MY_MODULE/%node'] = array(
'access callback' => 'MY_MODULE_access',
'access arguments' => array(1),
@mootari
mootari / module.php
Created August 3, 2017 14:15
Drupal 7, Views: Alter field output in table display.
<?php
/**
* Implements hook_preprocess_HOOK().
*
* Marks projects that have a reference in content overview.
*/
function MODULE_preprocess_views_view_field(&$vars) {
if(!empty($vars['view']->MODULE_foo) && $vars['field']->field_alias === 'node_type') {
if(!empty($vars['view']->MODULE_foo[$vars['row']->nid])) {
@mootari
mootari / .block
Created July 7, 2017 19:47 — forked from Kcnarf/.block
Voronoï playground : interactive Voronoï transitioning thanks to weighted Voronoï
license: mit
@mootari
mootari / index.html
Last active June 14, 2017 22:04
Random trees without RNGs
<!DOCTYPE html>
<html>
<head>
<style>
canvas {display:block; margin: 20px auto; border: 2px solid #4892c6; max-width: 100%; box-sizing: border-box; }
</style>
</head>
<body>
<script>(function() {
'use strict';
@mootari
mootari / template.php
Last active August 11, 2017 20:25
Proper error pages for content editors in admin theme. #drupal #d7
<?php
/**
* Implements hook_process_HOOK().
*/
function THEME_process_page(&$vars) {
$error_pages = array(
403 => array(
'title' => '403 Access Denied',
@mootari
mootari / module.php
Last active May 5, 2017 11:07
Drupal 7: Workaround for validation errors for same fields in multiple forms on the same page.
<?php
function MODULE_form_alter($form) {
$form['#pre_render'][] = 'MODULE_wrap_elements';
}
function MODULE_wrap_elements($form) {
foreach(element_children($form) as $name) {
$form[$name] += array('#parents' => array());
array_unshift($form[$name]['#parents'], 'container');
@mootari
mootari / class.php
Last active May 3, 2017 14:34
Barracuda/ArchiveStream: Wrapping remote files.
<?php
namespace Drupal\example;
class TarArchive extends \Barracuda\ArchiveStream\TarArchive {
public function add_remote_file($name, $path, $size, array $opt = array())
{
// send file header
$this->init_file_stream_transfer($name, $size, $opt);
// open input file