Overview

Namespaces

  • Thelia
    • Action
    • Config
    • Controller
    • Core
      • Bundle
      • DependencyInjection
        • Compiler
        • Loader
      • Event
      • EventListener
      • Template
        • BaseParam
    • Exception
    • Log
      • Destination
    • Model
      • map
      • om
    • Routing
      • Matcher
    • Tools
    • Tpex
      • BaseParam
      • Element
        • Loop
        • TestLoop
      • Event
      • Exception
      • Filter
      • Tokenizer

Classes

  • BaseAccessory
  • BaseAccessoryPeer
  • BaseAccessoryQuery
  • BaseAddress
  • BaseAddressPeer
  • BaseAddressQuery
  • BaseAdmin
  • BaseAdminGroup
  • BaseAdminGroupPeer
  • BaseAdminGroupQuery
  • BaseAdminLog
  • BaseAdminLogPeer
  • BaseAdminLogQuery
  • BaseAdminPeer
  • BaseAdminQuery
  • BaseArea
  • BaseAreaPeer
  • BaseAreaQuery
  • BaseAttribute
  • BaseAttributeAv
  • BaseAttributeAvI18n
  • BaseAttributeAvI18nPeer
  • BaseAttributeAvI18nQuery
  • BaseAttributeAvPeer
  • BaseAttributeAvQuery
  • BaseAttributeCategory
  • BaseAttributeCategoryPeer
  • BaseAttributeCategoryQuery
  • BaseAttributeCombination
  • BaseAttributeCombinationPeer
  • BaseAttributeCombinationQuery
  • BaseAttributeI18n
  • BaseAttributeI18nPeer
  • BaseAttributeI18nQuery
  • BaseAttributePeer
  • BaseAttributeQuery
  • BaseCategory
  • BaseCategoryI18n
  • BaseCategoryI18nPeer
  • BaseCategoryI18nQuery
  • BaseCategoryPeer
  • BaseCategoryQuery
  • BaseCategoryVersion
  • BaseCategoryVersionPeer
  • BaseCategoryVersionQuery
  • BaseCombination
  • BaseCombinationPeer
  • BaseCombinationQuery
  • BaseConfig
  • BaseConfigI18n
  • BaseConfigI18nPeer
  • BaseConfigI18nQuery
  • BaseConfigPeer
  • BaseConfigQuery
  • BaseContent
  • BaseContentAssoc
  • BaseContentAssocPeer
  • BaseContentAssocQuery
  • BaseContentFolder
  • BaseContentFolderPeer
  • BaseContentFolderQuery
  • BaseContentI18n
  • BaseContentI18nPeer
  • BaseContentI18nQuery
  • BaseContentPeer
  • BaseContentQuery
  • BaseContentVersion
  • BaseContentVersionPeer
  • BaseContentVersionQuery
  • BaseCountry
  • BaseCountryI18n
  • BaseCountryI18nPeer
  • BaseCountryI18nQuery
  • BaseCountryPeer
  • BaseCountryQuery
  • BaseCoupon
  • BaseCouponOrder
  • BaseCouponOrderPeer
  • BaseCouponOrderQuery
  • BaseCouponPeer
  • BaseCouponQuery
  • BaseCouponRule
  • BaseCouponRulePeer
  • BaseCouponRuleQuery
  • BaseCurrency
  • BaseCurrencyPeer
  • BaseCurrencyQuery
  • BaseCustomer
  • BaseCustomerPeer
  • BaseCustomerQuery
  • BaseCustomerTitle
  • BaseCustomerTitleI18n
  • BaseCustomerTitleI18nPeer
  • BaseCustomerTitleI18nQuery
  • BaseCustomerTitlePeer
  • BaseCustomerTitleQuery
  • BaseDelivzone
  • BaseDelivzonePeer
  • BaseDelivzoneQuery
  • BaseDocument
  • BaseDocumentI18n
  • BaseDocumentI18nPeer
  • BaseDocumentI18nQuery
  • BaseDocumentPeer
  • BaseDocumentQuery
  • BaseFeature
  • BaseFeatureAv
  • BaseFeatureAvI18n
  • BaseFeatureAvI18nPeer
  • BaseFeatureAvI18nQuery
  • BaseFeatureAvPeer
  • BaseFeatureAvQuery
  • BaseFeatureCategory
  • BaseFeatureCategoryPeer
  • BaseFeatureCategoryQuery
  • BaseFeatureI18n
  • BaseFeatureI18nPeer
  • BaseFeatureI18nQuery
  • BaseFeaturePeer
  • BaseFeatureProd
  • BaseFeatureProdPeer
  • BaseFeatureProdQuery
  • BaseFeatureQuery
  • BaseFolder
  • BaseFolderI18n
  • BaseFolderI18nPeer
  • BaseFolderI18nQuery
  • BaseFolderPeer
  • BaseFolderQuery
  • BaseFolderVersion
  • BaseFolderVersionPeer
  • BaseFolderVersionQuery
  • BaseGroup
  • BaseGroupI18n
  • BaseGroupI18nPeer
  • BaseGroupI18nQuery
  • BaseGroupModule
  • BaseGroupModulePeer
  • BaseGroupModuleQuery
  • BaseGroupPeer
  • BaseGroupQuery
  • BaseGroupResource
  • BaseGroupResourcePeer
  • BaseGroupResourceQuery
  • BaseImage
  • BaseImageI18n
  • BaseImageI18nPeer
  • BaseImageI18nQuery
  • BaseImagePeer
  • BaseImageQuery
  • BaseLang
  • BaseLangPeer
  • BaseLangQuery
  • BaseMessage
  • BaseMessageI18n
  • BaseMessageI18nPeer
  • BaseMessageI18nQuery
  • BaseMessagePeer
  • BaseMessageQuery
  • BaseMessageVersion
  • BaseMessageVersionPeer
  • BaseMessageVersionQuery
  • BaseModule
  • BaseModuleI18n
  • BaseModuleI18nPeer
  • BaseModuleI18nQuery
  • BaseModulePeer
  • BaseModuleQuery
  • BaseOrder
  • BaseOrderAddress
  • BaseOrderAddressPeer
  • BaseOrderAddressQuery
  • BaseOrderFeature
  • BaseOrderFeaturePeer
  • BaseOrderFeatureQuery
  • BaseOrderPeer
  • BaseOrderProduct
  • BaseOrderProductPeer
  • BaseOrderProductQuery
  • BaseOrderQuery
  • BaseOrderStatus
  • BaseOrderStatusI18n
  • BaseOrderStatusI18nPeer
  • BaseOrderStatusI18nQuery
  • BaseOrderStatusPeer
  • BaseOrderStatusQuery
  • BaseProduct
  • BaseProductCategory
  • BaseProductCategoryPeer
  • BaseProductCategoryQuery
  • BaseProductI18n
  • BaseProductI18nPeer
  • BaseProductI18nQuery
  • BaseProductPeer
  • BaseProductQuery
  • BaseProductVersion
  • BaseProductVersionPeer
  • BaseProductVersionQuery
  • BaseResource
  • BaseResourceI18n
  • BaseResourceI18nPeer
  • BaseResourceI18nQuery
  • BaseResourcePeer
  • BaseResourceQuery
  • BaseRewriting
  • BaseRewritingPeer
  • BaseRewritingQuery
  • BaseStock
  • BaseStockPeer
  • BaseStockQuery
  • BaseTax
  • BaseTaxI18n
  • BaseTaxI18nPeer
  • BaseTaxI18nQuery
  • BaseTaxPeer
  • BaseTaxQuery
  • BaseTaxRule
  • BaseTaxRuleCountry
  • BaseTaxRuleCountryPeer
  • BaseTaxRuleCountryQuery
  • BaseTaxRuleI18n
  • BaseTaxRuleI18nPeer
  • BaseTaxRuleI18nQuery
  • BaseTaxRulePeer
  • BaseTaxRuleQuery
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: 
  3: namespace Thelia\Model\om;
  4: 
  5: use \BaseObject;
  6: use \BasePeer;
  7: use \Criteria;
  8: use \Exception;
  9: use \PDO;
 10: use \Persistent;
 11: use \Propel;
 12: use \PropelException;
 13: use \PropelPDO;
 14: use Thelia\Model\TaxRule;
 15: use Thelia\Model\TaxRuleI18n;
 16: use Thelia\Model\TaxRuleI18nPeer;
 17: use Thelia\Model\TaxRuleI18nQuery;
 18: use Thelia\Model\TaxRuleQuery;
 19: 
 20: /**
 21:  * Base class that represents a row from the 'tax_rule_i18n' table.
 22:  *
 23:  *
 24:  *
 25:  * @package    propel.generator.Thelia.Model.om
 26:  */
 27: abstract class BaseTaxRuleI18n extends BaseObject implements Persistent
 28: {
 29:     /**
 30:      * Peer class name
 31:      */
 32:     const PEER = 'Thelia\\Model\\TaxRuleI18nPeer';
 33: 
 34:     /**
 35:      * The Peer class.
 36:      * Instance provides a convenient way of calling static methods on a class
 37:      * that calling code may not be able to identify.
 38:      * @var        TaxRuleI18nPeer
 39:      */
 40:     protected static $peer;
 41: 
 42:     /**
 43:      * The flag var to prevent infinit loop in deep copy
 44:      * @var       boolean
 45:      */
 46:     protected $startCopy = false;
 47: 
 48:     /**
 49:      * The value for the id field.
 50:      * @var        int
 51:      */
 52:     protected $id;
 53: 
 54:     /**
 55:      * The value for the locale field.
 56:      * Note: this column has a database default value of: 'en_US'
 57:      * @var        string
 58:      */
 59:     protected $locale;
 60: 
 61:     /**
 62:      * @var        TaxRule
 63:      */
 64:     protected $aTaxRule;
 65: 
 66:     /**
 67:      * Flag to prevent endless save loop, if this object is referenced
 68:      * by another object which falls in this transaction.
 69:      * @var        boolean
 70:      */
 71:     protected $alreadyInSave = false;
 72: 
 73:     /**
 74:      * Flag to prevent endless validation loop, if this object is referenced
 75:      * by another object which falls in this transaction.
 76:      * @var        boolean
 77:      */
 78:     protected $alreadyInValidation = false;
 79: 
 80:     /**
 81:      * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced
 82:      * @var        boolean
 83:      */
 84:     protected $alreadyInClearAllReferencesDeep = false;
 85: 
 86:     /**
 87:      * Applies default values to this object.
 88:      * This method should be called from the object's constructor (or
 89:      * equivalent initialization method).
 90:      * @see        __construct()
 91:      */
 92:     public function applyDefaultValues()
 93:     {
 94:         $this->locale = 'en_US';
 95:     }
 96: 
 97:     /**
 98:      * Initializes internal state of BaseTaxRuleI18n object.
 99:      * @see        applyDefaults()
100:      */
101:     public function __construct()
102:     {
103:         parent::__construct();
104:         $this->applyDefaultValues();
105:     }
106: 
107:     /**
108:      * Get the [id] column value.
109:      *
110:      * @return int
111:      */
112:     public function getId()
113:     {
114:         return $this->id;
115:     }
116: 
117:     /**
118:      * Get the [locale] column value.
119:      *
120:      * @return string
121:      */
122:     public function getLocale()
123:     {
124:         return $this->locale;
125:     }
126: 
127:     /**
128:      * Set the value of [id] column.
129:      *
130:      * @param int $v new value
131:      * @return TaxRuleI18n The current object (for fluent API support)
132:      */
133:     public function setId($v)
134:     {
135:         if ($v !== null && is_numeric($v)) {
136:             $v = (int) $v;
137:         }
138: 
139:         if ($this->id !== $v) {
140:             $this->id = $v;
141:             $this->modifiedColumns[] = TaxRuleI18nPeer::ID;
142:         }
143: 
144:         if ($this->aTaxRule !== null && $this->aTaxRule->getId() !== $v) {
145:             $this->aTaxRule = null;
146:         }
147: 
148: 
149:         return $this;
150:     } // setId()
151: 
152:     /**
153:      * Set the value of [locale] column.
154:      *
155:      * @param string $v new value
156:      * @return TaxRuleI18n The current object (for fluent API support)
157:      */
158:     public function setLocale($v)
159:     {
160:         if ($v !== null && is_numeric($v)) {
161:             $v = (string) $v;
162:         }
163: 
164:         if ($this->locale !== $v) {
165:             $this->locale = $v;
166:             $this->modifiedColumns[] = TaxRuleI18nPeer::LOCALE;
167:         }
168: 
169: 
170:         return $this;
171:     } // setLocale()
172: 
173:     /**
174:      * Indicates whether the columns in this object are only set to default values.
175:      *
176:      * This method can be used in conjunction with isModified() to indicate whether an object is both
177:      * modified _and_ has some values set which are non-default.
178:      *
179:      * @return boolean Whether the columns in this object are only been set with default values.
180:      */
181:     public function hasOnlyDefaultValues()
182:     {
183:             if ($this->locale !== 'en_US') {
184:                 return false;
185:             }
186: 
187:         // otherwise, everything was equal, so return true
188:         return true;
189:     } // hasOnlyDefaultValues()
190: 
191:     /**
192:      * Hydrates (populates) the object variables with values from the database resultset.
193:      *
194:      * An offset (0-based "start column") is specified so that objects can be hydrated
195:      * with a subset of the columns in the resultset rows.  This is needed, for example,
196:      * for results of JOIN queries where the resultset row includes columns from two or
197:      * more tables.
198:      *
199:      * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
200:      * @param int $startcol 0-based offset column which indicates which restultset column to start with.
201:      * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
202:      * @return int             next starting column
203:      * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
204:      */
205:     public function hydrate($row, $startcol = 0, $rehydrate = false)
206:     {
207:         try {
208: 
209:             $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
210:             $this->locale = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
211:             $this->resetModified();
212: 
213:             $this->setNew(false);
214: 
215:             if ($rehydrate) {
216:                 $this->ensureConsistency();
217:             }
218:             $this->postHydrate($row, $startcol, $rehydrate);
219:             return $startcol + 2; // 2 = TaxRuleI18nPeer::NUM_HYDRATE_COLUMNS.
220: 
221:         } catch (Exception $e) {
222:             throw new PropelException("Error populating TaxRuleI18n object", $e);
223:         }
224:     }
225: 
226:     /**
227:      * Checks and repairs the internal consistency of the object.
228:      *
229:      * This method is executed after an already-instantiated object is re-hydrated
230:      * from the database.  It exists to check any foreign keys to make sure that
231:      * the objects related to the current object are correct based on foreign key.
232:      *
233:      * You can override this method in the stub class, but you should always invoke
234:      * the base method from the overridden method (i.e. parent::ensureConsistency()),
235:      * in case your model changes.
236:      *
237:      * @throws PropelException
238:      */
239:     public function ensureConsistency()
240:     {
241: 
242:         if ($this->aTaxRule !== null && $this->id !== $this->aTaxRule->getId()) {
243:             $this->aTaxRule = null;
244:         }
245:     } // ensureConsistency
246: 
247:     /**
248:      * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
249:      *
250:      * This will only work if the object has been saved and has a valid primary key set.
251:      *
252:      * @param boolean $deep (optional) Whether to also de-associated any related objects.
253:      * @param PropelPDO $con (optional) The PropelPDO connection to use.
254:      * @return void
255:      * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
256:      */
257:     public function reload($deep = false, PropelPDO $con = null)
258:     {
259:         if ($this->isDeleted()) {
260:             throw new PropelException("Cannot reload a deleted object.");
261:         }
262: 
263:         if ($this->isNew()) {
264:             throw new PropelException("Cannot reload an unsaved object.");
265:         }
266: 
267:         if ($con === null) {
268:             $con = Propel::getConnection(TaxRuleI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ);
269:         }
270: 
271:         // We don't need to alter the object instance pool; we're just modifying this instance
272:         // already in the pool.
273: 
274:         $stmt = TaxRuleI18nPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
275:         $row = $stmt->fetch(PDO::FETCH_NUM);
276:         $stmt->closeCursor();
277:         if (!$row) {
278:             throw new PropelException('Cannot find matching row in the database to reload object values.');
279:         }
280:         $this->hydrate($row, 0, true); // rehydrate
281: 
282:         if ($deep) {  // also de-associate any related objects?
283: 
284:             $this->aTaxRule = null;
285:         } // if (deep)
286:     }
287: 
288:     /**
289:      * Removes this object from datastore and sets delete attribute.
290:      *
291:      * @param PropelPDO $con
292:      * @return void
293:      * @throws PropelException
294:      * @throws Exception
295:      * @see        BaseObject::setDeleted()
296:      * @see        BaseObject::isDeleted()
297:      */
298:     public function delete(PropelPDO $con = null)
299:     {
300:         if ($this->isDeleted()) {
301:             throw new PropelException("This object has already been deleted.");
302:         }
303: 
304:         if ($con === null) {
305:             $con = Propel::getConnection(TaxRuleI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
306:         }
307: 
308:         $con->beginTransaction();
309:         try {
310:             $deleteQuery = TaxRuleI18nQuery::create()
311:                 ->filterByPrimaryKey($this->getPrimaryKey());
312:             $ret = $this->preDelete($con);
313:             if ($ret) {
314:                 $deleteQuery->delete($con);
315:                 $this->postDelete($con);
316:                 $con->commit();
317:                 $this->setDeleted(true);
318:             } else {
319:                 $con->commit();
320:             }
321:         } catch (Exception $e) {
322:             $con->rollBack();
323:             throw $e;
324:         }
325:     }
326: 
327:     /**
328:      * Persists this object to the database.
329:      *
330:      * If the object is new, it inserts it; otherwise an update is performed.
331:      * All modified related objects will also be persisted in the doSave()
332:      * method.  This method wraps all precipitate database operations in a
333:      * single transaction.
334:      *
335:      * @param PropelPDO $con
336:      * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
337:      * @throws PropelException
338:      * @throws Exception
339:      * @see        doSave()
340:      */
341:     public function save(PropelPDO $con = null)
342:     {
343:         if ($this->isDeleted()) {
344:             throw new PropelException("You cannot save an object that has been deleted.");
345:         }
346: 
347:         if ($con === null) {
348:             $con = Propel::getConnection(TaxRuleI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
349:         }
350: 
351:         $con->beginTransaction();
352:         $isInsert = $this->isNew();
353:         try {
354:             $ret = $this->preSave($con);
355:             if ($isInsert) {
356:                 $ret = $ret && $this->preInsert($con);
357:             } else {
358:                 $ret = $ret && $this->preUpdate($con);
359:             }
360:             if ($ret) {
361:                 $affectedRows = $this->doSave($con);
362:                 if ($isInsert) {
363:                     $this->postInsert($con);
364:                 } else {
365:                     $this->postUpdate($con);
366:                 }
367:                 $this->postSave($con);
368:                 TaxRuleI18nPeer::addInstanceToPool($this);
369:             } else {
370:                 $affectedRows = 0;
371:             }
372:             $con->commit();
373: 
374:             return $affectedRows;
375:         } catch (Exception $e) {
376:             $con->rollBack();
377:             throw $e;
378:         }
379:     }
380: 
381:     /**
382:      * Performs the work of inserting or updating the row in the database.
383:      *
384:      * If the object is new, it inserts it; otherwise an update is performed.
385:      * All related objects are also updated in this method.
386:      *
387:      * @param PropelPDO $con
388:      * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
389:      * @throws PropelException
390:      * @see        save()
391:      */
392:     protected function doSave(PropelPDO $con)
393:     {
394:         $affectedRows = 0; // initialize var to track total num of affected rows
395:         if (!$this->alreadyInSave) {
396:             $this->alreadyInSave = true;
397: 
398:             // We call the save method on the following object(s) if they
399:             // were passed to this object by their coresponding set
400:             // method.  This object relates to these object(s) by a
401:             // foreign key reference.
402: 
403:             if ($this->aTaxRule !== null) {
404:                 if ($this->aTaxRule->isModified() || $this->aTaxRule->isNew()) {
405:                     $affectedRows += $this->aTaxRule->save($con);
406:                 }
407:                 $this->setTaxRule($this->aTaxRule);
408:             }
409: 
410:             if ($this->isNew() || $this->isModified()) {
411:                 // persist changes
412:                 if ($this->isNew()) {
413:                     $this->doInsert($con);
414:                 } else {
415:                     $this->doUpdate($con);
416:                 }
417:                 $affectedRows += 1;
418:                 $this->resetModified();
419:             }
420: 
421:             $this->alreadyInSave = false;
422: 
423:         }
424: 
425:         return $affectedRows;
426:     } // doSave()
427: 
428:     /**
429:      * Insert the row in the database.
430:      *
431:      * @param PropelPDO $con
432:      *
433:      * @throws PropelException
434:      * @see        doSave()
435:      */
436:     protected function doInsert(PropelPDO $con)
437:     {
438:         $modifiedColumns = array();
439:         $index = 0;
440: 
441: 
442:          // check the columns in natural order for more readable SQL queries
443:         if ($this->isColumnModified(TaxRuleI18nPeer::ID)) {
444:             $modifiedColumns[':p' . $index++]  = '`id`';
445:         }
446:         if ($this->isColumnModified(TaxRuleI18nPeer::LOCALE)) {
447:             $modifiedColumns[':p' . $index++]  = '`locale`';
448:         }
449: 
450:         $sql = sprintf(
451:             'INSERT INTO `tax_rule_i18n` (%s) VALUES (%s)',
452:             implode(', ', $modifiedColumns),
453:             implode(', ', array_keys($modifiedColumns))
454:         );
455: 
456:         try {
457:             $stmt = $con->prepare($sql);
458:             foreach ($modifiedColumns as $identifier => $columnName) {
459:                 switch ($columnName) {
460:                     case '`id`':
461:                         $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
462:                         break;
463:                     case '`locale`':
464:                         $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR);
465:                         break;
466:                 }
467:             }
468:             $stmt->execute();
469:         } catch (Exception $e) {
470:             Propel::log($e->getMessage(), Propel::LOG_ERR);
471:             throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
472:         }
473: 
474:         $this->setNew(false);
475:     }
476: 
477:     /**
478:      * Update the row in the database.
479:      *
480:      * @param PropelPDO $con
481:      *
482:      * @see        doSave()
483:      */
484:     protected function doUpdate(PropelPDO $con)
485:     {
486:         $selectCriteria = $this->buildPkeyCriteria();
487:         $valuesCriteria = $this->buildCriteria();
488:         BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
489:     }
490: 
491:     /**
492:      * Array of ValidationFailed objects.
493:      * @var        array ValidationFailed[]
494:      */
495:     protected $validationFailures = array();
496: 
497:     /**
498:      * Gets any ValidationFailed objects that resulted from last call to validate().
499:      *
500:      *
501:      * @return array ValidationFailed[]
502:      * @see        validate()
503:      */
504:     public function getValidationFailures()
505:     {
506:         return $this->validationFailures;
507:     }
508: 
509:     /**
510:      * Validates the objects modified field values and all objects related to this table.
511:      *
512:      * If $columns is either a column name or an array of column names
513:      * only those columns are validated.
514:      *
515:      * @param mixed $columns Column name or an array of column names.
516:      * @return boolean Whether all columns pass validation.
517:      * @see        doValidate()
518:      * @see        getValidationFailures()
519:      */
520:     public function validate($columns = null)
521:     {
522:         $res = $this->doValidate($columns);
523:         if ($res === true) {
524:             $this->validationFailures = array();
525: 
526:             return true;
527:         }
528: 
529:         $this->validationFailures = $res;
530: 
531:         return false;
532:     }
533: 
534:     /**
535:      * This function performs the validation work for complex object models.
536:      *
537:      * In addition to checking the current object, all related objects will
538:      * also be validated.  If all pass then <code>true</code> is returned; otherwise
539:      * an aggreagated array of ValidationFailed objects will be returned.
540:      *
541:      * @param array $columns Array of column names to validate.
542:      * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
543:      */
544:     protected function doValidate($columns = null)
545:     {
546:         if (!$this->alreadyInValidation) {
547:             $this->alreadyInValidation = true;
548:             $retval = null;
549: 
550:             $failureMap = array();
551: 
552: 
553:             // We call the validate method on the following object(s) if they
554:             // were passed to this object by their coresponding set
555:             // method.  This object relates to these object(s) by a
556:             // foreign key reference.
557: 
558:             if ($this->aTaxRule !== null) {
559:                 if (!$this->aTaxRule->validate($columns)) {
560:                     $failureMap = array_merge($failureMap, $this->aTaxRule->getValidationFailures());
561:                 }
562:             }
563: 
564: 
565:             if (($retval = TaxRuleI18nPeer::doValidate($this, $columns)) !== true) {
566:                 $failureMap = array_merge($failureMap, $retval);
567:             }
568: 
569: 
570: 
571:             $this->alreadyInValidation = false;
572:         }
573: 
574:         return (!empty($failureMap) ? $failureMap : true);
575:     }
576: 
577:     /**
578:      * Retrieves a field from the object by name passed in as a string.
579:      *
580:      * @param string $name name
581:      * @param string $type The type of fieldname the $name is of:
582:      *               one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
583:      *               BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
584:      *               Defaults to BasePeer::TYPE_PHPNAME
585:      * @return mixed Value of field.
586:      */
587:     public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
588:     {
589:         $pos = TaxRuleI18nPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
590:         $field = $this->getByPosition($pos);
591: 
592:         return $field;
593:     }
594: 
595:     /**
596:      * Retrieves a field from the object by Position as specified in the xml schema.
597:      * Zero-based.
598:      *
599:      * @param int $pos position in xml schema
600:      * @return mixed Value of field at $pos
601:      */
602:     public function getByPosition($pos)
603:     {
604:         switch ($pos) {
605:             case 0:
606:                 return $this->getId();
607:                 break;
608:             case 1:
609:                 return $this->getLocale();
610:                 break;
611:             default:
612:                 return null;
613:                 break;
614:         } // switch()
615:     }
616: 
617:     /**
618:      * Exports the object as an array.
619:      *
620:      * You can specify the key type of the array by passing one of the class
621:      * type constants.
622:      *
623:      * @param     string  $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
624:      *                    BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
625:      *                    Defaults to BasePeer::TYPE_PHPNAME.
626:      * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
627:      * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
628:      * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
629:      *
630:      * @return array an associative array containing the field names (as keys) and field values
631:      */
632:     public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
633:     {
634:         if (isset($alreadyDumpedObjects['TaxRuleI18n'][serialize($this->getPrimaryKey())])) {
635:             return '*RECURSION*';
636:         }
637:         $alreadyDumpedObjects['TaxRuleI18n'][serialize($this->getPrimaryKey())] = true;
638:         $keys = TaxRuleI18nPeer::getFieldNames($keyType);
639:         $result = array(
640:             $keys[0] => $this->getId(),
641:             $keys[1] => $this->getLocale(),
642:         );
643:         if ($includeForeignObjects) {
644:             if (null !== $this->aTaxRule) {
645:                 $result['TaxRule'] = $this->aTaxRule->toArray($keyType, $includeLazyLoadColumns,  $alreadyDumpedObjects, true);
646:             }
647:         }
648: 
649:         return $result;
650:     }
651: 
652:     /**
653:      * Sets a field from the object by name passed in as a string.
654:      *
655:      * @param string $name peer name
656:      * @param mixed $value field value
657:      * @param string $type The type of fieldname the $name is of:
658:      *                     one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
659:      *                     BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
660:      *                     Defaults to BasePeer::TYPE_PHPNAME
661:      * @return void
662:      */
663:     public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
664:     {
665:         $pos = TaxRuleI18nPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
666: 
667:         $this->setByPosition($pos, $value);
668:     }
669: 
670:     /**
671:      * Sets a field from the object by Position as specified in the xml schema.
672:      * Zero-based.
673:      *
674:      * @param int $pos position in xml schema
675:      * @param mixed $value field value
676:      * @return void
677:      */
678:     public function setByPosition($pos, $value)
679:     {
680:         switch ($pos) {
681:             case 0:
682:                 $this->setId($value);
683:                 break;
684:             case 1:
685:                 $this->setLocale($value);
686:                 break;
687:         } // switch()
688:     }
689: 
690:     /**
691:      * Populates the object using an array.
692:      *
693:      * This is particularly useful when populating an object from one of the
694:      * request arrays (e.g. $_POST).  This method goes through the column
695:      * names, checking to see whether a matching key exists in populated
696:      * array. If so the setByName() method is called for that column.
697:      *
698:      * You can specify the key type of the array by additionally passing one
699:      * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
700:      * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
701:      * The default key type is the column's BasePeer::TYPE_PHPNAME
702:      *
703:      * @param array  $arr     An array to populate the object from.
704:      * @param string $keyType The type of keys the array uses.
705:      * @return void
706:      */
707:     public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
708:     {
709:         $keys = TaxRuleI18nPeer::getFieldNames($keyType);
710: 
711:         if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
712:         if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]);
713:     }
714: 
715:     /**
716:      * Build a Criteria object containing the values of all modified columns in this object.
717:      *
718:      * @return Criteria The Criteria object containing all modified values.
719:      */
720:     public function buildCriteria()
721:     {
722:         $criteria = new Criteria(TaxRuleI18nPeer::DATABASE_NAME);
723: 
724:         if ($this->isColumnModified(TaxRuleI18nPeer::ID)) $criteria->add(TaxRuleI18nPeer::ID, $this->id);
725:         if ($this->isColumnModified(TaxRuleI18nPeer::LOCALE)) $criteria->add(TaxRuleI18nPeer::LOCALE, $this->locale);
726: 
727:         return $criteria;
728:     }
729: 
730:     /**
731:      * Builds a Criteria object containing the primary key for this object.
732:      *
733:      * Unlike buildCriteria() this method includes the primary key values regardless
734:      * of whether or not they have been modified.
735:      *
736:      * @return Criteria The Criteria object containing value(s) for primary key(s).
737:      */
738:     public function buildPkeyCriteria()
739:     {
740:         $criteria = new Criteria(TaxRuleI18nPeer::DATABASE_NAME);
741:         $criteria->add(TaxRuleI18nPeer::ID, $this->id);
742:         $criteria->add(TaxRuleI18nPeer::LOCALE, $this->locale);
743: 
744:         return $criteria;
745:     }
746: 
747:     /**
748:      * Returns the composite primary key for this object.
749:      * The array elements will be in same order as specified in XML.
750:      * @return array
751:      */
752:     public function getPrimaryKey()
753:     {
754:         $pks = array();
755:         $pks[0] = $this->getId();
756:         $pks[1] = $this->getLocale();
757: 
758:         return $pks;
759:     }
760: 
761:     /**
762:      * Set the [composite] primary key.
763:      *
764:      * @param array $keys The elements of the composite key (order must match the order in XML file).
765:      * @return void
766:      */
767:     public function setPrimaryKey($keys)
768:     {
769:         $this->setId($keys[0]);
770:         $this->setLocale($keys[1]);
771:     }
772: 
773:     /**
774:      * Returns true if the primary key for this object is null.
775:      * @return boolean
776:      */
777:     public function isPrimaryKeyNull()
778:     {
779: 
780:         return (null === $this->getId()) && (null === $this->getLocale());
781:     }
782: 
783:     /**
784:      * Sets contents of passed object to values from current object.
785:      *
786:      * If desired, this method can also make copies of all associated (fkey referrers)
787:      * objects.
788:      *
789:      * @param object $copyObj An object of TaxRuleI18n (or compatible) type.
790:      * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
791:      * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
792:      * @throws PropelException
793:      */
794:     public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
795:     {
796:         $copyObj->setId($this->getId());
797:         $copyObj->setLocale($this->getLocale());
798: 
799:         if ($deepCopy && !$this->startCopy) {
800:             // important: temporarily setNew(false) because this affects the behavior of
801:             // the getter/setter methods for fkey referrer objects.
802:             $copyObj->setNew(false);
803:             // store object hash to prevent cycle
804:             $this->startCopy = true;
805: 
806:             //unflag object copy
807:             $this->startCopy = false;
808:         } // if ($deepCopy)
809: 
810:         if ($makeNew) {
811:             $copyObj->setNew(true);
812:         }
813:     }
814: 
815:     /**
816:      * Makes a copy of this object that will be inserted as a new row in table when saved.
817:      * It creates a new object filling in the simple attributes, but skipping any primary
818:      * keys that are defined for the table.
819:      *
820:      * If desired, this method can also make copies of all associated (fkey referrers)
821:      * objects.
822:      *
823:      * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
824:      * @return TaxRuleI18n Clone of current object.
825:      * @throws PropelException
826:      */
827:     public function copy($deepCopy = false)
828:     {
829:         // we use get_class(), because this might be a subclass
830:         $clazz = get_class($this);
831:         $copyObj = new $clazz();
832:         $this->copyInto($copyObj, $deepCopy);
833: 
834:         return $copyObj;
835:     }
836: 
837:     /**
838:      * Returns a peer instance associated with this om.
839:      *
840:      * Since Peer classes are not to have any instance attributes, this method returns the
841:      * same instance for all member of this class. The method could therefore
842:      * be static, but this would prevent one from overriding the behavior.
843:      *
844:      * @return TaxRuleI18nPeer
845:      */
846:     public function getPeer()
847:     {
848:         if (self::$peer === null) {
849:             self::$peer = new TaxRuleI18nPeer();
850:         }
851: 
852:         return self::$peer;
853:     }
854: 
855:     /**
856:      * Declares an association between this object and a TaxRule object.
857:      *
858:      * @param             TaxRule $v
859:      * @return TaxRuleI18n The current object (for fluent API support)
860:      * @throws PropelException
861:      */
862:     public function setTaxRule(TaxRule $v = null)
863:     {
864:         if ($v === null) {
865:             $this->setId(NULL);
866:         } else {
867:             $this->setId($v->getId());
868:         }
869: 
870:         $this->aTaxRule = $v;
871: 
872:         // Add binding for other direction of this n:n relationship.
873:         // If this object has already been added to the TaxRule object, it will not be re-added.
874:         if ($v !== null) {
875:             $v->addTaxRuleI18n($this);
876:         }
877: 
878: 
879:         return $this;
880:     }
881: 
882: 
883:     /**
884:      * Get the associated TaxRule object
885:      *
886:      * @param PropelPDO $con Optional Connection object.
887:      * @param $doQuery Executes a query to get the object if required
888:      * @return TaxRule The associated TaxRule object.
889:      * @throws PropelException
890:      */
891:     public function getTaxRule(PropelPDO $con = null, $doQuery = true)
892:     {
893:         if ($this->aTaxRule === null && ($this->id !== null) && $doQuery) {
894:             $this->aTaxRule = TaxRuleQuery::create()->findPk($this->id, $con);
895:             /* The following can be used additionally to
896:                 guarantee the related object contains a reference
897:                 to this object.  This level of coupling may, however, be
898:                 undesirable since it could result in an only partially populated collection
899:                 in the referenced object.
900:                 $this->aTaxRule->addTaxRuleI18ns($this);
901:              */
902:         }
903: 
904:         return $this->aTaxRule;
905:     }
906: 
907:     /**
908:      * Clears the current object and sets all attributes to their default values
909:      */
910:     public function clear()
911:     {
912:         $this->id = null;
913:         $this->locale = null;
914:         $this->alreadyInSave = false;
915:         $this->alreadyInValidation = false;
916:         $this->alreadyInClearAllReferencesDeep = false;
917:         $this->clearAllReferences();
918:         $this->applyDefaultValues();
919:         $this->resetModified();
920:         $this->setNew(true);
921:         $this->setDeleted(false);
922:     }
923: 
924:     /**
925:      * Resets all references to other model objects or collections of model objects.
926:      *
927:      * This method is a user-space workaround for PHP's inability to garbage collect
928:      * objects with circular references (even in PHP 5.3). This is currently necessary
929:      * when using Propel in certain daemon or large-volumne/high-memory operations.
930:      *
931:      * @param boolean $deep Whether to also clear the references on all referrer objects.
932:      */
933:     public function clearAllReferences($deep = false)
934:     {
935:         if ($deep && !$this->alreadyInClearAllReferencesDeep) {
936:             $this->alreadyInClearAllReferencesDeep = true;
937:             if ($this->aTaxRule instanceof Persistent) {
938:               $this->aTaxRule->clearAllReferences($deep);
939:             }
940: 
941:             $this->alreadyInClearAllReferencesDeep = false;
942:         } // if ($deep)
943: 
944:         $this->aTaxRule = null;
945:     }
946: 
947:     /**
948:      * return the string representation of this object
949:      *
950:      * @return string
951:      */
952:     public function __toString()
953:     {
954:         return (string) $this->exportTo(TaxRuleI18nPeer::DEFAULT_STRING_FORMAT);
955:     }
956: 
957:     /**
958:      * return true is the object is in saving state
959:      *
960:      * @return boolean
961:      */
962:     public function isAlreadyInSave()
963:     {
964:         return $this->alreadyInSave;
965:     }
966: 
967: }
968: 
thelia API documentation generated by ApiGen 2.8.0