You are here

function flag_handler_relationship::validate in Flag 6.2

Same name and namespace in other branches
  1. 7.3 includes/views/flag_handler_relationships.inc \flag_handler_relationship::validate()
  2. 7.2 includes/flag_handler_relationships.inc \flag_handler_relationship::validate()

Make sure the flag exists.

When importing views, or when deleting flags, inconsistent views may result. This validator is called by Views before saving or previewing a view.

1 call to flag_handler_relationship::validate()
flag_handler_relationship::get_flag in includes/flag_handler_relationships.inc
Returns the flag object.

File

includes/flag_handler_relationships.inc, line 32
Contains various relationship handlers.

Class

flag_handler_relationship
Base class for all our relationship classes.

Code

function validate() {
  $errors = array();
  $tokens = array(
    '@relationship-name' => $this
      ->ui_name() . ' ' . $this
      ->admin_summary(),
    '@flag-name' => $this->options['flag'],
  );
  if (!$this->options['flag']) {
    $errors[] = t('You must pick a flag to use for the relationship "@relationship-name".', $tokens);
  }
  elseif (!flag_get_flag($this->options['flag'])) {
    $errors[] = t('This view is looking for a flag by the name "@flag-name", but there is no such flag. Perhaps it was deleted. Please update the relationship "@relationship-name" in this view to use an existing flag.', $tokens);
  }
  return $errors;
}