/** * Loads an adapter * @param array $nsa an array of tokens from the namespace string * @param string $ns the namespace string in full * @return array the meta data on how to load the component */ protected function adapter($nsa, $ns) { // Throw an exception of $nsa does not meet the correct length req. if (count($nsa) < 2) { throw new \ErrorException('Adapter namespace should follow this format: adapter/[adapter]'); } // The second key in the $nsa array is always the module name, followed // by the dao name $adapter = $nsa[1]; // Load the base class first \Painless::load('system/data/adapter/base', \Painless::LP_DEF_ONLY); return array('extpath' => $this->appPath . 'system/data/adapter/' . $adapter . EXT, 'extname' => '\\' . dash_to_pascal($this->appName) . '\\System\\Data\\Adapter\\' . dash_to_pascal($adapter), 'basepath' => $this->corePath . 'system/data/adapter/' . $adapter . EXT, 'basename' => '\\Painless\\System\\Data\\Adapter\\' . dash_to_pascal($adapter)); }
function dash_to_namespace($string) { // TODO: Use preg_replace for this $sp = explode('/', $string); foreach ($sp as $i => $s) { $sp[$i] = dash_to_pascal($s); } return implode('\\', $sp); }