Odyssey
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
CreateMenu Class Reference
Inheritance diagram for CreateMenu:
CompassMenu

Public Member Functions

 __construct ($HB_ENV=[])
 
 isCuAndUser ()
 
 makeMenu ($params=[])
 
 makeSingleMenuNode ($node_id='', $params=[], $full_node=false)
 

Protected Member Functions

 findNode ($node_id)
 
 recursivelyWalkArray ($node_id, $item)
 
 recurseDigArray ($node_id, $sub_array)
 
 setMenuArray ($params=[])
 
 jsonPathParam ($params)
 
 isValidConfig ($arr=[])
 
 setMenuParams ($params=[])
 
 makeMenuHtml ()
 
 createMenuToggleElement ()
 
 walkMenuItems ($items=[])
 
 createElementHtml ($arr=[], $close_tag=true)
 
 getElementId ($element=[])
 
 isAssociativeArray ($arr=[])
 
 hasDisplayValue ($id, $element=[])
 
 hasUserDisplayValue ($id, $display)
 
 openHtmlElement ($element=[])
 
 closeHtmlElement ($element=[])
 
 addIndent ($tag)
 
 addNewLine ($tag)
 
 closeElementOpen ($element=[])
 
 addElementAttributes ($id, $element=[])
 
 translateValuesIfRequired ($attr, $value)
 
 isAttributeMember ($element=[])
 
 addElementClasses ($id, $element=[])
 
 setMemberValue ($id, $value, $key_to_find, $element=[])
 
 setSubValue ($id, $key_to_find, $element=[])
 
 isKeyInArray ($id, $key_to_find, $input_string, $element=[])
 
 isClassMember ($element=[])
 
 addElementContent ($id, $element=[])
 
 userContentOverride ($id)
 
 isContentMember ($element=[])
 
 returnMenuHtml ()
 
 filterInputValue ($value)
 
 composeErrors ()
 
 isErrors ()
 

Protected Attributes

 $HB_ENV = []
 
 $params = []
 
 $menu_array = []
 
 $menu_html = ''
 
 $errors = []
 

Detailed Description

CreateMenu class

An abstract class to extend and create menus from any JSON file (possibly other formats, such as HTML templates, in future versions.)

Usage: See Documentation at the bottom of this file.

Definition at line 12 of file CreateMenu.php.

Constructor & Destructor Documentation

◆ __construct()

CreateMenu::__construct (   $HB_ENV = [])

CreateMenu constructor

Returns
void

Definition at line 33 of file CreateMenu.php.

34  {
35  if (count($HB_ENV) == 0) {
36  return;
37  }
38 
39  $this->HB_ENV = $HB_ENV;
40  }

Member Function Documentation

◆ addElementAttributes()

CreateMenu::addElementAttributes (   $id,
  $element = [] 
)
protected

Walk the attributes array and add all attributes EXCEPT class, special handling.

Parameters
string$id
array$element
Returns
string|null

Definition at line 503 of file CreateMenu.php.

504  {
505  if (! $this->isAttributeMember($element)) {
506  return null;
507  }
508 
509  $attributes = null;
510 
511  foreach ($element['attributes'] as $attr => $value) {
512  if ($attr == 'class') {
513  continue;
514  }
515 
516  $val = $this->setMemberValue($id, $value, $attr, $element);
517  $set_value = $this->translateValuesIfRequired($attr, $val);
518 
519  if ($set_value) {
520  $attributes .= " $attr=\"$set_value\" ";
521  }
522 
523  }
524 
525  return rtrim($attributes);
526  }
setMemberValue($id, $value, $key_to_find, $element=[])
Definition: CreateMenu.php:588
translateValuesIfRequired($attr, $value)
Definition: CreateMenu.php:533
isAttributeMember($element=[])
Definition: CreateMenu.php:547

◆ addElementClasses()

CreateMenu::addElementClasses (   $id,
  $element = [] 
)
protected

Add classes to the HTML element.

Parameters
string$id
array$element
Returns
string|null

Definition at line 560 of file CreateMenu.php.

561  {
562  if (! $this->isClassMember($element)) {
563  return null;
564  }
565 
566  $classes = null;
567 
568  foreach ($element['attributes']['class'] as $classname => $value) {
569 
570  $set_value = $this->setMemberValue($id, $value, $classname, $element);
571 
572  if ($set_value) {
573  $classes .= "$classname ";
574  }
575  }
576 
577  return (empty($classes))? null : ' class="' . rtrim($classes) . '"';
578  }
isClassMember($element=[])
Definition: CreateMenu.php:672
setMemberValue($id, $value, $key_to_find, $element=[])
Definition: CreateMenu.php:588

