From 5c387898c5cc02a9c7e2789dea4a3f711c251ae2 Mon Sep 17 00:00:00 2001 From: Jeff Tomlinson Date: Thu, 3 Aug 2017 10:23:38 -0600 Subject: [PATCH] Remove experimental code. --- .../emulsify_attributes.function.php | 64 ------------------- .../functions/render_attributes.function.php | 55 ---------------- emulsify.theme | 36 ----------- 3 files changed, 155 deletions(-) delete mode 100644 components/_twig-components/functions/emulsify_attributes.function.php delete mode 100644 components/_twig-components/functions/render_attributes.function.php diff --git a/components/_twig-components/functions/emulsify_attributes.function.php b/components/_twig-components/functions/emulsify_attributes.function.php deleted file mode 100644 index 5330ed7c..00000000 --- a/components/_twig-components/functions/emulsify_attributes.function.php +++ /dev/null @@ -1,64 +0,0 @@ - $value) { - if (is_array($value)) { - $attributes_r[$key] = implode(' ', $value); - } - else { - $attributes_r[$key] = $value; - } - } - - - - foreach($context['attributes'] as $attribute => $data) { - - // Remove this attribute from context so it doesn't filter down to child - // elements. - $context['attributes']->removeAttribute($attribute); - } - - if (class_exists('Drupal')) { - $attributes = new Attribute(); - - // Set all attributes. - foreach($attributes_r as $key => $value) { - $attributes->setAttribute($key, $value); - // Remove this attribute from context so it doesn't filter down to child - // elements. - $context['attributes']->removeAttribute($key); - } - - return $attributes; - - } - else { - -// return 'foo'; - -// return [ -// 'class' => ['foo'] -// ]; -// $classString = 'class="' . implode(' ', $classes) . '"'; -// return $classString; - dsm($attributes_r); - $attributes = []; - - foreach ($attributes_r as $attribute => $data) { -// $data = implode(' ', (array) $data); - $attributes[] = $attribute . '="' . $data . '"'; - } - - return implode(' ', $attributes); - } - -}, array('needs_context' => TRUE, 'is_safe' => array('html'))); diff --git a/components/_twig-components/functions/render_attributes.function.php b/components/_twig-components/functions/render_attributes.function.php deleted file mode 100644 index 7c1c347a..00000000 --- a/components/_twig-components/functions/render_attributes.function.php +++ /dev/null @@ -1,55 +0,0 @@ - $value) { - // If value is an instance of Attribute(), get its value. - if ($value instanceof Attribute && $value->offsetExists($key)) { - $value = $value->offsetGet($key)->value(); - } - - // Merge additional attribute values with existing ones. - if ($context['attributes']->offsetExists($key)) { - $existing_attribute = $context['attributes']->offsetGet($key)->value(); - $value = array_merge($existing_attribute, $value); - } - - $context['attributes']->setAttribute($key, $value); - } - } - - // Set all attributes. - foreach($context['attributes'] as $key => $value) { - $attributes->setAttribute($key, $value); - // Remove this attribute from context so it doesn't filter down to child - // elements. - $context['attributes']->removeAttribute($key); - } - - return $attributes; - } - else { - $attributes = []; - - foreach ($additional_attributes as $key => $value) { - if (is_array($value)) { - $attributes[] = $key . '="' . implode(' ', $value) . '"'; - } - else { - $attributes[] = $key . '="' . $value . '"'; - } - } - - return implode(' ', $attributes); - } - -}, array('needs_context' => true, 'is_safe' => array('html'))); diff --git a/emulsify.theme b/emulsify.theme index c1d49e2b..b2fefb9f 100644 --- a/emulsify.theme +++ b/emulsify.theme @@ -4,39 +4,3 @@ * @file * Functions to support theming in the Pattern Lab theme. */ - -use Drupal\Component\Utility\NestedArray; -use Drupal\Core\Template\Attribute; - -function emulsify_preprocess(&$variables, $hook, $info) { -// kint($variables['attributes']); -// $default_variables = _template_preprocess_default_variables(); -// kint($default_variables['attributes']); - - -// if (isset($info['render element'])) { -//// kint($variables['attributes']); -// $key = $info['render element']; -// -//// $variables['emulsify_attributes'] = 'Emulsify attributes.'; -// -// if (isset($variables[$key]['#attributes'])) { -// $variables['emulsify_attributes'] = NestedArray::mergeDeep($variables['attributes'], $variables[$key]['#attributes']); -// -// } -// } - -// dsm($hook); - -// static $attrs; -// -// $attributes = new Attribute(); -// -// foreach ($goobar_variables as $attribute => $value) { -// $attributes->setAttribute($attribute, $value); -// unset($variables['attributes'][$attribute]); -// } -// -// $variables['goobar'] = $attributes; - -}