/** * Loads all *.php files found at the sdk path module/sdk/{version}/lib and adds this.loadClass to * spl autoloader chain. * * @param string|null $version - either use this version (e.g. '3.0') * or take it from config.version if passed falsish value. * * @sideeffect if passed a version will update this.config to that version. */ public function __construct($version = null) { if ($version) { // provided a version, update config so we can use in the class loader later Config::inst()->update(__CLASS__, 'version', $version); } else { // no version, try and take from config instead. $version = $this->config()->get('version'); } $pathTemp = $this->config()->get('sdk_path'); // if sdk path is 'absolute' then load from site root, otherwise load relative to checkfront module directory $this->sdkPath = Controller::join_links(Director::baseFolder(), substr($pathTemp, 0, 1) === '/' ? '' : CheckfrontModule::module_path(), $this->detokenise($pathTemp, $version)); // now save the implementation path for later $this->implPath = Controller::join_links(Director::baseFolder(), CheckfrontModule::module_path(), $this->detokenise($this->config()->get('implementation_path'), $version)); spl_autoload_register(array($this, 'loadClass')); }