◆ addElementContent()

CreateMenu::addElementContent (   $id,
  $element = [] 
)
protected

Add content members. This method is called recursively for nested content members.

Parameters
stringid, container id
array$element
Returns
string|null

Definition at line 685 of file CreateMenu.php.

686  {
687  $translate = null;
688  if (! $this->isContentMember($element)) {
689  return null;
690  }
691 
692  // Do not translate - these items should already be translated.
693  $user_content = $this->userContentOverride($id);
694  if (! empty($user_content)) {
695  return $user_content;
696  }
697 
698  $content = null;
699 
700  foreach ($element['content'] as $content_arr) {
701  $content .= $this->createElementHtml($content_arr, true);
702  }
703 
704  return $content;
705  }
userContentOverride($id)
Definition: CreateMenu.php:714
isContentMember($element=[])
Definition: CreateMenu.php:735
createElementHtml($arr=[], $close_tag=true)
Definition: CreateMenu.php:329

◆ addIndent()

CreateMenu::addIndent (   $tag)
protected

Add indents after some elements @TODO let's see if we can better format output?

Parameters
$tag
Returns
string|null

Definition at line 453 of file CreateMenu.php.

454  {
455  if (in_array($tag, ['p', 'li', 'div'])) {
456  return " ";
457  }
458 
459  return null;
460  }

◆ addNewLine()

CreateMenu::addNewLine (   $tag)
protected

Add newlines after some elements @TODO let's see if we can better format output?

Parameters
$tag
Returns
string|null

Definition at line 468 of file CreateMenu.php.

469  {
470  if (in_array($tag, ['ul', 'li', 'p', 'div'])) {
471  return PHP_EOL;
472  }
473 
474  return null;
475  }

◆ closeElementOpen()

CreateMenu::closeElementOpen (   $element = [])
protected

Return the ending carat for an opened HTML tag.

Parameters
array$element
Returns
string|null

Definition at line 482 of file CreateMenu.php.

483  {
484  // This check allows raw data in the content member, i.e. content : ["string without a tag"]
485  if (! array_key_exists('html-element', $element)) {
486  return null;
487  }
488 
489  // @TODO hinky
490  if (in_array($element['html-element'], ['i', 'em', 'b', 'strong', 'label', 'span'])) {
491  return '>';
492  }
493 
494  return '>' . PHP_EOL;
495  }

◆ closeHtmlElement()

CreateMenu::closeHtmlElement (   $element = [])
protected

Output the closing tag for any opened element. Only outputs for valid tags, allowing raw content members to output.

Parameters
array$element
Returns
string|null

Definition at line 436 of file CreateMenu.php.

437  {
438  if (! isset($element['html-element'])) {
439  return null;
440  }
441 
442  return
443  "</{$element['html-element']}>" .
444  $this->addNewLine($element['html-element']);
445  }
addNewLine($tag)
Definition: CreateMenu.php:468

◆ composeErrors()

CreateMenu::composeErrors ( )
protected

Compose error HTML from $this->errors array.

Returns
string

Definition at line 769 of file CreateMenu.php.

770  {
771  $errors = "<ul class=\"error\">";
772 
773  foreach ($this->errors as $error) {
774  $errors .= "<li>$error</li>";
775  }
776 
777  return "$errors</ul>";
778  }

◆ createElementHtml()

CreateMenu::createElementHtml (   $arr = [],
  $close_tag = true 
)
protected

The meat of the meal, output an HTML element. As we encounter content elements, this method is called recursively, allowing deeply nested elements to output.

Parameters
array$arr
bool$close_tag- container needs to be closed after items done.
Returns
string|null

Definition at line 329 of file CreateMenu.php.

