merged branch Crell/route-requirements (PR #6098)
This PR was merged into the master branch.
Commits
-------
b930066
Add Route::hasOption() and Route::hasRequirement() methods.
Discussion
----------
Add Route::hasOption() and Route::hasRequirement() methods.
It seems odd that there's a hasDefault() method but not for options and requirements. Drupal has logic that depends on the existence of a given requirement. So let's add that.
I think I got the coding standards right the first time for once... :-)
This commit is contained in:
commit
64b69804f3
@ -233,6 +233,18 @@ class Route implements \Serializable
|
||||
return isset($this->options[$name]) ? $this->options[$name] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a an option has been set
|
||||
*
|
||||
* @param string $name An option name
|
||||
*
|
||||
* @return Boolean true if the option is set, false otherwise
|
||||
*/
|
||||
public function hasOption($name)
|
||||
{
|
||||
return array_key_exists($name, $this->options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the defaults.
|
||||
*
|
||||
@ -377,6 +389,18 @@ class Route implements \Serializable
|
||||
return isset($this->requirements[$key]) ? $this->requirements[$key] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a requirement is set for the given key.
|
||||
*
|
||||
* @param string $name A variable name
|
||||
*
|
||||
* @return Boolean true if a requirement is specified, false otherwise
|
||||
*/
|
||||
public function hasRequirement($key)
|
||||
{
|
||||
return array_key_exists($key, $this->requirements);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a requirement for the given key.
|
||||
*
|
||||
|
Reference in New Issue
Block a user