public static function validate(array &$settings, array &$errors) { // Use the TIMEOUT that was specified by the user for a real world indication $timeout = isset($settings[self::getClass()]['timeout']) ? (int) $settings[self::getClass()]['timeout'] : 6; // Check cache value is numeric if (!is_numeric($settings[self::getClass()]['cache'])) { $errors[self::getClass()]['cache'] = __('Must be a valid number'); } // Make sure that XPath has been filled out if (trim($settings[self::getClass()]['xpath']) == '') { $errors[self::getClass()]['xpath'] = __('This is a required field'); } // Ensure we have a URL if (trim($settings[self::getClass()]['url']) == '') { $errors[self::getClass()]['url'] = __('This is a required field'); } elseif (!preg_match('@{([^}]+)}@i', $settings[self::getClass()]['url'])) { // If there is a parameter in the URL, we can't validate the existence of the URL // as we don't have the environment details of where this datasource is going // to be executed. $valid_url = self::isValidURL($settings[self::getClass()]['url'], $timeout, $settings[self::getClass()]['format'], true); // If url was valid, `isValidURL` will return an array of data // Otherwise it'll return a string, which is an error if (is_array($valid_url)) { self::$url_result = $valid_url['data']; } else { $errors[self::getClass()]['url'] = $valid_url; } } return empty($errors[self::getClass()]); }
public static function registerProviders() { self::$provides = array('data-sources' => array('RemoteDatasource' => RemoteDatasource::getName())); return true; }
public function __construct($env = NULL, $process_params = true) { parent::__construct($env, $process_params); $this->_dependencies = array(); }
/** * Given the format, this function will look for the file * and create a new transformer. * * @param string $format * @return Transformer */ public static function getTransformer($format) { $transformer = EXTENSIONS . '/remote_datasource/lib/class.' . strtolower($format) . '.php'; if (!isset(self::$transformer)) { if (file_exists($transformer)) { $classname = (require_once $transformer); self::$transformer = new $classname(); } } return self::$transformer; }