/generator/lib/builder/om/PHP5ObjectBuilder.php
PHP | 4724 lines | 2723 code | 448 blank | 1553 comment | 375 complexity | dc03adce0da45a20827f99540c211125 MD5 | raw file
Large files files are truncated, but you can click here to view the full file
- <?php
- /**
- * This file is part of the Propel package.
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- *
- * @license MIT License
- */
- require_once dirname(__FILE__) . '/ObjectBuilder.php';
- /**
- * Generates a PHP5 base Object class for user object model (OM).
- *
- * This class produces the base object class (e.g. BaseMyTable) which contains all
- * the custom-built accessor and setter methods.
- *
- * @author Hans Lellelid <hans@xmpl.org>
- * @package propel.generator.builder.om
- */
- class PHP5ObjectBuilder extends ObjectBuilder
- {
- /**
- * Gets the package for the [base] object classes.
- * @return string
- */
- public function getPackage()
- {
- return parent::getPackage() . ".om";
- }
- public function getNamespace()
- {
- if ($namespace = parent::getNamespace()) {
- if ($this->getGeneratorConfig() && $omns = $this->getGeneratorConfig()->getBuildProperty('namespaceOm')) {
- return $namespace . '\\' . $omns;
- } else {
- return $namespace;
- }
- }
- }
- /**
- * Returns the name of the current class being built.
- * @return string
- */
- public function getUnprefixedClassname()
- {
- return $this->getBuildProperty('basePrefix') . $this->getStubObjectBuilder()->getUnprefixedClassname();
- }
- /**
- * Validates the current table to make sure that it won't
- * result in generated code that will not parse.
- *
- * This method may emit warnings for code which may cause problems
- * and will throw exceptions for errors that will definitely cause
- * problems.
- */
- protected function validateModel()
- {
- parent::validateModel();
- $table = $this->getTable();
- // Check to see whether any generated foreign key names
- // will conflict with column names.
- $colPhpNames = array();
- $fkPhpNames = array();
- foreach ($table->getColumns() as $col) {
- $colPhpNames[] = $col->getPhpName();
- }
- foreach ($table->getForeignKeys() as $fk) {
- $fkPhpNames[] = $this->getFKPhpNameAffix($fk, $plural = false);
- }
- $intersect = array_intersect($colPhpNames, $fkPhpNames);
- if (!empty($intersect)) {
- throw new EngineException("One or more of your column names for [" . $table->getName() . "] table conflict with foreign key names (" . implode(", ", $intersect) . ")");
- }
- // Check foreign keys to see if there are any foreign keys that
- // are also matched with an inversed referencing foreign key
- // (this is currently unsupported behavior)
- // see: http://propel.phpdb.org/trac/ticket/549
- foreach ($table->getForeignKeys() as $fk) {
- if ($fk->isMatchedByInverseFK()) {
- throw new EngineException("The 1:1 relationship expressed by foreign key " . $fk->getName() . " is defined in both directions; Propel does not currently support this (if you must have both foreign key constraints, consider adding this constraint with a custom SQL file.)" );
- }
- }
- }
- /**
- * Returns the appropriate formatter (from platform) for a date/time column.
- * @param Column $col
- * @return string
- */
- protected function getTemporalFormatter(Column $col)
- {
- $fmt = null;
- if ($col->getType() === PropelTypes::DATE) {
- $fmt = $this->getPlatform()->getDateFormatter();
- } elseif ($col->getType() === PropelTypes::TIME) {
- $fmt = $this->getPlatform()->getTimeFormatter();
- } elseif ($col->getType() === PropelTypes::TIMESTAMP) {
- $fmt = $this->getPlatform()->getTimestampFormatter();
- }
- return $fmt;
- }
- /**
- * Returns the type-casted and stringified default value for the specified Column.
- * This only works for scalar default values currently.
- * @return string The default value or 'NULL' if there is none.
- */
- protected function getDefaultValueString(Column $col)
- {
- $val = $col->getPhpDefaultValue();
- if ($val === null) {
- return var_export(null, true);
- }
- if ($col->isTemporalType()) {
- $fmt = $this->getTemporalFormatter($col);
- try {
- if (!($this->getPlatform() instanceof MysqlPlatform &&
- ($val === '0000-00-00 00:00:00' || $val === '0000-00-00'))) {
- // while technically this is not a default value of NULL,
- // this seems to be closest in meaning.
- $defDt = new DateTime($val);
- $defaultValue = var_export($defDt->format($fmt), true);
- }
- } catch (Exception $x) {
- // prevent endless loop when timezone is undefined
- date_default_timezone_set('America/Los_Angeles');
- throw new EngineException(sprintf('Unable to parse default temporal value "%s" for column "%s"', $col->getDefaultValueString(), $col->getFullyQualifiedName()), $x);
- }
- } elseif ($col->isEnumType()) {
- $valueSet = $col->getValueSet();
- if (!in_array($val, $valueSet)) {
- throw new EngineException(sprintf('Default Value "%s" is not among the enumerated values', $val));
- }
- $defaultValue = array_search($val, $valueSet);
- } else if ($col->isPhpPrimitiveType()) {
- settype($val, $col->getPhpType());
- $defaultValue = var_export($val, true);
- } elseif ($col->isPhpObjectType()) {
- $defaultValue = 'new '.$col->getPhpType().'(' . var_export($val, true) . ')';
- } else {
- throw new EngineException("Cannot get default value string for " . $col->getFullyQualifiedName());
- }
- return $defaultValue;
- }
- /**
- * Adds the include() statements for files that this class depends on or utilizes.
- * @param string &$script The script will be modified in this method.
- */
- protected function addIncludes(&$script)
- {
- } // addIncludes()
- /**
- * Adds class phpdoc comment and openning of class.
- * @param string &$script The script will be modified in this method.
- */
- protected function addClassOpen(&$script)
- {
- $table = $this->getTable();
- $tableName = $table->getName();
- $tableDesc = $table->getDescription();
- $interface = $this->getInterface();
- $parentClass = $this->getBehaviorContent('parentClass');
- $parentClass = (null !== $parentClass) ? $parentClass : ClassTools::classname($this->getBaseClass());
- $script .= "
- /**
- * Base class that represents a row from the '$tableName' table.
- *
- * $tableDesc
- *";
- if ($this->getBuildProperty('addTimeStamp')) {
- $now = strftime('%c');
- $script .= "
- * This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on:
- *
- * $now
- *";
- }
- $script .= "
- * @package propel.generator.".$this->getPackage()."
- */
- abstract class ".$this->getClassname()." extends ".$parentClass." ";
- $interface = ClassTools::getInterface($table);
- if ($interface) {
- $script .= " implements " . ClassTools::classname($interface);
- }
- if ($this->getTable()->getInterface()) {
- $this->declareClassFromBuilder($this->getInterfaceBuilder());
- }
- $script .= "
- {
- ";
- }
- /**
- * Specifies the methods that are added as part of the basic OM class.
- * This can be overridden by subclasses that wish to add more methods.
- * @see ObjectBuilder::addClassBody()
- */
- protected function addClassBody(&$script)
- {
- $this->declareClassFromBuilder($this->getStubPeerBuilder());
- $this->declareClassFromBuilder($this->getStubQueryBuilder());
- $this->declareClasses('Propel', 'PropelException', 'PDO', 'PropelPDO', 'Criteria', 'BaseObject', 'Persistent', 'BasePeer', 'PropelObjectCollection');
- $table = $this->getTable();
- if (!$table->isAlias()) {
- $this->addConstants($script);
- $this->addAttributes($script);
- }
- if ($this->hasDefaultValues()) {
- $this->addApplyDefaultValues($script);
- $this->addConstructor($script);
- }
- $this->addColumnAccessorMethods($script);
- $this->addColumnMutatorMethods($script);
- $this->addHasOnlyDefaultValues($script);
- $this->addHydrate($script);
- $this->addEnsureConsistency($script);
- if (!$table->isReadOnly()) {
- $this->addManipulationMethods($script);
- }
- if ($this->isAddValidateMethod()) {
- $this->addValidationMethods($script);
- }
- if ($this->isAddGenericAccessors()) {
- $this->addGetByName($script);
- $this->addGetByPosition($script);
- $this->addToArray($script);
- }
- if ($this->isAddGenericMutators()) {
- $this->addSetByName($script);
- $this->addSetByPosition($script);
- $this->addFromArray($script);
- }
- $this->addBuildCriteria($script);
- $this->addBuildPkeyCriteria($script);
- $this->addGetPrimaryKey($script);
- $this->addSetPrimaryKey($script);
- $this->addIsPrimaryKeyNull($script);
- $this->addCopy($script);
- if (!$table->isAlias()) {
- $this->addGetPeer($script);
- }
- $this->addFKMethods($script);
- $this->addRefFKMethods($script);
- $this->addCrossFKMethods($script);
- $this->addClear($script);
- $this->addClearAllReferences($script);
- $this->addPrimaryString($script);
- // apply behaviors
- $this->applyBehaviorModifier('objectMethods', $script, " ");
- $this->addMagicCall($script);
- }
- /**
- * Closes class.
- * @param string &$script The script will be modified in this method.
- */
- protected function addClassClose(&$script)
- {
- $script .= "
- } // " . $this->getClassname() . "
- ";
- $this->applyBehaviorModifier('objectFilter', $script, "");
- }
- /**
- * Adds any constants to the class.
- * @param string &$script The script will be modified in this method.
- */
- protected function addConstants(&$script)
- {
- $script .= "
- /**
- * Peer class name
- */
- const PEER = '" . addslashes($this->getStubPeerBuilder()->getFullyQualifiedClassname()) . "';
- ";
- }
- /**
- * Adds class attributes.
- * @param string &$script The script will be modified in this method.
- */
- protected function addAttributes(&$script)
- {
- $table = $this->getTable();
- $script .= "
- /**
- * The Peer class.
- * Instance provides a convenient way of calling static methods on a class
- * that calling code may not be able to identify.
- * @var ".$this->getPeerClassname()."
- */
- protected static \$peer;
- ";
- if (!$table->isAlias()) {
- $this->addColumnAttributes($script);
- }
- foreach ($table->getForeignKeys() as $fk) {
- $this->addFKAttributes($script, $fk);
- }
- foreach ($table->getReferrers() as $refFK) {
- $this->addRefFKAttributes($script, $refFK);
- }
- // many-to-many relationships
- foreach ($table->getCrossFks() as $fkList) {
- $crossFK = $fkList[1];
- $this->addCrossFKAttributes($script, $crossFK);
- }
- $this->addAlreadyInSaveAttribute($script);
- $this->addAlreadyInValidationAttribute($script);
- // apply behaviors
- $this->applyBehaviorModifier('objectAttributes', $script, " ");
- }
- /**
- * Adds variables that store column values.
- * @param string &$script The script will be modified in this method.
- * @see addColumnNameConstants()
- */
- protected function addColumnAttributes(&$script)
- {
- $table = $this->getTable();
- foreach ($table->getColumns() as $col) {
- $this->addColumnAttributeComment($script, $col);
- $this->addColumnAttributeDeclaration($script, $col);
- if ($col->isLazyLoad() ) {
- $this->addColumnAttributeLoaderComment($script, $col);
- $this->addColumnAttributeLoaderDeclaration($script, $col);
- }
- if ($col->getType() == PropelTypes::OBJECT || $col->getType() == PropelTypes::PHP_ARRAY) {
- $this->addColumnAttributeUnserializedComment($script, $col);
- $this->addColumnAttributeUnserializedDeclaration($script, $col);
- }
- }
- }
- /**
- * Add comment about the attribute (variable) that stores column values
- * @param string &$script The script will be modified in this method.
- * @param Column $col
- **/
- protected function addColumnAttributeComment(&$script, Column $col)
- {
- $cptype = $col->getPhpType();
- $clo = strtolower($col->getName());
- $script .= "
- /**
- * The value for the $clo field.";
- if ($col->getDefaultValue()) {
- if ($col->getDefaultValue()->isExpression()) {
- $script .= "
- * Note: this column has a database default value of: (expression) ".$col->getDefaultValue()->getValue();
- } else {
- $script .= "
- * Note: this column has a database default value of: ". $this->getDefaultValueString($col);
- }
- }
- $script .= "
- * @var $cptype
- */";
- }
- /**
- * Adds the declaration of a column value storage attribute
- * @param string &$script The script will be modified in this method.
- * @param Column $col
- **/
- protected function addColumnAttributeDeclaration(&$script, Column $col)
- {
- $clo = strtolower($col->getName());
- $script .= "
- protected \$" . $clo . ";
- ";
- }
- /**
- * Adds the comment about the attribute keeping track if an attribute value has been loaded
- * @param string &$script The script will be modified in this method.
- * @param Column $col
- **/
- protected function addColumnAttributeLoaderComment(&$script, Column $col)
- {
- $clo = strtolower($col->getName());
- $script .= "
- /**
- * Whether the lazy-loaded \$$clo value has been loaded from database.
- * This is necessary to avoid repeated lookups if \$$clo column is NULL in the db.
- * @var boolean
- */";
- }
- /**
- * Adds the declaration of the attribute keeping track of an attribute's loaded state
- * @param string &$script The script will be modified in this method.
- * @param Column $col
- **/
- protected function addColumnAttributeLoaderDeclaration(&$script, Column $col)
- {
- $clo = strtolower($col->getName());
- $script .= "
- protected \$".$clo."_isLoaded = false;
- ";
- }
- /**
- * Adds the comment about the serialized attribute
- * @param string &$script The script will be modified in this method.
- * @param Column $col
- **/
- protected function addColumnAttributeUnserializedComment(&$script, Column $col)
- {
- $clo = strtolower($col->getName());
- $script .= "
- /**
- * The unserialized \$$clo value - i.e. the persisted object.
- * This is necessary to avoid repeated calls to unserialize() at runtime.
- * @var object
- */";
- }
- /**
- * Adds the declaration of the serialized attribute
- * @param string &$script The script will be modified in this method.
- * @param Column $col
- **/
- protected function addColumnAttributeUnserializedDeclaration(&$script, Column $col)
- {
- $clo = strtolower($col->getName()) . "_unserialized";
- $script .= "
- protected \$" . $clo . ";
- ";
- }
- /**
- * Adds the getPeer() method.
- * This is a convenient, non introspective way of getting the Peer class for a particular object.
- * @param string &$script The script will be modified in this method.
- */
- protected function addGetPeer(&$script)
- {
- $this->addGetPeerComment($script);
- $this->addGetPeerFunctionOpen($script);
- $this->addGetPeerFunctionBody($script);
- $this->addGetPeerFunctionClose($script);
- }
- /**
- * Add the comment for the getPeer method
- * @param string &$script The script will be modified in this method.
- **/
- protected function addGetPeerComment(&$script) {
- $script .= "
- /**
- * Returns a peer instance associated with this om.
- *
- * Since Peer classes are not to have any instance attributes, this method returns the
- * same instance for all member of this class. The method could therefore
- * be static, but this would prevent one from overriding the behavior.
- *
- * @return ".$this->getPeerClassname()."
- */";
- }
- /**
- * Adds the function declaration (function opening) for the getPeer method
- * @param string &$script The script will be modified in this method.
- **/
- protected function addGetPeerFunctionOpen(&$script) {
- $script .= "
- public function getPeer()
- {";
- }
- /**
- * Adds the body of the getPeer method
- * @param string &$script The script will be modified in this method.
- **/
- protected function addGetPeerFunctionBody(&$script) {
- $script .= "
- if (self::\$peer === null) {
- " . $this->buildObjectInstanceCreationCode('self::$peer', $this->getPeerClassname()) . "
- }
- return self::\$peer;";
- }
- /**
- * Add the function close for the getPeer method
- * Note: this is just a } and the body ends with a return statement, so it's quite useless. But it's here anyway for consisency, cause there's a close function for all functions and in some other instances, they are useful
- * @param string &$script The script will be modified in this method.
- **/
- protected function addGetPeerFunctionClose(&$script) {
- $script .= "
- }
- ";
- }
- /**
- * Adds the constructor for this object.
- * @param string &$script The script will be modified in this method.
- * @see addConstructor()
- */
- protected function addConstructor(&$script)
- {
- $this->addConstructorComment($script);
- $this->addConstructorOpen($script);
- $this->addConstructorBody($script);
- $this->addConstructorClose($script);
- }
- /**
- * Adds the comment for the constructor
- * @param string &$script The script will be modified in this method.
- **/
- protected function addConstructorComment(&$script) {
- $script .= "
- /**
- * Initializes internal state of ".$this->getClassname()." object.
- * @see applyDefaults()
- */";
- }
- /**
- * Adds the function declaration for the constructor
- * @param string &$script The script will be modified in this method.
- **/
- protected function addConstructorOpen(&$script) {
- $script .= "
- public function __construct()
- {";
- }
- /**
- * Adds the function body for the constructor
- * @param string &$script The script will be modified in this method.
- **/
- protected function addConstructorBody(&$script) {
- $script .= "
- parent::__construct();
- \$this->applyDefaultValues();";
- }
- /**
- * Adds the function close for the constructor
- * @param string &$script The script will be modified in this method.
- **/
- protected function addConstructorClose(&$script) {
- $script .= "
- }
- ";
- }
- /**
- * Adds the applyDefaults() method, which is called from the constructor.
- * @param string &$script The script will be modified in this method.
- * @see addConstructor()
- */
- protected function addApplyDefaultValues(&$script)
- {
- $this->addApplyDefaultValuesComment($script);
- $this->addApplyDefaultValuesOpen($script);
- $this->addApplyDefaultValuesBody($script);
- $this->addApplyDefaultValuesClose($script);
- }
- /**
- * Adds the comment for the applyDefaults method
- * @param string &$script The script will be modified in this method.
- * @see addApplyDefaultValues()
- **/
- protected function addApplyDefaultValuesComment(&$script) {
- $script .= "
- /**
- * Applies default values to this object.
- * This method should be called from the object's constructor (or
- * equivalent initialization method).
- * @see __construct()
- */";
- }
- /**
- * Adds the function declaration for the applyDefaults method
- * @param string &$script The script will be modified in this method.
- * @see addApplyDefaultValues()
- **/
- protected function addApplyDefaultValuesOpen(&$script) {
- $script .= "
- public function applyDefaultValues()
- {";
- }
- /**
- * Adds the function body of the applyDefault method
- * @param string &$script The script will be modified in this method.
- * @see addApplyDefaultValues()
- **/
- protected function addApplyDefaultValuesBody(&$script) {
- $table = $this->getTable();
- // FIXME - Apply support for PHP default expressions here
- // see: http://propel.phpdb.org/trac/ticket/378
- $colsWithDefaults = array();
- foreach ($table->getColumns() as $col) {
- $def = $col->getDefaultValue();
- if ($def !== null && !$def->isExpression()) {
- $colsWithDefaults[] = $col;
- }
- }
- $colconsts = array();
- foreach ($colsWithDefaults as $col) {
- $clo = strtolower($col->getName());
- $defaultValue = $this->getDefaultValueString($col);
- $script .= "
- \$this->".$clo." = $defaultValue;";
- }
- }
- /**
- * Adds the function close for the applyDefaults method
- * @param string &$script The script will be modified in this method.
- * @see addApplyDefaultValues()
- **/
- protected function addApplyDefaultValuesClose(&$script) {
- $script .= "
- }
- ";
- }
- // --------------------------------------------------------------
- //
- // A C C E S S O R M E T H O D S
- //
- // --------------------------------------------------------------
- /**
- * Adds a date/time/timestamp getter method.
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see parent::addColumnAccessors()
- */
- protected function addTemporalAccessor(&$script, Column $col)
- {
- $this->addTemporalAccessorComment($script, $col);
- $this->addTemporalAccessorOpen($script, $col);
- $this->addTemporalAccessorBody($script, $col);
- $this->addTemporalAccessorClose($script, $col);
- } // addTemporalAccessor
- /**
- * Adds the comment for a temporal accessor
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see addTemporalAccessor
- **/
- public function addTemporalAccessorComment(&$script, Column $col) {
- $clo = strtolower($col->getName());
- $useDateTime = $this->getBuildProperty('useDateTimeClass');
- $dateTimeClass = $this->getBuildProperty('dateTimeClass');
- if (!$dateTimeClass) {
- $dateTimeClass = 'DateTime';
- }
- $handleMysqlDate = false;
- if ($this->getPlatform() instanceof MysqlPlatform) {
- if ($col->getType() === PropelTypes::TIMESTAMP) {
- $handleMysqlDate = true;
- $mysqlInvalidDateString = '0000-00-00 00:00:00';
- } elseif ($col->getType() === PropelTypes::DATE) {
- $handleMysqlDate = true;
- $mysqlInvalidDateString = '0000-00-00';
- }
- // 00:00:00 is a valid time, so no need to check for that.
- }
- $script .= "
- /**
- * Get the [optionally formatted] temporal [$clo] column value.
- * ".$col->getDescription();
- if (!$useDateTime) {
- $script .= "
- * This accessor only only work with unix epoch dates. Consider enabling the propel.useDateTimeClass
- * option in order to avoid converstions to integers (which are limited in the dates they can express).";
- }
- $script .= "
- *
- * @param string \$format The date/time format string (either date()-style or strftime()-style).
- * If format is NULL, then the raw ".($useDateTime ? 'DateTime object' : 'unix timestamp integer')." will be returned.";
- if ($useDateTime) {
- $script .= "
- * @return mixed Formatted date/time value as string or $dateTimeClass object (if format is NULL), NULL if column is NULL" .($handleMysqlDate ? ', and 0 if column value is ' . $mysqlInvalidDateString : '');
- } else {
- $script .= "
- * @return mixed Formatted date/time value as string or (integer) unix timestamp (if format is NULL), NULL if column is NULL".($handleMysqlDate ? ', and 0 if column value is ' . $mysqlInvalidDateString : '');
- }
- $script .= "
- * @throws PropelException - if unable to parse/validate the date/time value.
- */";
- }
- /**
- * Adds the function declaration for a temporal accessor
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see addTemporalAccessor
- **/
- public function addTemporalAccessorOpen(&$script, Column $col) {
- $cfc = $col->getPhpName();
- $defaultfmt = null;
- $visibility = $col->getAccessorVisibility();
- // Default date/time formatter strings are specified in build.properties
- if ($col->getType() === PropelTypes::DATE) {
- $defaultfmt = $this->getBuildProperty('defaultDateFormat');
- } elseif ($col->getType() === PropelTypes::TIME) {
- $defaultfmt = $this->getBuildProperty('defaultTimeFormat');
- } elseif ($col->getType() === PropelTypes::TIMESTAMP) {
- $defaultfmt = $this->getBuildProperty('defaultTimeStampFormat');
- }
- if (empty($defaultfmt)) { $defaultfmt = null; }
- $script .= "
- ".$visibility." function get$cfc(\$format = ".var_export($defaultfmt, true)."";
- if ($col->isLazyLoad()) $script .= ", \$con = null";
- $script .= ")
- {";
- }
-
- protected function getAccessorLazyLoadSnippet(Column $col)
- {
- if ($col->isLazyLoad()) {
- $clo = strtolower($col->getName());
- $defaultValueString = 'null';
- $def = $col->getDefaultValue();
- if ($def !== null && !$def->isExpression()) {
- $defaultValueString = $this->getDefaultValueString($col);
- }
- return "
- if (!\$this->{$clo}_isLoaded && \$this->{$clo} === {$defaultValueString} && !\$this->isNew()) {
- \$this->load{$col->getPhpName()}(\$con);
- }
- ";
- }
- }
- /**
- * Adds the body of the temporal accessor
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see addTemporalAccessor
- **/
- protected function addTemporalAccessorBody(&$script, Column $col) {
- $cfc = $col->getPhpName();
- $clo = strtolower($col->getName());
- $useDateTime = $this->getBuildProperty('useDateTimeClass');
- $dateTimeClass = $this->getBuildProperty('dateTimeClass');
- if (!$dateTimeClass) {
- $dateTimeClass = 'DateTime';
- }
- $this->declareClasses($dateTimeClass);
- $defaultfmt = null;
- // Default date/time formatter strings are specified in build.properties
- if ($col->getType() === PropelTypes::DATE) {
- $defaultfmt = $this->getBuildProperty('defaultDateFormat');
- } elseif ($col->getType() === PropelTypes::TIME) {
- $defaultfmt = $this->getBuildProperty('defaultTimeFormat');
- } elseif ($col->getType() === PropelTypes::TIMESTAMP) {
- $defaultfmt = $this->getBuildProperty('defaultTimeStampFormat');
- }
- if (empty($defaultfmt)) { $defaultfmt = null; }
- $handleMysqlDate = false;
- if ($this->getPlatform() instanceof MysqlPlatform) {
- if ($col->getType() === PropelTypes::TIMESTAMP) {
- $handleMysqlDate = true;
- $mysqlInvalidDateString = '0000-00-00 00:00:00';
- } elseif ($col->getType() === PropelTypes::DATE) {
- $handleMysqlDate = true;
- $mysqlInvalidDateString = '0000-00-00';
- }
- // 00:00:00 is a valid time, so no need to check for that.
- }
- if ($col->isLazyLoad()) {
- $script .= $this->getAccessorLazyLoadSnippet($col);
- }
- $script .= "
- if (\$this->$clo === null) {
- return null;
- }
- ";
- if ($handleMysqlDate) {
- $script .= "
- if (\$this->$clo === '$mysqlInvalidDateString') {
- // while technically this is not a default value of NULL,
- // this seems to be closest in meaning.
- return null;
- } else {
- try {
- \$dt = new $dateTimeClass(\$this->$clo);
- } catch (Exception \$x) {
- throw new PropelException(\"Internally stored date/time/timestamp value could not be converted to $dateTimeClass: \" . var_export(\$this->$clo, true), \$x);
- }
- }
- ";
- } else {
- $script .= "
- try {
- \$dt = new $dateTimeClass(\$this->$clo);
- } catch (Exception \$x) {
- throw new PropelException(\"Internally stored date/time/timestamp value could not be converted to $dateTimeClass: \" . var_export(\$this->$clo, true), \$x);
- }
- ";
- } // if handleMyqlDate
- $script .= "
- if (\$format === null) {";
- if ($useDateTime) {
- $script .= "
- // Because propel.useDateTimeClass is TRUE, we return a $dateTimeClass object.
- return \$dt;";
- } else {
- $script .= "
- // We cast here to maintain BC in API; obviously we will lose data if we're dealing with pre-/post-epoch dates.
- return (int) \$dt->format('U');";
- }
- $script .= "
- } elseif (strpos(\$format, '%') !== false) {
- return strftime(\$format, \$dt->format('U'));
- } else {
- return \$dt->format(\$format);
- }";
- }
- /**
- * Adds the body of the temporal accessor
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see addTemporalAccessorClose
- **/
- protected function addTemporalAccessorClose(&$script, Column $col) {
- $script .= "
- }
- ";
- }
- /**
- * Adds an object getter method.
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see parent::addColumnAccessors()
- */
- protected function addObjectAccessor(&$script, Column $col)
- {
- $this->addDefaultAccessorComment($script, $col);
- $this->addDefaultAccessorOpen($script, $col);
- $this->addObjectAccessorBody($script, $col);
- $this->addDefaultAccessorClose($script, $col);
- }
- /**
- * Adds the function body for an object accessor method
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see addDefaultAccessor()
- **/
- protected function addObjectAccessorBody(&$script, Column $col)
- {
- $cfc = $col->getPhpName();
- $clo = strtolower($col->getName());
- $cloUnserialized = $clo.'_unserialized';
- if ($col->isLazyLoad()) {
- $script .= $this->getAccessorLazyLoadSnippet($col);
- }
- $script .= "
- if (null == \$this->$cloUnserialized && null !== \$this->$clo) {
- \$this->$cloUnserialized = unserialize(\$this->$clo);
- }
- return \$this->$cloUnserialized;";
- }
- /**
- * Adds an array getter method.
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see parent::addColumnAccessors()
- */
- protected function addArrayAccessor(&$script, Column $col)
- {
- $this->addDefaultAccessorComment($script, $col);
- $this->addDefaultAccessorOpen($script, $col);
- $this->addArrayAccessorBody($script, $col);
- $this->addDefaultAccessorClose($script, $col);
- }
- /**
- * Adds the function body for an array accessor method
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see addDefaultAccessor()
- **/
- protected function addArrayAccessorBody(&$script, Column $col)
- {
- $cfc = $col->getPhpName();
- $clo = strtolower($col->getName());
- $cloUnserialized = $clo.'_unserialized';
- if ($col->isLazyLoad()) {
- $script .= $this->getAccessorLazyLoadSnippet($col);
- }
- $script .= "
- if (null === \$this->$cloUnserialized) {
- \$this->$cloUnserialized = array();
- }
- if (!\$this->$cloUnserialized && null !== \$this->$clo) {
- \$$cloUnserialized = substr(\$this->$clo, 2, -2);
- \$this->$cloUnserialized = \$$cloUnserialized ? explode(' | ', \$$cloUnserialized) : array();
- }
- return \$this->$cloUnserialized;";
- }
-
- /**
- * Adds an enum getter method.
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see parent::addColumnAccessors()
- */
- protected function addEnumAccessor(&$script, Column $col)
- {
- $this->addDefaultAccessorComment($script, $col);
- $this->addDefaultAccessorOpen($script, $col);
- $this->addEnumAccessorBody($script, $col);
- $this->addDefaultAccessorClose($script, $col);
- }
- /**
- * Adds the function body for an enum accessor method
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see addDefaultAccessor()
- **/
- protected function addEnumAccessorBody(&$script, Column $col)
- {
- $cfc = $col->getPhpName();
- $clo = strtolower($col->getName());
- if ($col->isLazyLoad()) {
- $script .= $this->getAccessorLazyLoadSnippet($col);
- }
- $script .= "
- if (null === \$this->$clo) {
- return null;
- }
- \$valueSet = " . $this->getPeerClassname() . "::getValueSet(" . $this->getColumnConstant($col) . ");
- if (!isset(\$valueSet[\$this->$clo])) {
- throw new PropelException('Unknown stored enum key: ' . \$this->$clo);
- }
- return \$valueSet[\$this->$clo];";
- }
-
- /**
- * Adds a tester method for an array column.
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- */
- protected function addHasArrayElement(&$script, Column $col)
- {
- $clo = strtolower($col->getName());
- $cfc = $col->getPhpName();
- $visibility = $col->getAccessorVisibility();
- $singularPhpName = rtrim($cfc, 's');
- $script .= "
- /**
- * Test the presence of a value in the [$clo] array column value.
- * @param mixed \$value
- * ".$col->getDescription();
- if ($col->isLazyLoad()) {
- $script .= "
- * @param PropelPDO An optional PropelPDO connection to use for fetching this lazy-loaded column.";
- }
- $script .= "
- * @return Boolean
- */
- $visibility function has$singularPhpName(\$value";
- if ($col->isLazyLoad()) $script .= ", PropelPDO \$con = null";
- $script .= ")
- {
- return in_array(\$value, \$this->get$cfc(";
- if ($col->isLazyLoad()) $script .= "\$con";
- $script .= "));
- } // has$singularPhpName()
- ";
- }
-
- /**
- * Adds a normal (non-temporal) getter method.
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see parent::addColumnAccessors()
- */
- protected function addDefaultAccessor(&$script, Column $col)
- {
- $this->addDefaultAccessorComment($script, $col);
- $this->addDefaultAccessorOpen($script, $col);
- $this->addDefaultAccessorBody($script, $col);
- $this->addDefaultAccessorClose($script, $col);
- }
- /**
- * Add the comment for a default accessor method (a getter)
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see addDefaultAccessor()
- **/
- public function addDefaultAccessorComment(&$script, Column $col) {
- $clo=strtolower($col->getName());
- $script .= "
- /**
- * Get the [$clo] column value.
- * ".$col->getDescription();
- if ($col->isLazyLoad()) {
- $script .= "
- * @param PropelPDO An optional PropelPDO connection to use for fetching this lazy-loaded column.";
- }
- $script .= "
- * @return ".$col->getPhpType()."
- */";
- }
- /**
- * Adds the function declaration for a default accessor
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see addDefaultAccessor()
- **/
- public function addDefaultAccessorOpen(&$script, Column $col) {
- $cfc = $col->getPhpName();
- $visibility = $col->getAccessorVisibility();
- $script .= "
- ".$visibility." function get$cfc(";
- if ($col->isLazyLoad()) $script .= "PropelPDO \$con = null";
- $script .= ")
- {";
- }
- /**
- * Adds the function body for a default accessor method
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see addDefaultAccessor()
- **/
- protected function addDefaultAccessorBody(&$script, Column $col) {
- $cfc = $col->getPhpName();
- $clo = strtolower($col->getName());
- if ($col->isLazyLoad()) {
- $script .= $this->getAccessorLazyLoadSnippet($col);
- }
- $script .= "
- return \$this->$clo;";
- }
- /**
- * Adds the function close for a default accessor method
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see addDefaultAccessor()
- **/
- protected function addDefaultAccessorClose(&$script, Column $col) {
- $script .= "
- }
- ";
- }
- /**
- * Adds the lazy loader method.
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see parent::addColumnAccessors()
- */
- protected function addLazyLoader(&$script, Column $col)
- {
- $this->addLazyLoaderComment($script, $col);
- $this->addLazyLoaderOpen($script, $col);
- $this->addLazyLoaderBody($script, $col);
- $this->addLazyLoaderClose($script, $col);
- }
- /**
- * Adds the comment for the lazy loader method
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see addLazyLoader()
- **/
- protected function addLazyLoaderComment(&$script, Column $col) {
- $clo = strtolower($col->getName());
- $script .= "
- /**
- * Load the value for the lazy-loaded [$clo] column.
- *
- * This method performs an additional query to return the value for
- * the [$clo] column, since it is not populated by
- * the hydrate() method.
- *
- * @param \$con PropelPDO (optional) The PropelPDO connection to use.
- * @return void
- * @throws PropelException - any underlying error will be wrapped and re-thrown.
- */";
- }
- /**
- * Adds the function declaration for the lazy loader method
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see addLazyLoader()
- **/
- protected function addLazyLoaderOpen(&$script, Column $col) {
- $cfc = $col->getPhpName();
- $script .= "
- protected function load$cfc(PropelPDO \$con = null)
- {";
- }
- /**
- * Adds the function body for the lazy loader method
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see addLazyLoader()
- **/
- protected function addLazyLoaderBody(&$script, Column $col) {
- $platform = $this->getPlatform();
- $clo = strtolower($col->getName());
- // pdo_sqlsrv driver requires the use of PDOStatement::bindColumn() or a hex string will be returned
- if ($col->getType() === PropelTypes::BLOB && $platform instanceof SqlsrvPlatform) {
- $script .= "
- \$c = \$this->buildPkeyCriteria();
- \$c->addSelectColumn(".$this->getColumnConstant($col).");
- try {
- \$row = array(0 => null);
- \$stmt = ".$this->getPeerClassname()."::doSelectStmt(\$c, \$con);
- \$stmt->bindColumn(1, \$row[0], PDO::PARAM_LOB, 0, PDO::SQLSRV_ENCODING_BINARY);
- \$stmt->fetch(PDO::FETCH_BOUND);
- \$stmt->closeCursor();";
- } else {
- $script .= "
- \$c = \$this->buildPkeyCriteria();
- \$c->addSelectColumn(".$this->getColumnConstant($col).");
- try {
- \$stmt = ".$this->getPeerClassname()."::doSelectStmt(\$c, \$con);
- \$row = \$stmt->fetch(PDO::FETCH_NUM);
- \$stmt->closeCursor();";
- }
- if ($col->getType() === PropelTypes::CLOB && $platform instanceof OraclePlatform) {
- // PDO_OCI returns a stream for CLOB objects, while other PDO adapters return a string...
- $script .= "
- \$this->$clo = stream_get_contents(\$row[0]);";
- } elseif ($col->isLobType() && !$platform->hasStreamBlobImpl()) {
- $script .= "
- if (\$row[0] !== null) {
- \$this->$clo = fopen('php://memory', 'r+');
- fwrite(\$this->$clo, \$row[0]);
- rewind(\$this->$clo);
- } else {
- \$this->$clo = null;
- }";
- } elseif ($col->isPhpPrimitiveType()) {
- $script .= "
- \$this->$clo = (\$row[0] !== null) ? (".$col->getPhpType().") \$row[0] : null;";
- } elseif ($col->isPhpObjectType()) {
- $script .= "
- \$this->$clo = (\$row[0] !== null) ? new ".$col->getPhpType()."(\$row[0]) : null;";
- } else {
- $script .= "
- \$this->$clo = \$row[0];";
- }
- $script .= "
- \$this->".$clo."_isLoaded = true;
- } catch (Exception \$e) {
- throw new PropelException(\"Error loading value for [$clo] column on demand.\", \$e);
- }";
- }
- /**
- * Adds the function close for the lazy loader
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see addLazyLoader()
- **/
- protected function addLazyLoaderClose(&$script, Column $col) {
- $script .= "
- }";
- } // addLazyLoader()
- // --------------------------------------------------------------
- //
- // M U T A T O R M E T H O D S
- //
- // --------------------------------------------------------------
- /**
- * Adds the open of the mutator (setter) method for a column.
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- */
- protected function addMutatorOpen(&$script, Column $col)
- {
- $this->addMutatorComment($script, $col);
- $this->addMutatorOpenOpen($script, $col);
- $this->addMutatorOpenBody($script, $col);
- }
- /**
- * Adds the comment for a mutator
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see addMutatorOpen()
- **/
- public function addMutatorComment(&$script, Column $col) {
- $clo = strtolower($col->getName());
- $script .= "
- /**
- * Set the value of [$clo] column.
- * ".$col->getDescription()."
- * @param ".$col->getPhpType()." \$v new value
- * @return ".$this->getObjectClassname()." The current object (for fluent API support)
- */";
- }
- /**
- * Adds the mutator function declaration
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see addMutatorOpen()
- **/
- public function addMutatorOpenOpen(&$script, Column $col) {
- $cfc = $col->getPhpName();
- $visibility = $col->getMutatorVisibility();
- $script .= "
- ".$visibility." function set$cfc(\$v)
- {";
- }
- /**
- * Adds the mutator open body part
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see addMutatorOpen()
- **/
- protected function addMutatorOpenBody(&$script, Column $col)
- {
- $clo = strtolower($col->getName());
- $cfc = $col->getPhpName();
- if ($col->isLazyLoad()) {
- $script .= "
- // explicitly set the is-loaded flag to true for this lazy load col;
- // it doesn't matter if the value is actually set or not (logic below) as
- // any attempt to set the value means that no db lookup should be performed
- // when the get$cfc() method is called.
- \$this->".$clo."_isLoaded = true;
- ";
- }
- }
- /**
- * Adds the close of the mutator (setter) method for a column.
- *
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- */
- protected function addMutatorClose(&$script, Column $col)
- {
- $this->addMutatorCloseBody($script, $col);
- $this->addMutatorCloseClose($script, $col);
- }
- /**
- * Adds the body of the close part of a mutator
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see addMutatorClose()
- **/
- protected function addMutatorCloseBody(&$script, Column $col) {
- $table = $this->getTable();
- $cfc = $col->getPhpName();
- $clo = strtolower($col->getName());
- if ($col->isForeignKey()) {
- foreach ($col->getForeignKeys() as $fk) {
- $tblFK = $table->getDatabase()->getTable($fk->getForeignTableName());
- $colFK = $tblFK->getColumn($fk->getMappedForeignColumn($col->getName()));
- $varName = $this->getFKVarName($fk);
- $script .= "
- if (\$this->$varName !== null && \$this->".$varName."->get".$colFK->getPhpName()."() !== \$v) {
- \$this->$varName = null;
- }
- ";
- } // foreach fk
- } /* if col is foreign key */
- foreach ($col->getReferrers() as $refFK) {
- $tblFK = $this->getDatabase()->getTable($refFK->getForeignTableName());
- if ( $tblFK->getName() != $table->getName() ) {
- foreach ($col->getForeignKeys() as $fk) {
- $tblFK = $table->getDatabase()->getTable($fk->getForeignTableName());
- $colFK = $tblFK->getColumn($fk->getMappedForeignColumn($col->getName()));
- if ($refFK->isLocalPrimaryKey()) {
- $varName = $this->getPKRefFKVarName($refFK);
- $script .= "
- // update associated ".$tblFK->getPhpName()."
- if (\$this->$varName !== null) {
- \$this->{$varName}->set".$colFK->getPhpName()."(\$v);
- }
- ";
- } else {
- $collName = $this->getRefFKCollVarName($refFK);
- $script .= "
- // update associated ".$tblFK->getPhpName()."
- if (\$this->$collName !== null) {
- foreach (\$this->$collName as \$referrerObject) {
- \$referrerObject->set".$colFK->getPhpName()."(\$v);
- }
- }
- ";
- } // if (isLocalPrimaryKey
- } // foreach col->getPrimaryKeys()
- } // if tablFk != table
- } // foreach
- }
- /**
- * Adds the close for the mutator close
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see addMutatorClose()
- **/
- protected function addMutatorCloseClose(&$script, Column $col) {
- $cfc = $col->getPhpName();
- $script .= "
- return \$this;
- } // set$cfc()
- ";
- }
- /**
- * Adds a setter for BLOB columns.
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see parent::addColumnMutators()
- */
- protected function addLobMutator(&$script, Column $col)
- {
- $this->addMutatorOpen($script, $col);
- $clo = strtolower($col->getName());
- $script .= "
- // Because BLOB columns are streams in PDO we have to assume that they are
- // always modified when a new value is passed in. For example, the contents
- // of the stream itself may have changed externally.
- if (!is_resource(\$v) && \$v !== null) {
- \$this->$clo = fopen('php://memory', 'r+');
- fwrite(\$this->$clo, \$v);
- rewind(\$this->$clo);
- } else { // it's already a stream
- \$this->$clo = \$v;
- }
- \$this->modifiedColumns[] = ".$this->getColumnConstant($col).";
- ";
- $this->addMutatorClose($script, $col);
- } // addLobMutatorSnippet
- /**
- * Adds a setter method for date/time/timestamp columns.
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see parent::addColumnMutators()
- */
- protected function addTemporalMutator(&$script, Column $col)
- {
- $cfc = $col->getPhpName();
- $clo = strtolower($col->getName());
- $visibility = $col->getMutatorVisibility();
- $dateTimeClass = $this->getBuildProperty('dateTimeClass');
- if (!$dateTimeClass) {
- $dateTimeClass = 'DateTime';
- }
- $this->declareClasses($dateTimeClass, 'DateTimeZone', 'PropelDateTime');
- $this->addTemporalMutatorComment($script, $col);
- $this->addMutatorOpenOpen($script, $col);
- $this->addMutatorOpenBody($script, $col);
- $fmt = var_export($this->getTemporalFormatter($col), true);
- $script .= "
- \$dt = PropelDateTime::newInstance(\$v, null, '$dateTimeClass');
- if (\$this->$clo !== null || \$dt !== null) {
- \$currentDateAsString = (\$this->$clo !== null && \$tmpDt = new $dateTimeClass(\$this->$clo)) ? \$tmpDt->format($fmt) : null;
- \$newDateAsString = \$dt ? \$dt->format($fmt) : null;";
- if (($def = $col->getDefaultValue()) !== null && !$def->isExpression()) {
- $defaultValue = $this->getDefaultValueString($col);
- $script .= "
- if ( (\$currentDateAsString !== \$newDateAsString) // normalized values don't match
- || (\$dt->format($fmt) === $defaultValue) // or the entered value matches the default
- ) {";
- } else {
- $script .= "
- if (\$currentDateAsString !== \$newDateAsString) {";
- }
- $script .= "
- \$this->$clo = \$newDateAsString;
- \$this->modifiedColumns[] = ".$this->getColumnConstant($col).";
- }
- } // if either are not null
- ";
- $this->addMutatorClose($script, $col);
- }
- public function addTemporalMutatorComment(&$script, Column $col)
- {
- $cfc = $col->getPhpName();
- $clo = strtolower($col->getName());
- $script .= "
- /**
- * Sets the value of [$clo] column to a normalized version of the date/time value specified.
- * ".$col->getDescription()."
- * @param mixed \$v string, integer (timestamp), or DateTime value.
- * Empty strings are treated as NULL.
- * @return ".$this->getObjectClassname()." The current object (for fluent API support)
- */";
- }
- /**
- * Adds a setter for Object columns.
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see parent::addColumnMutators()
- */
- protected function addObjectMutator(&$script, Column $col)
- {
- $clo = strtolower($col->getName());
- $cloUnserialized = $clo.'_unserialized';
- $this->addMutatorOpen($script, $col);
- $script .= "
- if (\$this->$cloUnserialized !== \$v";
- if (($def = $col->getDefaultValue()) !== null && !$def->isExpression()) {
- $script .= " || \$this->isNew()";
- }
- $script .= ") {
- \$this->$cloUnserialized = \$v;
- \$this->$clo = serialize(\$v);
- \$this->modifiedColumns[] = ".$this->getColumnConstant($col).";
- }
- ";
- $this->addMutatorClose($script, $col);
- }
- /**
- * Adds a setter for Array columns.
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see parent::addColumnMutators()
- */
- protected function addArrayMutator(&$script, Column $col)
- {
- $clo = strtolower($col->getName());
- $cloUnserialized = $clo.'_unserialized';
- $this->addMutatorOpen($script, $col);
- $script .= "
- if (\$this->$cloUnserialized !== \$v";
- if (($def = $col->getDefaultValue()) !== null && !$def->isExpression()) {
- $script .= " || \$this->isNew()";
- }
- $script .= ") {
- \$this->$cloUnserialized = \$v;
- \$this->$clo = '| ' . implode(' | ', \$v) . ' |';
- \$this->modifiedColumns[] = ".$this->getColumnConstant($col).";
- }
- ";
- $this->addMutatorClose($script, $col);
- }
- /**
- * Adds a push method for an array column.
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- */
- protected function addAddArrayElement(&$script, Column $col)
- {
- $clo = strtolower($col->getName());
- $cfc = $col->getPhpName();
- $visibility = $col->getAccessorVisibility();
- $singularPhpName = rtrim($cfc, 's');
- $script .= "
- /**
- * Adds a value to the [$clo] array column value.
- * @param mixed \$value
- * ".$col->getDescription();
- if ($col->isLazyLoad()) {
- $script .= "
- * @param PropelPDO An optional PropelPDO connection to use for fetching this lazy-loaded column.";
- }
- $script .= "
- * @return ".$this->getObjectClassname()." The current object (for fluent API support)
- */
- $visibility function add$singularPhpName(\$value";
- if ($col->isLazyLoad()) $script .= ", PropelPDO \$con = null";
- $script .= ")
- {
- \$currentArray = \$this->get$cfc(";
- if ($col->isLazyLoad()) $script .= "\$con";
- $script .= ");
- \$currentArray []= \$value;
- \$this->set$cfc(\$currentArray);
-
- return \$this;
- } // add$singularPhpName()
- ";
- }
- /**
- * Adds a remove method for an array column.
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- */
- protected function addRemoveArrayElement(&$script, Column $col)
- {
- $clo = strtolower($col->getName());
- $cfc = $col->getPhpName();
- $visibility = $col->getAccessorVisibility();
- $singularPhpName = rtrim($cfc, 's');
- $script .= "
- /**
- * Removes a value from the [$clo] array …
Large files files are truncated, but you can click here to view the full file