330  {
331  // This check allows raw data in the content member, i.e. "content" : ["nothing but a string"]
332  if (isset($arr[0]) && is_string($arr[0])) {
333  return $arr . PHP_EOL;
334  }
335 
336  $id = $this->getElementId($arr);
337  if (! $this->hasDisplayValue($id, $arr)) {
338  return null;
339  }
340 
341  $html =
342  $this->openHtmlElement($arr) .
343  $this->addElementAttributes($id, $arr) .
344  $this->addElementClasses($id, $arr) .
345  $this->closeElementOpen($arr) .
346  $this->addElementContent($id, $arr);
347 
348  if ($close_tag) {
349  $html .= $this->closeHtmlElement($arr);
350  }
351 
352  return $html;
353  }
closeElementOpen($element=[])
Definition: CreateMenu.php:482
addElementClasses($id, $element=[])
Definition: CreateMenu.php:560
addElementAttributes($id, $element=[])
Definition: CreateMenu.php:503
getElementId($element=[])
Definition: CreateMenu.php:360
hasDisplayValue($id, $element=[])
Definition: CreateMenu.php:389
addElementContent($id, $element=[])
Definition: CreateMenu.php:685
openHtmlElement($element=[])
Definition: CreateMenu.php:419
closeHtmlElement($element=[])
Definition: CreateMenu.php:436

◆ createMenuToggleElement()

CreateMenu::createMenuToggleElement ( )
protected

Create the "non menu" toggle element if it exists. It is still contained by the parent wrapper but not in the menu element list.

Returns
string|null

Definition at line 294 of file CreateMenu.php.

295  {
296  if (!
297  isset($this->menu_array['toggle-element']) &&
298  is_array($this->menu_array['toggle-element'])
299  ) {
300  return null;
301  }
302 
303  return $this->createElementHtml($this->menu_array['toggle-element'], true);
304  }
createElementHtml($arr=[], $close_tag=true)
Definition: CreateMenu.php:329

◆ filterInputValue()

CreateMenu::filterInputValue (   $value)
protected

Basic filter (could use improvement, but all values should be internal)

Parameters
mixed$value
Returns
mixed

Definition at line 760 of file CreateMenu.php.

761  {
762  return filter_var($value, FILTER_UNSAFE_RAW);
763  }

◆ findNode()

CreateMenu::findNode (   $node_id)
protected

Helper for makeSingleMenuNode(), find the node in the array identified by $node_id.

Parameters
string$node_id
Returns
array

Definition at line 102 of file CreateMenu.php.

103  {
104  if (! (isset($this->menu_array['items']) && is_array($this->menu_array['items']))) {
105  return [];
106  }
107 
108  foreach ($this->menu_array['items'] as $item) {
109 
110  $arr = $this->recursivelyWalkArray($node_id, $item);
111  if (count($arr) > 0) {
112  return $arr;
113  }
114  }
115  return [];
116  }
recursivelyWalkArray($node_id, $item)
Definition: CreateMenu.php:125

◆ getElementId()

CreateMenu::getElementId (   $element = [])
protected

Get the ID of an element if it exists.

Parameters
array$element
Returns
string|null

Definition at line 360 of file CreateMenu.php.

361  {
362  if (! isset($element['attributes']['id'])) {
363  return null;
364  }
365 
366  return $element['attributes']['id'];
367  }

◆ hasDisplayValue()

CreateMenu::hasDisplayValue (   $id,
  $element = [] 
)
protected

See if an element has an explicitly set display value. Default to true.

Parameters
string$id
array$element
Returns
bool

Definition at line 389 of file CreateMenu.php.

390  {
391  if (! isset($element['display'])) {
392  return true;
393  }
394 
395  return $this->hasUserDisplayValue($id, $element['display']);
396  }
hasUserDisplayValue($id, $display)
Definition: CreateMenu.php:404

◆ hasUserDisplayValue()

CreateMenu::hasUserDisplayValue (   $id,
  $display 
)
protected

See if there is a display value set on the member.

Parameters
string$id
bool$display
Returns
bool|mixed

Definition at line 404 of file CreateMenu.php.

405  {
406  $key = $id . '.display';
407  if (array_key_exists($key, $this->params)) {
408  return $this->params[$key];
409  }
410 
411  return $display === true;
412  }

◆ isAssociativeArray()

CreateMenu::isAssociativeArray (   $arr = [])
protected

Helper for recursively walking array, looking for ID.

Parameters
array$arr
Returns
bool

Definition at line 374 of file CreateMenu.php.

375  {
376  if (! is_array($arr)) {
377  return false;
378  }
379 
380  return array_keys($arr) !== range(0, count($arr) - 1);
381  }

◆ isAttributeMember()

CreateMenu::isAttributeMember (   $element = [])
protected

Helper for addElementAttributes, is this an attributes array member?

Parameters
array$element
Returns
bool

Definition at line 547 of file CreateMenu.php.

548  {
549  return
550  isset($element['attributes']) &&
551  is_array($element['attributes']);
552  }

◆ isClassMember()

CreateMenu::isClassMember (   $element = [])
protected

Helper for addElementClasses, is this a class array member?

