X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fdrupalmoduleupgrader%2Fsrc%2FRouting%2FParameterBinding.php;fp=web%2Fmodules%2Fcontrib%2Fdrupalmoduleupgrader%2Fsrc%2FRouting%2FParameterBinding.php;h=d43ef40c60295e820f8cd90de75701677618a69c;hp=0000000000000000000000000000000000000000;hb=8acec36f19c470dfcda1ae2336826a782f41874c;hpb=e0411c4e83ba0d079034db83c3f7f55be24a0e35 diff --git a/web/modules/contrib/drupalmoduleupgrader/src/Routing/ParameterBinding.php b/web/modules/contrib/drupalmoduleupgrader/src/Routing/ParameterBinding.php new file mode 100644 index 000000000..d43ef40c6 --- /dev/null +++ b/web/modules/contrib/drupalmoduleupgrader/src/Routing/ParameterBinding.php @@ -0,0 +1,122 @@ +path = clone $path; + $this->parameter = $parameter; + $this->argument = $argument; + } + + /** + * The original parameter node. + * + * @return \Pharborist\Functions\ParameterNode + */ + public function getParameter() { + return $this->parameter; + } + + /** + * Returns if the parameter is explicitly represented in the path. + * + * @return boolean + */ + public function inPath() { + return ($this->isPathPosition() && sizeof($this->path) > $this->getArgument()); + } + + /** + * Returns if this binding has an explicit argument. + * + * @return boolean + */ + public function hasArgument() { + return ($this->getArgument() !== self::NO_ARGUMENT); + } + + /** + * Returns the argument. + * + * @return mixed + */ + public function getArgument() { + return $this->argument; + } + + /** + * Whether or not the argument is a path position (integer greater + * than or equal to 0). + * + * @return boolean + */ + public function isPathPosition() { + return ($this->hasArgument() && is_integer($this->getArgument())); + } + + /** + * Returns the value of the binding. If the value is an instance of + * \Drupal\drupalmoduleupgrader\Utility\Path\PathComponentInterface, + * the binding expects to be physically represented in the path, although + * it may not yet be (this can be ascertained by the inPath() method). Any + * other value is used verbatim. + * + * @return mixed + */ + public function getValue() { + if ($this->hasArgument()) { + if ($this->isPathPosition()) { + $position = $this->getArgument(); + return $this->path->containsKey($position) ? $this->path[$position] : new PathComponent('%'); + } + else { + return $this->getArgument(); + } + } + else { + $value = $this->getParameter()->getValue(); + + if ($value instanceof ScalarNode) { + return $value->toValue(); + } + } + } + +}