/**
  * @see ItemParameterManipulation::doManipulation
  * 
  * @since 0.4
  */
 public function doManipulation(&$value, Parameter $parameter, array &$parameters)
 {
     // When the value defaulted to a boolean, there is no need for this manipulation.
     if (!is_bool($value) || !$parameter->wasSetToDefault()) {
         $value = in_array($value, array('yes', 'on'));
     }
 }
 /**
  * @see ItemParameterManipulation::doManipulation
  * 
  * @since 0.7.5
  */
 public function doManipulation(&$value, Parameter $parameter, array &$parameters)
 {
     global $egMapsDefaultGeoService;
     static $validatedDefault = false;
     if (!MapsGeocoders::canGeocode()) {
         throw new MWException('There are no geocoders registered, so no geocoding can happen.');
     }
     // Get rid of any aliases.
     $value = $this->getMainIndentifier($value);
     // Override the defaulting.
     if ($parameter->wasSetToDefault() && is_string($this->mappingServiceParam) && array_key_exists($this->mappingServiceParam, $parameters)) {
         $value = self::resolveOverrides($value, $parameters[$this->mappingServiceParam]->getValue());
     }
     if ($value === '' || !array_key_exists($value, MapsGeocoders::$registeredGeocoders)) {
         if (!$validatedDefault) {
             if (!array_key_exists($egMapsDefaultGeoService, MapsGeocoders::$registeredGeocoders)) {
                 $geoServices = array_keys(MapsGeocoders::$registeredGeocoders);
                 $egMapsDefaultGeoService = array_shift($geoServices);
                 if (is_null($egMapsDefaultGeoService)) {
                     throw new MWException('Tried to geocode while there are no geocoders available at ' . __METHOD__);
                 }
             }
         }
         if (array_key_exists($egMapsDefaultGeoService, MapsGeocoders::$registeredGeocoders)) {
             $value = $egMapsDefaultGeoService;
         } else {
             throw new MWException('Attempt to use the default geocoder while it does not exist.');
         }
     }
 }
Exemple #3
0
 /**
  * @see ItemParameterManipulation::doManipulation
  * 
  * @since 0.7
  */
 public function doManipulation(&$value, Parameter $parameter, array &$parameters)
 {
     // If there are multiple points and the value was not provided or incorrect (=defaulted),
     // set it to false, so the mapping service can figure out the optimal value.
     if ($parameter->wasSetToDefault() && count($parameters['coordinates']->getValue()) > 1) {
         $value = false;
     }
 }