public function testRequiredAttributes() { $this->setExpectedException('Exception'); $config = ['element' => 'img', 'requiredAttributes' => ['src']]; Element::build($config); }
private static function configAfterSanitizingAttributesArray($config) { foreach ($config['attributes'] as $key => $value) { // Move aria if (Element::stringStartsWith('aria-', $key)) { $config = Element::configAfterMovingKeyFromTo($key, 'attributes', 'ariaAttributes', $config); } // Move data if (Element::stringStartsWith('data-', $key)) { $config = Element::configAfterMovingKeyFromTo($key, 'attributes', 'dataAttributes', $config); } // Move actions if (Element::stringStartsWith('on', $key)) { $config = Element::configAfterMovingKeyFromTo($key, 'attributes', 'eventHandlers', $config); } // Move booleans that are true if (in_array($key, Element::booleanAttributes()) && $value) { array_push($config['booleanAttributes'], $key); unset($config['attributes'][$key]); } elseif (in_array($key, Element::booleanAttributes()) && !$value) { unset($config['attributes'][$key]); } } return $config; }