Checks if the breakpoint is valid.
\Drupal\breakpoint\InvalidBreakpointSourceTypeException
\Drupal\breakpoint\InvalidBreakpointSourceException
\Drupal\breakpoint\InvalidBreakpointNameException
\Drupal\breakpoint\InvalidBreakpointMediaQueryException
Overrides BreakpointInterface::isValid
isValidMediaQuery()
public function isValid() {
// Check for illegal values in breakpoint source type.
if (!in_array($this->sourceType, array(
Breakpoint::SOURCE_TYPE_USER_DEFINED,
Breakpoint::SOURCE_TYPE_MODULE,
Breakpoint::SOURCE_TYPE_THEME,
))) {
throw new InvalidBreakpointSourceTypeException(format_string('Invalid source type @source_type', array(
'@source_type' => $this->sourceType,
)));
}
// Check for illegal characters in breakpoint source.
if (preg_match('/[^a-z_]+/', $this->source)) {
throw new InvalidBreakpointSourceException(format_string("Invalid value '@source' for breakpoint source property. Breakpoint source property can only contain lowercase letters and underscores.", array(
'@source' => $this->source,
)));
}
// Check for illegal characters in breakpoint names.
if (preg_match('/[^0-9a-z_\\-]/', $this->name)) {
throw new InvalidBreakpointNameException(format_string("Invalid value '@name' for breakpoint name property. Breakpoint name property can only contain lowercase alphanumeric characters, underscores (_), and hyphens (-).", array(
'@name' => $this->name,
)));
}
return $this::isValidMediaQuery($this->mediaQuery);
}