/**
  * 
  * 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_NAME');
     }
     $this->_outln("Removing 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);
     // the base system dir
     $system = Solar::$system;
     // the links to remove (reverse order from make-vendor)
     $links = array("script/{$this->_dashes}", "include/Mock/{$this->_studly}", "include/Test/{$this->_studly}", "include/{$this->_studly}");
     // remove the links
     foreach ($links as $link) {
         $this->_out("    Removing '{$link}' ... ");
         $path = "{$system}/{$link}";
         if (Solar_File::exists($path)) {
             unlink($path);
             $this->_outln("done.");
         } else {
             $this->_outln("missing.");
         }
     }
     // done!
     $this->_outln("... done.");
     // reminders
     $this->_outln("Remember to remove '{$this->_studly}_App' from the " . "['Solar_Controller_Front']['classes'] element " . "in your config file.");
     $this->_outln("Remember to remove '{$this->_studly}_Model' from the " . "['Solar_Sql_Model_Catalog']['classes'] element " . "in your config file.");
     // need to write a recursive-remove method for Solar_Dir that will
     // delete only the symlinked files (not the real files)
     $this->_outln("You will need to remove the " . "'docroot/public/{$this->_studly}' directory yourself, as it " . "may contain copies of public assets (not links).");
 }
 /**
  * 
  * 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.");
 }
 /**
  * 
  * 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_NAME');
     }
     // 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);
     // create dirs, files, and symlinks
     $this->_createDirs();
     $this->_createFiles();
     $this->_createLinks();
 }
Exemple #4
0
 /**
  * 
  * Gets the model class for a particular model name.
  * 
  * @param string $name The model name.
  * 
  * @return string The model class.
  * 
  */
 public function getClass($name)
 {
     $name = $this->_inflect->underToStudly($name);
     if (empty($this->_name_class[$name])) {
         $class = $this->_stack->load($name);
         $this->_name_class[$name] = $class;
     }
     return $this->_name_class[$name];
 }
Exemple #5
0
 /**
  * 
  * 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_NAME');
     }
     // 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);
     // create dirs, files, and symlinks
     $this->_createDirs();
     $this->_createFiles();
     $this->_createLinks();
     // done!
     $this->_outln("Done!");
     $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.");
 }
 /**
  * 
  * Fixes up special column indicator properties, and post-sets the
  * $_inherit_name value based on the existence of the inheritance column.
  * 
  * @return void
  * 
  * @todo How to make foreign_col recognize that it's inherited, and should
  * use the parent foreign_col value?  Can we just work up the chain?
  * 
  */
 protected function _fixPropertyCols()
 {
     // make sure these actually exist in the table, otherwise unset them
     $list = array('_created_col', '_updated_col', '_primary_col', '_inherit_col');
     foreach ($list as $col) {
         if (trim($this->{$col}) == '' || !array_key_exists($this->{$col}, $this->_table_cols)) {
             // doesn't exist in the table
             $this->{$col} = null;
         }
     }
     // post-set the inheritance model value
     if (!$this->_inherit_col) {
         $this->_inherit_name = null;
         $this->_inherit_base = null;
     }
     // set up the fetch-cols list
     settype($this->_fetch_cols, 'array');
     if (!$this->_fetch_cols) {
         $this->_fetch_cols = array_keys($this->_table_cols);
     }
     // simply force to array
     settype($this->_serialize_cols, 'array');
     settype($this->_xmlstruct_cols, 'array');
     // the "sequence" columns.  make sure they point to a sequence name.
     // e.g., string 'col' becomes 'col' => 'col'.
     $tmp = array();
     foreach ((array) $this->_sequence_cols as $key => $val) {
         if (is_int($key)) {
             $tmp[$val] = $val;
         } else {
             $tmp[$key] = $val;
         }
     }
     $this->_sequence_cols = $tmp;
     // make sure we have a hint to foreign models as to what colname
     // to use when referring to this model
     if (empty($this->_foreign_col)) {
         if (!$this->_inherit_name) {
             // not inherited
             $prefix = $this->_inflect->toSingular($this->_model_name);
             $this->_foreign_col = strtolower($prefix) . '_' . $this->_primary_col;
         } else {
             // inherited, can't just use the model name as a column name.
             // need to find base model foreign_col value.
             $base = Solar::factory($this->_inherit_base, array('sql' => $this->_sql));
             $this->_foreign_col = $base->foreign_col;
             unset($base);
         }
     }
 }