Parameters
array$element
Returns
bool

Definition at line 672 of file CreateMenu.php.

673  {
674  return
675  isset($element['attributes']['class']) &&
676  is_array($element['attributes']['class']);
677  }

◆ isContentMember()

CreateMenu::isContentMember (   $element = [])
protected

Helper for addElementContent, is this a content member in the array?

Parameters
array$element
Returns
bool

Definition at line 735 of file CreateMenu.php.

736  {
737  return
738  isset($element['content']) &&
739  is_array($element['content']);
740  }

◆ isCuAndUser()

CreateMenu::isCuAndUser ( )

If we have no CU and user, no need to output anything.

Returns
bool

Definition at line 46 of file CreateMenu.php.

47  {
48  return (
49  isset($this->HB_ENV['Cu']) &&
50  (strlen($this->HB_ENV['Cu']) > 0) &&
51  isset($this->HB_ENV['Uid']) &&
52  (strlen($this->HB_ENV['Uid']) > 0)
53  );
54  }

◆ isErrors()

CreateMenu::isErrors ( )
protected

Determine if there are errors.

Returns
bool

Definition at line 784 of file CreateMenu.php.

785  {
786  return (count($this->errors) > 0);
787  }

◆ isKeyInArray()

CreateMenu::isKeyInArray (   $id,
  $key_to_find,
  $input_string,
  $element = [] 
)
protected

Recursively dig into the element array looking for a match on the dot syntax string. If found, return true and we will use the input substitution value for the existing array value.

Parameters
string$id,theelement container ID attribute
string$key_to_find,thecurrent member key we are looking for
string$input_string,thedot-syntax input string
array$element,currentelement array
Returns
bool

Definition at line 630 of file CreateMenu.php.

631  {
632  if (!is_string($input_string) || empty($input_string) || !count($element))
633  {
634  return false;
635  }
636 
637  if (strpos($input_string, '.') !== false)
638  {
639  $key_found = false;
640  $keys = explode('.', $input_string);
641  // We are already checking the parent element
642  $find_id = array_shift($keys);
643  if (! ($find_id == $id)) {
644  return false;
645  }
646 
647  foreach ($keys as $inner_key)
648  {
649  if (array_key_exists($inner_key, $element)) {
650 
651  if ($inner_key == $key_to_find) {
652  $key_found = true;
653  break;
654  }
655 
656  $element = $element[$inner_key];
657  }
658  }
659 
660  return $key_found;
661  }
662 
663  // No one home
664  return false;
665 }

◆ isValidConfig()

CreateMenu::isValidConfig (   $arr = [])
protected

Check that the array decoded from JSON has valid array members.

Parameters
array$arr
Returns
bool

Definition at line 223 of file CreateMenu.php.

224  {
225  if ($arr === false) {
226  $this->errors[] = "Could not read the JSON configuration.";
227  return false;
228  }
229 
230  if (! (isset($arr['container']) && is_array($arr['container']))) {
231  $this->errors[] = "There is no container element in the configuration.";
232  }
233 
234  if (! (isset($arr['items']) && is_array($arr['items']))) {
235  $this->errors[] = "There is no menu items array in the configuration.";
236  }
237 
238  return true;
239  }

◆ jsonPathParam()

CreateMenu::jsonPathParam (   $params)
protected

Get the JSON file path from params.

Parameters
$params
Returns
string|null

Definition at line 209 of file CreateMenu.php.

210  {
211  if (! (isset($params['json_path']) && ! empty($params['json_path']))) {
212  return null;
213  }
214 
215  return $params['json_path'];
216  }

◆ makeMenu()

CreateMenu::makeMenu (   $params = [])

Main entry point, convert the JSON array to a menu, substituting any values required and return final HTML.

Parameters
array$params
Returns
string

Definition at line 62 of file CreateMenu.php.

63  {
64  return $this
65  ->setMenuArray($params)
66  ->setMenuParams($params)
67  ->makeMenuHtml()
68  ->returnMenuHtml();
69  }

◆ makeMenuHtml()

CreateMenu::makeMenuHtml ( )
protected

Make the menu and store in $this->menu_html.

Returns
$this

Definition at line 270 of file CreateMenu.php.

