本文整理匯總了PHP中Parameter::hasDependency方法的典型用法代碼示例。如果您正苦於以下問題:PHP Parameter::hasDependency方法的具體用法?PHP Parameter::hasDependency怎麽用?PHP Parameter::hasDependency使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Parameter
的用法示例。
在下文中一共展示了Parameter::hasDependency方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: doValidation
/**
* Returns true if the parameter value contains atleast 1 comma
* meaning that there are atleast two enpoints on which to draw a line.
*
* @param string $value
* @param Parameter $parameter
* @param array $parameters
*
* @since 0.4
*
* @return boolean
*/
protected function doValidation($value, Parameter $parameter, array $parameters)
{
//fetch locations
$value = explode($this->metaDataSeparator, $value);
$value = $value[0];
//need atleast two points to create a line
$valid = strpos($value, ':') != false;
if (!$valid) {
return $valid;
}
//setup geocode deps
$canGeoCode = MapsGeocoders::canGeocode();
if ($canGeoCode) {
$geoService = $parameter->hasDependency('geoservice') ? $parameters['geoservice']->getValue() : '';
$mappingService = $parameter->hasDependency('mappingservice') ? $parameters['mappingservice']->getValue() : false;
}
//strip away line parameters and check for valid locations
$parts = explode(':', $value);
foreach ($parts as $part) {
$toIndex = strpos($part, $this->metaDataSeparator);
if ($toIndex != false) {
$part = substr($part, 0, $toIndex);
}
if ($canGeoCode) {
$valid = MapsGeocoders::isLocation($part, $geoService, $mappingService);
} else {
$valid = MapsCoordinateParser::areCoordinates($part);
}
if (!$valid) {
break;
}
}
return $valid;
}
示例2: doValidation
/**
* @see ItemParameterCriterion::validate
*/
protected function doValidation($value, Parameter $parameter, array $parameters)
{
if ($this->metaDataSeparator !== false) {
$parts = explode($this->metaDataSeparator, $value);
$value = $parts[0];
}
if (MapsGeocoders::canGeocode()) {
$geoService = $parameter->hasDependency('geoservice') ? $parameters['geoservice']->getValue() : '';
$mappingService = $parameter->hasDependency('mappingservice') ? $parameters['mappingservice']->getValue() : false;
return MapsGeocoders::isLocation($value, $geoService, $mappingService);
} else {
return MapsCoordinateParser::areCoordinates($value);
}
}