summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Carver2017-06-19 07:31:46 -0500
committerMark Carver2017-06-19 08:13:42 -0500
commitfd8fde2b8c134b814a13806d30dab4497030ef7d (patch)
tree4ba19d4aae97d026ed74ec9419b0925948961098
parent90bc697634068682acac5c4c2b6ddbdae60dfa39 (diff)
Issue #2887284 by AdamPS, markcarver: Forcibly disable smart descriptions on captcha elements
-rw-r--r--src/Plugin/Prerender/Captcha.php29
-rw-r--r--src/Utility/Element.php9
2 files changed, 37 insertions, 1 deletions
diff --git a/src/Plugin/Prerender/Captcha.php b/src/Plugin/Prerender/Captcha.php
new file mode 100644
index 0000000..3563436
--- /dev/null
+++ b/src/Plugin/Prerender/Captcha.php
@@ -0,0 +1,29 @@
+<?php
+
+namespace Drupal\bootstrap\Plugin\Prerender;
+
+use Drupal\bootstrap\Annotation\BootstrapPrerender;
+use Drupal\bootstrap\Utility\Element;
+
+/**
+ * Pre-render callback for the "captcha" element type.
+ *
+ * @ingroup plugins_prerender
+ *
+ * @BootstrapPrerender("captcha",
+ * action = @BootstrapConstant(
+ * "\Drupal\bootstrap\Bootstrap::CALLBACK_PREPEND"
+ * )
+ * )
+ */
+class Captcha extends PrerenderBase {
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function preRenderElement(Element $element) {
+ parent::preRenderElement($element);
+ $element->setProperty('smart_description', FALSE, TRUE);
+ }
+
+}
diff --git a/src/Utility/Element.php b/src/Utility/Element.php
index 84df3f7..67270e4 100644
--- a/src/Utility/Element.php
+++ b/src/Utility/Element.php
@@ -671,11 +671,18 @@ class Element extends DrupalAttributes {
* The name of the property to set.
* @param mixed $value
* The value of the property to set.
+ * @param bool $recurse
+ * Flag indicating wither to set the same property on child elements.
*
* @return $this
*/
- public function setProperty($name, $value) {
+ public function setProperty($name, $value, $recurse = FALSE) {
$this->array["#$name"] = $value instanceof Element ? $value->getArray() : $value;
+ if ($recurse) {
+ foreach ($this->children() as $child) {
+ $child->setProperty($name, $value, $recurse);
+ }
+ }
return $this;
}