271  {
272  if ($this->isErrors()) {
273  return $this;
274  }
275 
276  // Already checked for these keys.
277  $container = $this->menu_array['container'];
278  $items = $this->menu_array['items'];
279 
280  $this->menu_html =
281  $this->createMenuToggleElement() .
282  $this->createElementHtml($container, false) .
283  $this->walkMenuItems($items) .
284  $this->closeHtmlElement($container);
285 
286  return $this;
287  }
createMenuToggleElement()
Definition: CreateMenu.php:294
walkMenuItems($items=[])
Definition: CreateMenu.php:311
closeHtmlElement($element=[])
Definition: CreateMenu.php:436
createElementHtml($arr=[], $close_tag=true)
Definition: CreateMenu.php:329

◆ makeSingleMenuNode()

CreateMenu::makeSingleMenuNode (   $node_id = '',
  $params = [],
  $full_node = false 
)

Using the same methods above, return the content of a single node in the array. Digs recursively into the array until it finds $node_id and depending on the wrapper flag, returns the full node or its content only.

Parameters
string$node_id
array$params
bool$full_node- give us the element as is in the array false = just its content
Returns
string

Definition at line 81 of file CreateMenu.php.

82  {
83  $this
84  ->setMenuArray($params)
85  ->setMenuParams($params);
86 
87  $node = $this->findNode($node_id);
88  if (count($node) > 0) {
89  return ($full_node)?
90  $this->createElementHtml($node, true) :
91  $this->addElementContent($node_id, $node);
92  }
93 
94  return '';
95  }
addElementContent($id, $element=[])
Definition: CreateMenu.php:685
findNode($node_id)
Definition: CreateMenu.php:102
createElementHtml($arr=[], $close_tag=true)
Definition: CreateMenu.php:329

◆ openHtmlElement()

CreateMenu::openHtmlElement (   $element = [])
protected

Open a valid HTML element.

Parameters
array$element
Returns
string|null

Definition at line 419 of file CreateMenu.php.

420  {
421  if (! isset($element['html-element'])) {
422  return null;
423  }
424 
425  return
426  $this->addIndent($element['html-element']) .
427  "<{$element['html-element']}";
428  }
addIndent($tag)
Definition: CreateMenu.php:453

◆ recurseDigArray()

CreateMenu::recurseDigArray (   $node_id,
  $sub_array 
)
protected

Helper for recursivelyWalkArray(), if we have a numerically indexed array, walk it and look for the node identified by $node_id.

Parameters
string$node_id
array$sub_array
Returns
array

Definition at line 162 of file CreateMenu.php.

163  {
164  if (is_array($sub_array) && ! $this->isAssociativeArray($sub_array)) {
165 
166  foreach ($sub_array as $node_array) {
167 
168  $element_array = $this->recursivelyWalkArray($node_id, $node_array);
169  $id = $this->getElementId($element_array);
170 
171  if (($id == $node_id)) {
172  return $element_array;
173  }
174  }
175  }
176 
177  return [];
178  }
getElementId($element=[])
Definition: CreateMenu.php:360
recursivelyWalkArray($node_id, $item)
Definition: CreateMenu.php:125
isAssociativeArray($arr=[])
Definition: CreateMenu.php:374

◆ recursivelyWalkArray()

CreateMenu::recursivelyWalkArray (   $node_id,
  $item 
)
protected

Helper for findNode(). Recursively dig into the array and attempt to locate the array identified by $node_id.

Parameters
string$node_id
array$item
Returns
array

Definition at line 125 of file CreateMenu.php.

126  {
127  if (! is_array($item)) {
128  return[];
129  }
130 
131  // Check top level, if it's there cool, we're done.
132  $id = $this->getElementId($item);
133  if (($id == $node_id)) {
134  return $item;
135  }
136 
137  // Walk $item array, if a matching ID is found, also done.
138  foreach ($item as $key => $value) {
139 
140  $id = $this->getElementId($value);
141  if (($id == $node_id)) {
142  return $value;
143  }
144 
145  // If we have nothing, recurse this function and walk through sub arrays.
146  $element_array = $this->recurseDigArray($node_id, $value);
147  if (count($element_array) > 0) {
148  return $element_array;
149  }
150  }
151 
152  return [];
153  }
getElementId($element=[])
Definition: CreateMenu.php:360
recurseDigArray($node_id, $sub_array)
Definition: CreateMenu.php:162

◆ returnMenuHtml()

CreateMenu::returnMenuHtml ( )
protected

Return the response, whether it's errors or the menu.

Returns
string

Definition at line 746 of file CreateMenu.php.

747  {
748  if ($this->isErrors()) {
749  return $this->composeErrors();
750  }
751 
752  return $this->menu_html;
753  }

◆ setMemberValue()

