Skip to content

Commit eb156de

Browse files
committed
Initial Scaffolding
1 parent cc9a120 commit eb156de

File tree

5 files changed

+118
-26
lines changed

5 files changed

+118
-26
lines changed

patternkit.info

Lines changed: 0 additions & 16 deletions
This file was deleted.

patternkit.info.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name: Patternkit
2+
description: Adds Patternkit patterns to panels as content types.
3+
package: Presentation Framework
4+
core: 8.x
5+
dependencies:
6+
- drupal:ctools
7+
- drupal:panels

patternkit.module

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,6 @@ include __DIR__ . '/include/api.inc';
1212
include __DIR__ . '/include/patternkit_config_form.inc';
1313
include __DIR__ . '/include/utility.inc';
1414

15-
/**
16-
* Implements hook_ctools_plugin_directory().
17-
*/
18-
function patternkit_ctools_plugin_directory($owner, $plugin) {
19-
if ($owner == 'ctools') {
20-
return 'plugins/' . $plugin;
21-
}
22-
23-
return NULL;
24-
}
2515

2616
/**
2717
* Implements hook_flush_caches().

patternkit.routing.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
patternkit.description:
2+
path: '/admin/structure/patternkit'
3+
defaults:
4+
_controller: '\Drupal\patternkit\Controller\PatternkitController'
5+
_title: 'Patternkit'
6+
requirements:
7+
_permission: 'administer patternkit'
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?php
2+
3+
namespace Drupal\patternlab\PatternkitController;
4+
5+
/**
6+
* Controller routines for block example routes.
7+
*/
8+
class PatternkitController {
9+
/**
10+
* @file
11+
* Provides the admin settings form for Patternkit.
12+
*/
13+
14+
/**
15+
* Drupal Form API callback for the admin form.
16+
*
17+
* @param array $form
18+
* Drupal Form API form array.
19+
* @param array $form_state
20+
* Drupal Form API form state array.
21+
*
22+
* @return array
23+
* A Drupal Form API admin form array.
24+
*/
25+
function patternkit_config_form(array $form, array &$form_state) {
26+
$libraries = patternkit_pattern_libraries();
27+
$library_options = array();
28+
$library_values = array();
29+
foreach ($libraries as $library) {
30+
$lib_title = $library->getTitle();
31+
$lib_desc = $lib_title;
32+
$lib_metadata = $library->getMetadata();
33+
if (!empty($lib_metadata)) {
34+
$library_values[] = $lib_title;
35+
$lib_desc = t('@title (@count patterns)', array(
36+
'@title' => $lib_title,
37+
'@count' => count($lib_metadata),
38+
));
39+
}
40+
$library_options[$lib_title] = $lib_desc;
41+
}
42+
$form['patternkit_libraries'] = array(
43+
'#type' => 'checkboxes',
44+
'#title' => t('Enabled Patternkit Libraries'),
45+
'#options' => $library_options,
46+
'#default_value' => $library_values,
47+
'#disabled' => TRUE,
48+
);
49+
50+
$form['patternkit_pl_host'] = array(
51+
'#type' => 'textfield',
52+
'#title' => t('PatternLab/Kit REST Services Host'),
53+
'#default_value' => variable_get('patternkit_pl_host',
54+
'http://localhost:9001'),
55+
'#size' => '120',
56+
'#maxlength' => '1023',
57+
);
58+
59+
$form['patternkit_cache_enabled'] = array(
60+
'#type' => 'checkbox',
61+
'#title' => t('Use the Patternkit Library Cache'),
62+
'#default_value' => variable_get('patternkit_cache_enabled', TRUE),
63+
);
64+
65+
$form['patternkit_render_cache'] = array(
66+
'#type' => 'checkbox',
67+
'#title' => t('Use the Patternkit Disk Render Cache'),
68+
'#default_value' => variable_get('patternkit_render_cache', FALSE),
69+
);
70+
71+
$form['patternkit_default_module_ttl'] = array(
72+
'#type' => 'textfield',
73+
'#title' => t('Patternkit Default Pattern TTL (in ms)'),
74+
'#default_value' => variable_get('patternkit_default_module_ttl',
75+
PATTERNKIT_DEFAULT_TTL),
76+
);
77+
78+
$form['#submit'][] = 'patternkit_config_form_submit';
79+
80+
return system_settings_form($form);
81+
}
82+
83+
/**
84+
* Rebuilds Patternkit data on form save.
85+
*
86+
* @param array $form
87+
* Drupal Form API form array.
88+
* @param array $form_state
89+
* Drupal Form API form state array.
90+
*
91+
* @see system_settings_form_submit()
92+
*/
93+
function patternkit_config_form_submit(array $form, array &$form_state) {
94+
if ($form_state['values']['patternkit_cache_enabled']
95+
&& !variable_get('patternkit_cache_enabled', TRUE)) {
96+
$libraries = patternkit_pattern_libraries();
97+
foreach ($libraries as $library) {
98+
$library->getCachedMetadata(NULL, TRUE);
99+
}
100+
}
101+
102+
drupal_set_message(t('Rebuilt Patternkit Library Cache.'));
103+
}
104+
}

0 commit comments

Comments
 (0)