/** * * Creates a symlink in "docroot/public" for a given class. * * @param string $class The class name. * * @return void * */ protected function _link($class) { // array of class-name parts $arr = explode('_', $class); // the last part of the class name where to put the symlink $tgt = array_pop($arr); // make the rest of the array into a subdirectory path $sub = implode('/', $arr); // where is the source (original) directory located, relatively? $k = count($arr); $src = ""; for ($i = 0; $i < $k; $i++) { $src .= "../"; } $src .= "../../include/{$sub}/{$tgt}/Public"; // need the system root $system = Solar::$system; // make sure we have a place to make the symlink $dir = "docroot/public/{$sub}"; if (!Solar_Dir::exists("{$system}/{$dir}")) { $this->_out(" Making public directory {$dir} ... "); Solar_Dir::mkdir("{$system}/{$dir}", 0755, true); $this->_outln("done."); } // make the symlink $this->_out(" Making public symlink for {$class} ... "); try { Solar_Symlink::make($src, $tgt, $dir); $this->_outln('done.'); } catch (Exception $e) { $this->_out($e->getMessage()); $this->_outln(' ... failed.'); } }
/** * * Write out a series of dirs and symlinks for a new Vendor source. * * @param string $vendor The Vendor name. * * @return void * */ protected function _exec($vendor = null) { // we need a vendor name, at least if (!$vendor) { throw $this->_exception('ERR_NO_VENDOR'); } $this->_outln("Making links for vendor '{$vendor}' ..."); // build "foo-bar" and "FooBar" versions of the vendor name. $this->_inflect = Solar_Registry::get('inflect'); $this->_dashes = $this->_inflect->camelToDashes($vendor); $this->_studly = $this->_inflect->dashesToStudly($this->_dashes); $links = array(array('dir' => "include", 'tgt' => $this->_studly, 'src' => "../source/{$this->_dashes}/{$this->_studly}"), array('dir' => "include/Test", 'tgt' => $this->_studly, 'src' => "../../source/{$this->_dashes}/tests/Test/{$this->_studly}"), array('dir' => "include/Mock", 'tgt' => $this->_studly, 'src' => "../../source/{$this->_dashes}/tests/Mock/{$this->_studly}"), array('dir' => "include/Fixture", 'tgt' => $this->_studly, 'src' => "../../source/{$this->_dashes}/tests/Fixture/{$this->_studly}"), array('dir' => "script", 'tgt' => $this->_dashes, 'src' => "../source/solar/script/solar")); $system = Solar::$system; foreach ($links as $link) { // $dir, $src, $tgt extract($link); // make it $this->_out(" Making link '{$dir}/{$tgt}' ... "); try { Solar_Symlink::make($src, $tgt, "{$system}/{$dir}"); $this->_outln("done."); } catch (Exception $e) { $this->_out($e->getMessage()); $this->_outln(" ... failed."); } } // done with this part $this->_outln("... done."); // make public links $link_public = Solar::factory('Solar_Cli_LinkPublic'); $link_public->exec($vendor); // done for real $this->_outln("Remember to add '{$this->_studly}_App' to the " . "['Solar_Controller_Front']['classes'] element " . "in your config file so that it finds your apps."); $this->_outln("Remember to add '{$this->_studly}_Model' to the " . "['Solar_Sql_Model_Catalog']['classes'] element " . "in your config file so that it finds your models."); }