CreateMenu::setMemberValue (   $id,
  $value,
  $key_to_find,
  $element = [] 
)
protected

Set substitution value if found, otherwise return what's already in the array.

Parameters
string$id,theelement ID
mixed$value,existingvalue in array
string$key_to_find,thecurrent member we are looking for if found in input
array$element
Returns
mixed|null

Definition at line 588 of file CreateMenu.php.

589  {
590  $sub_value = $this->setSubValue($id, $key_to_find, $element);
591 
592  if (! is_null($sub_value)) {
593  return $sub_value;
594  }
595 
596  return $value;
597  }
setSubValue($id, $key_to_find, $element=[])
Definition: CreateMenu.php:606

◆ setMenuArray()

CreateMenu::setMenuArray (   $params = [])
protected

Extract the JSON file path and convert to an array. Or try to.

Parameters
array$params
Returns
$this

Definition at line 185 of file CreateMenu.php.

186  {
187  $json_path = $this->jsonPathParam($params);
188 
189  if (! is_readable($json_path)) {
190  $this->errors[] = "File $json_path is not readable.";
191  return $this;
192  }
193 
194  $arr = json_decode(file_get_contents($json_path), 1);
195  if (! $this->isValidConfig($arr)) {
196  return $this;
197  }
198 
199  $this->menu_array = $arr;
200 
201  return $this;
202  }
jsonPathParam($params)
Definition: CreateMenu.php:209
isValidConfig($arr=[])
Definition: CreateMenu.php:223

◆ setMenuParams()

CreateMenu::setMenuParams (   $params = [])
protected

Extract substitution values from input and set them as input params as an internal property.

Parameters
array$params
Returns
$this

Definition at line 246 of file CreateMenu.php.

247  {
248  if ($this->isErrors()) {
249  return $this;
250  }
251 
252  if (
253  ! isset($params['substitute_values']) &&
254  is_array($params['substitute_values'])
255  ) {
256  return $this;
257  }
258 
259  foreach ($params['substitute_values'] as $key => $value) {
260  $this->params[$key] = $value;
261  }
262 
263  return $this;
264  }

◆ setSubValue()

CreateMenu::setSubValue (   $id,
  $key_to_find,
  $element = [] 
)
protected

If there is a substitution value in input params, return it.

Parameters
string$id
string$key_to_find,thecurrent member we are looking for if found in input
array$element
Returns
mixed|null

Definition at line 606 of file CreateMenu.php.

607  {
608  foreach ($this->params as $identifier => $value) {
609 
610  $ret = $this->isKeyInArray($id, $key_to_find, $identifier, $element);
611 
612  if ($ret) {
613  return $value;
614  }
615 
616  }
617  return null;
618  }
isKeyInArray($id, $key_to_find, $input_string, $element=[])
Definition: CreateMenu.php:630

◆ translateValuesIfRequired()

CreateMenu::translateValuesIfRequired (   $attr,
  $value 
)
protected
Parameters
$attr
$value
Returns
string

Definition at line 533 of file CreateMenu.php.

534  {
535  if (! in_array($attr, ['title', 'aria-label', 'alt', 'label'])) {
536  return $value;
537  }
538  $translate = $this->HB_ENV['MC']->msg($value);
539  return (! empty($translate))? $translate : $value;
540  }

◆ userContentOverride()

CreateMenu::userContentOverride (   $id)
protected

Users may override content, such as a dynamically created link text or other content. The first and last elements (container id and identifier 'content') are all we need in this case. if the ID and identifier match, return user-provided content.

Parameters
string$id
Returns
string|null

Definition at line 714 of file CreateMenu.php.

715  {
716  foreach ($this->params as $identifier => $value) {
717 
718  $path = explode('.', $identifier);
719  $find_id = array_shift($path);
720  $target = array_pop($path);
721 
722  if (($target == 'content') && ($find_id == $id)) {
723  return $value;
724  }
725  }
726 
727  return null;
728  }

◆ walkMenuItems()

CreateMenu::walkMenuItems (   $items = [])
protected

Helper for makeMenuHtml(), walk the menu items and compose the HTML string.

Parameters
array$items
Returns
string|null

Definition at line 311 of file CreateMenu.php.

312  {
313  $html = null;
314 
315  foreach ($items as $item) {
316  $html .= $this->createElementHtml($item, true);
317  }
318 
319  return $html;
320  }
createElementHtml($arr=[], $close_tag=true)
Definition: CreateMenu.php:329

The documentation for this class was generated from the following file: