/** * Generate the attributes of an element. * * @param Menu\Items\Element $item * @return string */ protected function attributes(Element $element) { $output = ''; foreach ($element->attributes() as $attribute => $value) { $output .= ' ' . $attribute . '="' . $value . '"'; } return $output; }
/** * Add a class to an element. * * @param Menu\Items\Element $element * @param string $class * @return void */ protected function addClass($element, $class) { // Don't do anything if the class is null. if (!is_null($class)) { // Make sure that the element does not already have the class // before appending the class to the element. if (strpos($element->class, ' ' . $class . ' ') === false) { $element->append('class', $class); } } }