[ Index ]
 

Code source de Symfony 1.0.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/vendor/propel-generator/classes/propel/engine/builder/om/ -> ObjectBuilder.php (source)

   1  <?php
   2  
   3  /*
   4   *  $Id: ObjectBuilder.php 106 2005-06-07 03:18:28Z hans $
   5   *
   6   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   7   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   8   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
   9   * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  10   * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  11   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  12   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  13   * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  14   * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  15   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  16   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  17   *
  18   * This software consists of voluntary contributions made by many individuals
  19   * and is licensed under the LGPL. For more information please see
  20   * <http://propel.phpdb.org>.
  21   */
  22  
  23  require_once 'propel/engine/builder/om/OMBuilder.php';
  24  
  25  /**
  26   * Base class for Peer-building classes.
  27   * 
  28   * This class is designed so that it can be extended by a PHP4PeerBuilder in addition
  29   * to the "standard" PHP5PeerBuilder and PHP5ComplexOMPeerBuilder.  Hence, this class
  30   * should not have any actual template code in it -- simply basic logic & utility 
  31   * methods.
  32   * 
  33   * @author Hans Lellelid <hans@xmpl.org>
  34   */
  35  abstract class ObjectBuilder extends OMBuilder {
  36      
  37      /**
  38       * Constructs a new PeerBuilder subclass.
  39       */
  40  	public function __construct(Table $table) {
  41          parent::__construct($table);
  42      }
  43          
  44      /**
  45       * This method adds the contents of the generated class to the script.
  46       * 
  47       * This method is abstract and should be overridden by the subclasses.
  48       * 
  49       * Hint: Override this method in your subclass if you want to reorganize or
  50       * drastically change the contents of the generated peer class.
  51       * 
  52       * @param string &$script The script will be modified in this method.
  53       */
  54      abstract protected function addClassBody(&$script);
  55      
  56      /**
  57       * Adds the getter methods for the column values.
  58       * This is here because it is probably generic enough to apply to templates being generated
  59       * in different langauges (e.g. PHP4 and PHP5).
  60       * @param string &$script The script will be modified in this method.
  61       */
  62  	protected function addColumnAccessorMethods(&$script)
  63      {
  64          $table = $this->getTable();
  65          
  66          foreach ($table->getColumns() as $col) {
  67              
  68              if ($col->getType() === PropelTypes::DATE || $col->getType() === PropelTypes::TIME || $col->getType() === PropelTypes::TIMESTAMP) { 
  69                  $this->addTemporalAccessor($script, $col);
  70              } else {
  71                  $this->addGenericAccessor($script, $col);
  72              }
  73              if ($col->isLazyLoad()) {
  74                  $this->addLazyLoader($script, $col);
  75              }
  76          }
  77      }
  78      
  79      /**
  80       * Adds the mutator (setter) methods for setting column values.
  81       * This is here because it is probably generic enough to apply to templates being generated
  82       * in different langauges (e.g. PHP4 and PHP5).
  83       * @param string &$script The script will be modified in this method.
  84       */
  85  	protected function addColumnMutatorMethods(&$script)
  86      {
  87          foreach ($this->getTable()->getColumns() as $col) {
  88              
  89              if ($col->isLob()) {
  90                  $this->addLobMutator($script, $col);
  91              } elseif ($col->getType() === PropelTypes::DATE || $col->getType() === PropelTypes::TIME || $col->getType() === PropelTypes::TIMESTAMP) {
  92                  $this->addTemporalMutator($script, $col);
  93              } else {
  94                  $this->addDefaultMutator($script, $col);
  95              }
  96          }
  97      }
  98      
  99      
 100      /**
 101       * Gets the baseClass path if specified for table/db.  
 102       * If not, will return 'propel.om.BaseObject'
 103       * @return string
 104       */
 105      protected function getBaseClass() {
 106          $class = $this->getTable()->getBaseClass();
 107          if ($class === null) {
 108              $class = "propel.om.BaseObject";
 109          }
 110          return $class;
 111      }
 112      
 113      /**
 114       * Gets the interface path if specified for current table.
 115       * If not, will return 'propel.om.Persistent'.
 116       * @return string
 117       */
 118      protected function getInterface() {
 119          $interface = $this->getTable()->getInterface();
 120          if ($interface === null && !$this->getTable()->isReadOnly()) {
 121              $interface = "propel.om.Persistent";
 122          }
 123          return $interface;
 124      }
 125      
 126      /**
 127       * Whether to add the generic mutator methods (setByName(), setByPosition(), fromArray()).
 128       * This is based on the build property propel.addGenericMutators, and also whether the
 129       * table is read-only or an alias.
 130       */
 131  	protected function isAddGenericMutators()
 132      {
 133          $table = $this->getTable();        
 134          return (!$table->isAlias() && $this->getBuildProperty('addGenericMutators') && !$table->isReadOnly());
 135      }
 136      
 137      /**
 138       * Whether to add the generic accessor methods (getByName(), getByPosition(), toArray()).
 139       * This is based on the build property propel.addGenericAccessors, and also whether the
 140       * table is an alias.
 141       */
 142  	protected function isAddGenericAccessors()
 143      {
 144          $table = $this->getTable();        
 145          return (!$table->isAlias() && $this->getBuildProperty('addGenericAccessors'));
 146      }
 147      
 148  }


Généré le : Fri Mar 16 22:42:14 2007 par Balluche grâce à PHPXref 0.7