You are here

function _patterns_has_all_mandatory_attributes in Patterns 7.2

Auxiliar function that can be used by the components to check if the action has all the expected mandatory values.

@TO-DO: Find a cleaner way to input the <br>

Parameters

array $attributes List of attributes in the current action:

array $mandatory_attributes List of expected mandatory attributes:

string $msg Message that will be promted to the user:

Return value

boolean Returns TRUE if all the $mandatory_attributes are found in $attributes, FALSE otherwise

6 calls to _patterns_has_all_mandatory_attributes()
block_patterns_validate in patterns_components/components/block.inc
color_patterns_validate in patterns_components/components/color.inc
field_patterns_validate in patterns_components/components/field.inc
menu_patterns_validate in patterns_components/components/menu.inc
system_patterns_validate in patterns_components/components/system.inc

... See full list

File

patterns_components/patterns_components.module, line 24

Code

function _patterns_has_all_mandatory_attributes($attributes, $mandatory_attributes, &$msg) {
  $result = TRUE;
  foreach ($mandatory_attributes as $att) {
    if (!array_key_exists($att, $attributes)) {
      $msg .= t('Mandatory attribute %att could not be found.<br>', array(
        '%att' => $att,
      ));
      $result = FALSE;
    }
  }
  return $result;
}