You are here

function patterns_parser_should_include_local in Patterns 7.2

Same name and namespace in other branches
  1. 7 includes/parser/parser.inc \patterns_parser_should_include_local()

Determines whether an pattern should be included based on the local configuration (the pattern code itself).

If a pattern id is specified in the associative array $options, it also takes that into consideration, otherwise uses the default include settings.

See also

patterns_parser_should_include()

_patterns_parser_merge_default_include_options()

1 call to patterns_parser_should_include_local()
patterns_parser_retrieve_actions_from_section in includes/parser/parser.inc
Returns all the actions from a a given section

File

includes/parser/parser.inc, line 509

Code

function patterns_parser_should_include_local($include, $options = array()) {

  // ATTACHED
  $options = _patterns_parser_merge_default_include_options($options);
  if ($options['mode'] === PATTERNS_INCLUDE_ATTACHED) {
    if (!is_array($include['pattern'])) {
      if ($options['verbose']) {
        drupal_set_message(t('A pattern was not included because lookup in the database is prohibited by the current configuration.'), 'status');
      }
      return FALSE;
    }
  }
  elseif (!empty($include) && isset($include['run'])) {

    // then we check if something is specified in the pattern file
    if (patterns_parser_is_valid_include_mode($include['run'])) {
      if ($include['run'] === PATTERNS_INCLUDE_ATTACHED) {
        return patterns_parser_should_include_local($include, array(
          'mode' => PATTERNS_INCLUDE_ATTACHED,
        ));
      }
      $options = array_merge($options, array(
        'mode' => $include['run'],
      ));
      return patterns_parser_should_include(NULL, $options);
    }
  }

  // RETURN GLOBAL OPTION IF WE COULD NOT DO BETTER
  return $options['include'];
}