Smarter Model Object Classes

Absent any special switches used when creating the model object classes, there are two standard methods used as accessors for instance properties: valueForProperty('property_name') and setValueForProperty('property_name', $value).

While versatile, constantly having to write long accessor names becomes tedious very quickly. Fortunately, there is a switch called --with-property-methods available (which can be abbreviated -p) to create developer-friendly method names to access the model object properties.

cd ~/Sites/fw/install
php orm_install -p -n Istarel Workshop -w ~/Sites -a iw -r category
Initializing Application...
Parsing Tables in iw...
  Analyzing category...

Partial Listing: /iw/rsrc/model/default/DefaultCategory.php

class DefaultCategory extends ORMObject
{
   ...

// Accessors

   function setCategoryId($category_id)
   {
      $this->setValueForProperty('category_id', $category_id);
      return $this;
   }

   function categoryId()
   {
      return $this->category_id;
   }

   function setName($name)
   {
      $this->setValueForProperty('name', $name);
      return $this;
   }

   function name()
   {
      return $this->name;
   }

   function setPublicPath($public_path)
   {
      $this->setValueForProperty('public_path', $public_path);
      return $this;
   }

   function publicPath()
   {
      return $this->public_path;
   }

   ...