Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Banners often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Banners, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
36 | abstract class Banners implements ActiveRecordInterface |
||
37 | { |
||
|
|||
38 | /** |
||
39 | * TableMap class name |
||
40 | */ |
||
41 | const TABLE_MAP = '\\xbanners\\models\\Map\\BannersTableMap'; |
||
42 | |||
43 | |||
44 | /** |
||
45 | * attribute to determine if this object has previously been saved. |
||
46 | * @var boolean |
||
47 | */ |
||
48 | protected $new = true; |
||
49 | |||
50 | /** |
||
51 | * attribute to determine whether this object has been deleted. |
||
52 | * @var boolean |
||
53 | */ |
||
54 | protected $deleted = false; |
||
55 | |||
56 | /** |
||
57 | * The columns that have been modified in current object. |
||
58 | * Tracking modified columns allows us to only update modified columns. |
||
59 | * @var array |
||
60 | */ |
||
61 | protected $modifiedColumns = array(); |
||
62 | |||
63 | /** |
||
64 | * The (virtual) columns that are added at runtime |
||
65 | * The formatters can add supplementary columns based on a resultset |
||
66 | * @var array |
||
67 | */ |
||
68 | protected $virtualColumns = array(); |
||
69 | |||
70 | /** |
||
71 | * The value for the id field. |
||
72 | * |
||
73 | * @var int |
||
74 | */ |
||
75 | protected $id; |
||
76 | |||
77 | /** |
||
78 | * The value for the place field. |
||
79 | * |
||
80 | * @var string |
||
81 | */ |
||
82 | protected $place; |
||
83 | |||
84 | /** |
||
85 | * The value for the width field. |
||
86 | * |
||
87 | * @var int |
||
88 | */ |
||
89 | protected $width; |
||
90 | |||
91 | /** |
||
92 | * The value for the height field. |
||
93 | * |
||
94 | * @var int |
||
95 | */ |
||
96 | protected $height; |
||
97 | |||
98 | /** |
||
99 | * The value for the effects field. |
||
100 | * |
||
101 | * @var string |
||
102 | */ |
||
103 | protected $effects; |
||
104 | |||
105 | /** |
||
106 | * The value for the page_type field. |
||
107 | * |
||
108 | * @var string |
||
109 | */ |
||
110 | protected $page_type; |
||
111 | |||
112 | /** |
||
113 | * @var ObjectCollection|ChildBannerImage[] Collection to store aggregation of ChildBannerImage objects. |
||
114 | */ |
||
115 | protected $collBannerImages; |
||
116 | protected $collBannerImagesPartial; |
||
117 | |||
118 | /** |
||
119 | * @var ObjectCollection|ChildBannersI18n[] Collection to store aggregation of ChildBannersI18n objects. |
||
120 | */ |
||
121 | protected $collBannersI18ns; |
||
122 | protected $collBannersI18nsPartial; |
||
123 | |||
124 | /** |
||
125 | * Flag to prevent endless save loop, if this object is referenced |
||
126 | * by another object which falls in this transaction. |
||
127 | * |
||
128 | * @var boolean |
||
129 | */ |
||
130 | protected $alreadyInSave = false; |
||
131 | |||
132 | // i18n behavior |
||
133 | |||
134 | /** |
||
135 | * Current locale |
||
136 | * @var string |
||
137 | */ |
||
138 | protected $currentLocale = 'ru'; |
||
139 | |||
140 | /** |
||
141 | * Current translation objects |
||
142 | * @var array[ChildBannersI18n] |
||
143 | */ |
||
144 | protected $currentTranslations; |
||
145 | |||
146 | /** |
||
147 | * An array of objects scheduled for deletion. |
||
148 | * @var ObjectCollection|ChildBannerImage[] |
||
149 | */ |
||
150 | protected $bannerImagesScheduledForDeletion = null; |
||
151 | |||
152 | /** |
||
153 | * An array of objects scheduled for deletion. |
||
154 | * @var ObjectCollection|ChildBannersI18n[] |
||
155 | */ |
||
156 | protected $bannersI18nsScheduledForDeletion = null; |
||
157 | |||
158 | /** |
||
159 | * Initializes internal state of xbanners\models\Base\Banners object. |
||
160 | */ |
||
161 | public function __construct() |
||
164 | |||
165 | /** |
||
166 | * Returns whether the object has been modified. |
||
167 | * |
||
168 | * @return boolean True if the object has been modified. |
||
169 | */ |
||
170 | public function isModified() |
||
174 | |||
175 | /** |
||
176 | * Has specified column been modified? |
||
177 | * |
||
178 | * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID |
||
179 | * @return boolean True if $col has been modified. |
||
180 | */ |
||
181 | public function isColumnModified($col) |
||
185 | |||
186 | /** |
||
187 | * Get the columns that have been modified in this object. |
||
188 | * @return array A unique list of the modified column names for this object. |
||
189 | */ |
||
190 | public function getModifiedColumns() |
||
194 | |||
195 | /** |
||
196 | * Returns whether the object has ever been saved. This will |
||
197 | * be false, if the object was retrieved from storage or was created |
||
198 | * and then saved. |
||
199 | * |
||
200 | * @return boolean true, if the object has never been persisted. |
||
201 | */ |
||
202 | public function isNew() |
||
206 | |||
207 | /** |
||
208 | * Setter for the isNew attribute. This method will be called |
||
209 | * by Propel-generated children and objects. |
||
210 | * |
||
211 | * @param boolean $b the state of the object. |
||
212 | */ |
||
213 | public function setNew($b) |
||
217 | |||
218 | /** |
||
219 | * Whether this object has been deleted. |
||
220 | * @return boolean The deleted state of this object. |
||
221 | */ |
||
222 | public function isDeleted() |
||
226 | |||
227 | /** |
||
228 | * Specify whether this object has been deleted. |
||
229 | * @param boolean $b The deleted state of this object. |
||
230 | * @return void |
||
231 | */ |
||
232 | public function setDeleted($b) |
||
236 | |||
237 | /** |
||
238 | * Sets the modified state for the object to be false. |
||
239 | * @param string $col If supplied, only the specified column is reset. |
||
240 | * @return void |
||
241 | */ |
||
242 | View Code Duplication | public function resetModified($col = null) |
|
252 | |||
253 | /** |
||
254 | * Compares this with another <code>Banners</code> instance. If |
||
255 | * <code>obj</code> is an instance of <code>Banners</code>, delegates to |
||
256 | * <code>equals(Banners)</code>. Otherwise, returns <code>false</code>. |
||
257 | * |
||
258 | * @param mixed $obj The object to compare to. |
||
259 | * @return boolean Whether equal to the object specified. |
||
260 | */ |
||
261 | View Code Duplication | public function equals($obj) |
|
277 | |||
278 | /** |
||
279 | * Get the associative array of the virtual columns in this object |
||
280 | * |
||
281 | * @return array |
||
282 | */ |
||
283 | public function getVirtualColumns() |
||
287 | |||
288 | /** |
||
289 | * Checks the existence of a virtual column in this object |
||
290 | * |
||
291 | * @param string $name The virtual column name |
||
292 | * @return boolean |
||
293 | */ |
||
294 | public function hasVirtualColumn($name) |
||
298 | |||
299 | /** |
||
300 | * Get the value of a virtual column in this object |
||
301 | * |
||
302 | * @param string $name The virtual column name |
||
303 | * @return mixed |
||
304 | * |
||
305 | * @throws PropelException |
||
306 | */ |
||
307 | View Code Duplication | public function getVirtualColumn($name) |
|
315 | |||
316 | /** |
||
317 | * Set the value of a virtual column in this object |
||
318 | * |
||
319 | * @param string $name The virtual column name |
||
320 | * @param mixed $value The value to give to the virtual column |
||
321 | * |
||
322 | * @return $this|Banners The current object, for fluid interface |
||
323 | */ |
||
324 | public function setVirtualColumn($name, $value) |
||
330 | |||
331 | /** |
||
332 | * Logs a message using Propel::log(). |
||
333 | * |
||
334 | * @param string $msg |
||
335 | * @param int $priority One of the Propel::LOG_* logging levels |
||
336 | * @return boolean |
||
337 | */ |
||
338 | protected function log($msg, $priority = Propel::LOG_INFO) |
||
342 | |||
343 | /** |
||
344 | * Export the current object properties to a string, using a given parser format |
||
345 | * <code> |
||
346 | * $book = BookQuery::create()->findPk(9012); |
||
347 | * echo $book->exportTo('JSON'); |
||
348 | * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
||
349 | * </code> |
||
350 | * |
||
351 | * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') |
||
352 | * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. |
||
353 | * @return string The exported data |
||
354 | */ |
||
355 | View Code Duplication | public function exportTo($parser, $includeLazyLoadColumns = true) |
|
363 | |||
364 | /** |
||
365 | * Clean up internal collections prior to serializing |
||
366 | * Avoids recursive loops that turn into segmentation faults when serializing |
||
367 | */ |
||
368 | View Code Duplication | public function __sleep() |
|
382 | |||
383 | /** |
||
384 | * Get the [id] column value. |
||
385 | * |
||
386 | * @return int |
||
387 | */ |
||
388 | public function getId() |
||
392 | |||
393 | /** |
||
394 | * Get the [place] column value. |
||
395 | * |
||
396 | * @return string |
||
397 | */ |
||
398 | public function getPlace() |
||
402 | |||
403 | /** |
||
404 | * Get the [width] column value. |
||
405 | * |
||
406 | * @return int |
||
407 | */ |
||
408 | public function getWidth() |
||
412 | |||
413 | /** |
||
414 | * Get the [height] column value. |
||
415 | * |
||
416 | * @return int |
||
417 | */ |
||
418 | public function getHeight() |
||
422 | |||
423 | /** |
||
424 | * Get the [effects] column value. |
||
425 | * |
||
426 | * @return string |
||
427 | */ |
||
428 | public function getEffects() |
||
432 | |||
433 | /** |
||
434 | * Get the [page_type] column value. |
||
435 | * |
||
436 | * @return string |
||
437 | */ |
||
438 | public function getPageType() |
||
442 | |||
443 | /** |
||
444 | * Set the value of [id] column. |
||
445 | * |
||
446 | * @param int $v new value |
||
447 | * @return $this|\xbanners\models\Banners The current object (for fluent API support) |
||
448 | */ |
||
449 | View Code Duplication | public function setId($v) |
|
462 | |||
463 | /** |
||
464 | * Set the value of [place] column. |
||
465 | * |
||
466 | * @param string $v new value |
||
467 | * @return $this|\xbanners\models\Banners The current object (for fluent API support) |
||
468 | */ |
||
469 | View Code Duplication | public function setPlace($v) |
|
482 | |||
483 | /** |
||
484 | * Set the value of [width] column. |
||
485 | * |
||
486 | * @param int $v new value |
||
487 | * @return $this|\xbanners\models\Banners The current object (for fluent API support) |
||
488 | */ |
||
489 | View Code Duplication | public function setWidth($v) |
|
502 | |||
503 | /** |
||
504 | * Set the value of [height] column. |
||
505 | * |
||
506 | * @param int $v new value |
||
507 | * @return $this|\xbanners\models\Banners The current object (for fluent API support) |
||
508 | */ |
||
509 | View Code Duplication | public function setHeight($v) |
|
522 | |||
523 | /** |
||
524 | * Set the value of [effects] column. |
||
525 | * |
||
526 | * @param string $v new value |
||
527 | * @return $this|\xbanners\models\Banners The current object (for fluent API support) |
||
528 | */ |
||
529 | View Code Duplication | public function setEffects($v) |
|
542 | |||
543 | /** |
||
544 | * Set the value of [page_type] column. |
||
545 | * |
||
546 | * @param string $v new value |
||
547 | * @return $this|\xbanners\models\Banners The current object (for fluent API support) |
||
548 | */ |
||
549 | View Code Duplication | public function setPageType($v) |
|
562 | |||
563 | /** |
||
564 | * Indicates whether the columns in this object are only set to default values. |
||
565 | * |
||
566 | * This method can be used in conjunction with isModified() to indicate whether an object is both |
||
567 | * modified _and_ has some values set which are non-default. |
||
568 | * |
||
569 | * @return boolean Whether the columns in this object are only been set with default values. |
||
570 | */ |
||
571 | public function hasOnlyDefaultValues() |
||
576 | |||
577 | /** |
||
578 | * Hydrates (populates) the object variables with values from the database resultset. |
||
579 | * |
||
580 | * An offset (0-based "start column") is specified so that objects can be hydrated |
||
581 | * with a subset of the columns in the resultset rows. This is needed, for example, |
||
582 | * for results of JOIN queries where the resultset row includes columns from two or |
||
583 | * more tables. |
||
584 | * |
||
585 | * @param array $row The row returned by DataFetcher->fetch(). |
||
586 | * @param int $startcol 0-based offset column which indicates which restultset column to start with. |
||
587 | * @param boolean $rehydrate Whether this object is being re-hydrated from the database. |
||
588 | * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
||
589 | One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
590 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
591 | * |
||
592 | * @return int next starting column |
||
593 | * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. |
||
594 | */ |
||
595 | View Code Duplication | public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) |
|
630 | |||
631 | /** |
||
632 | * Checks and repairs the internal consistency of the object. |
||
633 | * |
||
634 | * This method is executed after an already-instantiated object is re-hydrated |
||
635 | * from the database. It exists to check any foreign keys to make sure that |
||
636 | * the objects related to the current object are correct based on foreign key. |
||
637 | * |
||
638 | * You can override this method in the stub class, but you should always invoke |
||
639 | * the base method from the overridden method (i.e. parent::ensureConsistency()), |
||
640 | * in case your model changes. |
||
641 | * |
||
642 | * @throws PropelException |
||
643 | */ |
||
644 | public function ensureConsistency() |
||
647 | |||
648 | /** |
||
649 | * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. |
||
650 | * |
||
651 | * This will only work if the object has been saved and has a valid primary key set. |
||
652 | * |
||
653 | * @param boolean $deep (optional) Whether to also de-associated any related objects. |
||
654 | * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. |
||
655 | * @return void |
||
656 | * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db |
||
657 | */ |
||
658 | View Code Duplication | public function reload($deep = false, ConnectionInterface $con = null) |
|
691 | |||
692 | /** |
||
693 | * Removes this object from datastore and sets delete attribute. |
||
694 | * |
||
695 | * @param ConnectionInterface $con |
||
696 | * @return void |
||
697 | * @throws PropelException |
||
698 | * @see Banners::setDeleted() |
||
699 | * @see Banners::isDeleted() |
||
700 | */ |
||
701 | View Code Duplication | public function delete(ConnectionInterface $con = null) |
|
722 | |||
723 | /** |
||
724 | * Persists this object to the database. |
||
725 | * |
||
726 | * If the object is new, it inserts it; otherwise an update is performed. |
||
727 | * All modified related objects will also be persisted in the doSave() |
||
728 | * method. This method wraps all precipitate database operations in a |
||
729 | * single transaction. |
||
730 | * |
||
731 | * @param ConnectionInterface $con |
||
732 | * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
||
733 | * @throws PropelException |
||
734 | * @see doSave() |
||
735 | */ |
||
736 | View Code Duplication | public function save(ConnectionInterface $con = null) |
|
770 | |||
771 | /** |
||
772 | * Performs the work of inserting or updating the row in the database. |
||
773 | * |
||
774 | * If the object is new, it inserts it; otherwise an update is performed. |
||
775 | * All related objects are also updated in this method. |
||
776 | * |
||
777 | * @param ConnectionInterface $con |
||
778 | * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
||
779 | * @throws PropelException |
||
780 | * @see save() |
||
781 | */ |
||
782 | protected function doSave(ConnectionInterface $con) |
||
839 | |||
840 | /** |
||
841 | * Insert the row in the database. |
||
842 | * |
||
843 | * @param ConnectionInterface $con |
||
844 | * |
||
845 | * @throws PropelException |
||
846 | * @see doSave() |
||
847 | */ |
||
848 | protected function doInsert(ConnectionInterface $con) |
||
923 | |||
924 | /** |
||
925 | * Update the row in the database. |
||
926 | * |
||
927 | * @param ConnectionInterface $con |
||
928 | * |
||
929 | * @return Integer Number of updated rows |
||
930 | * @see doSave() |
||
931 | */ |
||
932 | protected function doUpdate(ConnectionInterface $con) |
||
939 | |||
940 | /** |
||
941 | * Retrieves a field from the object by name passed in as a string. |
||
942 | * |
||
943 | * @param string $name name |
||
944 | * @param string $type The type of fieldname the $name is of: |
||
945 | * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
946 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
947 | * Defaults to TableMap::TYPE_PHPNAME. |
||
948 | * @return mixed Value of field. |
||
949 | */ |
||
950 | View Code Duplication | public function getByName($name, $type = TableMap::TYPE_PHPNAME) |
|
957 | |||
958 | /** |
||
959 | * Retrieves a field from the object by Position as specified in the xml schema. |
||
960 | * Zero-based. |
||
961 | * |
||
962 | * @param int $pos position in xml schema |
||
963 | * @return mixed Value of field at $pos |
||
964 | */ |
||
965 | public function getByPosition($pos) |
||
991 | |||
992 | /** |
||
993 | * Exports the object as an array. |
||
994 | * |
||
995 | * You can specify the key type of the array by passing one of the class |
||
996 | * type constants. |
||
997 | * |
||
998 | * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
999 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
1000 | * Defaults to TableMap::TYPE_PHPNAME. |
||
1001 | * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. |
||
1002 | * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion |
||
1003 | * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. |
||
1004 | * |
||
1005 | * @return array an associative array containing the field names (as keys) and field values |
||
1006 | */ |
||
1007 | public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) |
||
1008 | { |
||
1009 | |||
1010 | if (isset($alreadyDumpedObjects['Banners'][$this->hashCode()])) { |
||
1011 | return '*RECURSION*'; |
||
1012 | } |
||
1013 | $alreadyDumpedObjects['Banners'][$this->hashCode()] = true; |
||
1014 | $keys = BannersTableMap::getFieldNames($keyType); |
||
1015 | $result = array( |
||
1016 | $keys[0] => $this->getId(), |
||
1017 | $keys[1] => $this->getPlace(), |
||
1018 | $keys[2] => $this->getWidth(), |
||
1019 | $keys[3] => $this->getHeight(), |
||
1020 | $keys[4] => $this->getEffects(), |
||
1021 | $keys[5] => $this->getPageType(), |
||
1022 | ); |
||
1023 | $virtualColumns = $this->virtualColumns; |
||
1024 | foreach ($virtualColumns as $key => $virtualColumn) { |
||
1025 | $result[$key] = $virtualColumn; |
||
1026 | } |
||
1027 | |||
1028 | if ($includeForeignObjects) { |
||
1029 | if (null !== $this->collBannerImages) { |
||
1030 | |||
1031 | switch ($keyType) { |
||
1032 | case TableMap::TYPE_CAMELNAME: |
||
1033 | $key = 'bannerImages'; |
||
1034 | break; |
||
1035 | case TableMap::TYPE_FIELDNAME: |
||
1036 | $key = 'banner_images'; |
||
1037 | break; |
||
1038 | default: |
||
1039 | $key = 'BannerImages'; |
||
1040 | } |
||
1041 | |||
1042 | $result[$key] = $this->collBannerImages->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); |
||
1043 | } |
||
1044 | if (null !== $this->collBannersI18ns) { |
||
1045 | |||
1046 | switch ($keyType) { |
||
1047 | case TableMap::TYPE_CAMELNAME: |
||
1048 | $key = 'bannersI18ns'; |
||
1049 | break; |
||
1050 | case TableMap::TYPE_FIELDNAME: |
||
1051 | $key = 'banners_i18ns'; |
||
1052 | break; |
||
1053 | default: |
||
1054 | $key = 'BannersI18ns'; |
||
1055 | } |
||
1056 | |||
1057 | $result[$key] = $this->collBannersI18ns->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); |
||
1058 | } |
||
1059 | } |
||
1060 | |||
1061 | return $result; |
||
1062 | } |
||
1063 | |||
1064 | /** |
||
1065 | * Sets a field from the object by name passed in as a string. |
||
1066 | * |
||
1067 | * @param string $name |
||
1068 | * @param mixed $value field value |
||
1069 | * @param string $type The type of fieldname the $name is of: |
||
1070 | * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
1071 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
1072 | * Defaults to TableMap::TYPE_PHPNAME. |
||
1073 | * @return $this|\xbanners\models\Banners |
||
1074 | */ |
||
1075 | public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) |
||
1081 | |||
1082 | /** |
||
1083 | * Sets a field from the object by Position as specified in the xml schema. |
||
1084 | * Zero-based. |
||
1085 | * |
||
1086 | * @param int $pos position in xml schema |
||
1087 | * @param mixed $value field value |
||
1088 | * @return $this|\xbanners\models\Banners |
||
1089 | */ |
||
1090 | public function setByPosition($pos, $value) |
||
1115 | |||
1116 | /** |
||
1117 | * Populates the object using an array. |
||
1118 | * |
||
1119 | * This is particularly useful when populating an object from one of the |
||
1120 | * request arrays (e.g. $_POST). This method goes through the column |
||
1121 | * names, checking to see whether a matching key exists in populated |
||
1122 | * array. If so the setByName() method is called for that column. |
||
1123 | * |
||
1124 | * You can specify the key type of the array by additionally passing one |
||
1125 | * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
1126 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
1127 | * The default key type is the column's TableMap::TYPE_PHPNAME. |
||
1128 | * |
||
1129 | * @param array $arr An array to populate the object from. |
||
1130 | * @param string $keyType The type of keys the array uses. |
||
1131 | * @return void |
||
1132 | */ |
||
1133 | View Code Duplication | public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) |
|
1156 | |||
1157 | /** |
||
1158 | * Populate the current object from a string, using a given parser format |
||
1159 | * <code> |
||
1160 | * $book = new Book(); |
||
1161 | * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
||
1162 | * </code> |
||
1163 | * |
||
1164 | * You can specify the key type of the array by additionally passing one |
||
1165 | * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
1166 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
1167 | * The default key type is the column's TableMap::TYPE_PHPNAME. |
||
1168 | * |
||
1169 | * @param mixed $parser A AbstractParser instance, |
||
1170 | * or a format name ('XML', 'YAML', 'JSON', 'CSV') |
||
1171 | * @param string $data The source data to import from |
||
1172 | * @param string $keyType The type of keys the array uses. |
||
1173 | * |
||
1174 | * @return $this|\xbanners\models\Banners The current object, for fluid interface |
||
1175 | */ |
||
1176 | View Code Duplication | public function importFrom($parser, $data, $keyType = TableMap::TYPE_PHPNAME) |
|
1186 | |||
1187 | /** |
||
1188 | * Build a Criteria object containing the values of all modified columns in this object. |
||
1189 | * |
||
1190 | * @return Criteria The Criteria object containing all modified values. |
||
1191 | */ |
||
1192 | public function buildCriteria() |
||
1217 | |||
1218 | /** |
||
1219 | * Builds a Criteria object containing the primary key for this object. |
||
1220 | * |
||
1221 | * Unlike buildCriteria() this method includes the primary key values regardless |
||
1222 | * of whether or not they have been modified. |
||
1223 | * |
||
1224 | * @throws LogicException if no primary key is defined |
||
1225 | * |
||
1226 | * @return Criteria The Criteria object containing value(s) for primary key(s). |
||
1227 | */ |
||
1228 | public function buildPkeyCriteria() |
||
1235 | |||
1236 | /** |
||
1237 | * If the primary key is not null, return the hashcode of the |
||
1238 | * primary key. Otherwise, return the hash code of the object. |
||
1239 | * |
||
1240 | * @return int Hashcode |
||
1241 | */ |
||
1242 | View Code Duplication | public function hashCode() |
|
1257 | |||
1258 | /** |
||
1259 | * Returns the primary key for this object (row). |
||
1260 | * @return int |
||
1261 | */ |
||
1262 | public function getPrimaryKey() |
||
1266 | |||
1267 | /** |
||
1268 | * Generic method to set the primary key (id column). |
||
1269 | * |
||
1270 | * @param int $key Primary key. |
||
1271 | * @return void |
||
1272 | */ |
||
1273 | public function setPrimaryKey($key) |
||
1277 | |||
1278 | /** |
||
1279 | * Returns true if the primary key for this object is null. |
||
1280 | * @return boolean |
||
1281 | */ |
||
1282 | public function isPrimaryKeyNull() |
||
1286 | |||
1287 | /** |
||
1288 | * Sets contents of passed object to values from current object. |
||
1289 | * |
||
1290 | * If desired, this method can also make copies of all associated (fkey referrers) |
||
1291 | * objects. |
||
1292 | * |
||
1293 | * @param object $copyObj An object of \xbanners\models\Banners (or compatible) type. |
||
1294 | * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
||
1295 | * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. |
||
1296 | * @throws PropelException |
||
1297 | */ |
||
1298 | public function copyInto($copyObj, $deepCopy = false, $makeNew = true) |
||
1330 | |||
1331 | /** |
||
1332 | * Makes a copy of this object that will be inserted as a new row in table when saved. |
||
1333 | * It creates a new object filling in the simple attributes, but skipping any primary |
||
1334 | * keys that are defined for the table. |
||
1335 | * |
||
1336 | * If desired, this method can also make copies of all associated (fkey referrers) |
||
1337 | * objects. |
||
1338 | * |
||
1339 | * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
||
1340 | * @return \xbanners\models\Banners Clone of current object. |
||
1341 | * @throws PropelException |
||
1342 | */ |
||
1343 | View Code Duplication | public function copy($deepCopy = false) |
|
1352 | |||
1353 | |||
1354 | /** |
||
1355 | * Initializes a collection based on the name of a relation. |
||
1356 | * Avoids crafting an 'init[$relationName]s' method name |
||
1357 | * that wouldn't work when StandardEnglishPluralizer is used. |
||
1358 | * |
||
1359 | * @param string $relationName The name of the relation to initialize |
||
1360 | * @return void |
||
1361 | */ |
||
1362 | public function initRelation($relationName) |
||
1371 | |||
1372 | /** |
||
1373 | * Clears out the collBannerImages collection |
||
1374 | * |
||
1375 | * This does not modify the database; however, it will remove any associated objects, causing |
||
1376 | * them to be refetched by subsequent calls to accessor method. |
||
1377 | * |
||
1378 | * @return void |
||
1379 | * @see addBannerImages() |
||
1380 | */ |
||
1381 | public function clearBannerImages() |
||
1385 | |||
1386 | /** |
||
1387 | * Reset is the collBannerImages collection loaded partially. |
||
1388 | */ |
||
1389 | public function resetPartialBannerImages($v = true) |
||
1393 | |||
1394 | /** |
||
1395 | * Initializes the collBannerImages collection. |
||
1396 | * |
||
1397 | * By default this just sets the collBannerImages collection to an empty array (like clearcollBannerImages()); |
||
1398 | * however, you may wish to override this method in your stub class to provide setting appropriate |
||
1399 | * to your application -- for example, setting the initial array to the values stored in database. |
||
1400 | * |
||
1401 | * @param boolean $overrideExisting If set to true, the method call initializes |
||
1402 | * the collection even if it is not empty |
||
1403 | * |
||
1404 | * @return void |
||
1405 | */ |
||
1406 | View Code Duplication | public function initBannerImages($overrideExisting = true) |
|
1417 | |||
1418 | /** |
||
1419 | * Gets an array of ChildBannerImage objects which contain a foreign key that references this object. |
||
1420 | * |
||
1421 | * If the $criteria is not null, it is used to always fetch the results from the database. |
||
1422 | * Otherwise the results are fetched from the database the first time, then cached. |
||
1423 | * Next time the same method is called without $criteria, the cached collection is returned. |
||
1424 | * If this ChildBanners is new, it will return |
||
1425 | * an empty collection or the current collection; the criteria is ignored on a new object. |
||
1426 | * |
||
1427 | * @param Criteria $criteria optional Criteria object to narrow the query |
||
1428 | * @param ConnectionInterface $con optional connection object |
||
1429 | * @return ObjectCollection|ChildBannerImage[] List of ChildBannerImage objects |
||
1430 | * @throws PropelException |
||
1431 | */ |
||
1432 | View Code Duplication | public function getBannerImages(Criteria $criteria = null, ConnectionInterface $con = null) |
|
1475 | |||
1476 | /** |
||
1477 | * Sets a collection of ChildBannerImage objects related by a one-to-many relationship |
||
1478 | * to the current object. |
||
1479 | * It will also schedule objects for deletion based on a diff between old objects (aka persisted) |
||
1480 | * and new objects from the given Propel collection. |
||
1481 | * |
||
1482 | * @param Collection $bannerImages A Propel collection. |
||
1483 | * @param ConnectionInterface $con Optional connection object |
||
1484 | * @return $this|ChildBanners The current object (for fluent API support) |
||
1485 | */ |
||
1486 | View Code Duplication | public function setBannerImages(Collection $bannerImages, ConnectionInterface $con = null) |
|
1508 | |||
1509 | /** |
||
1510 | * Returns the number of related BannerImage objects. |
||
1511 | * |
||
1512 | * @param Criteria $criteria |
||
1513 | * @param boolean $distinct |
||
1514 | * @param ConnectionInterface $con |
||
1515 | * @return int Count of related BannerImage objects. |
||
1516 | * @throws PropelException |
||
1517 | */ |
||
1518 | View Code Duplication | public function countBannerImages(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) |
|
1542 | |||
1543 | /** |
||
1544 | * Method called to associate a ChildBannerImage object to this object |
||
1545 | * through the ChildBannerImage foreign key attribute. |
||
1546 | * |
||
1547 | * @param ChildBannerImage $l ChildBannerImage |
||
1548 | * @return $this|\xbanners\models\Banners The current object (for fluent API support) |
||
1549 | */ |
||
1550 | public function addBannerImage(ChildBannerImage $l) |
||
1567 | |||
1568 | /** |
||
1569 | * @param ChildBannerImage $bannerImage The ChildBannerImage object to add. |
||
1570 | */ |
||
1571 | protected function doAddBannerImage(ChildBannerImage $bannerImage) |
||
1576 | |||
1577 | /** |
||
1578 | * @param ChildBannerImage $bannerImage The ChildBannerImage object to remove. |
||
1579 | * @return $this|ChildBanners The current object (for fluent API support) |
||
1580 | */ |
||
1581 | View Code Duplication | public function removeBannerImage(ChildBannerImage $bannerImage) |
|
1596 | |||
1597 | /** |
||
1598 | * Clears out the collBannersI18ns collection |
||
1599 | * |
||
1600 | * This does not modify the database; however, it will remove any associated objects, causing |
||
1601 | * them to be refetched by subsequent calls to accessor method. |
||
1602 | * |
||
1603 | * @return void |
||
1604 | * @see addBannersI18ns() |
||
1605 | */ |
||
1606 | public function clearBannersI18ns() |
||
1610 | |||
1611 | /** |
||
1612 | * Reset is the collBannersI18ns collection loaded partially. |
||
1613 | */ |
||
1614 | public function resetPartialBannersI18ns($v = true) |
||
1618 | |||
1619 | /** |
||
1620 | * Initializes the collBannersI18ns collection. |
||
1621 | * |
||
1622 | * By default this just sets the collBannersI18ns collection to an empty array (like clearcollBannersI18ns()); |
||
1623 | * however, you may wish to override this method in your stub class to provide setting appropriate |
||
1624 | * to your application -- for example, setting the initial array to the values stored in database. |
||
1625 | * |
||
1626 | * @param boolean $overrideExisting If set to true, the method call initializes |
||
1627 | * the collection even if it is not empty |
||
1628 | * |
||
1629 | * @return void |
||
1630 | */ |
||
1631 | View Code Duplication | public function initBannersI18ns($overrideExisting = true) |
|
1642 | |||
1643 | /** |
||
1644 | * Gets an array of ChildBannersI18n objects which contain a foreign key that references this object. |
||
1645 | * |
||
1646 | * If the $criteria is not null, it is used to always fetch the results from the database. |
||
1647 | * Otherwise the results are fetched from the database the first time, then cached. |
||
1648 | * Next time the same method is called without $criteria, the cached collection is returned. |
||
1649 | * If this ChildBanners is new, it will return |
||
1650 | * an empty collection or the current collection; the criteria is ignored on a new object. |
||
1651 | * |
||
1652 | * @param Criteria $criteria optional Criteria object to narrow the query |
||
1653 | * @param ConnectionInterface $con optional connection object |
||
1654 | * @return ObjectCollection|ChildBannersI18n[] List of ChildBannersI18n objects |
||
1655 | * @throws PropelException |
||
1656 | */ |
||
1657 | View Code Duplication | public function getBannersI18ns(Criteria $criteria = null, ConnectionInterface $con = null) |
|
1700 | |||
1701 | /** |
||
1702 | * Sets a collection of ChildBannersI18n objects related by a one-to-many relationship |
||
1703 | * to the current object. |
||
1704 | * It will also schedule objects for deletion based on a diff between old objects (aka persisted) |
||
1705 | * and new objects from the given Propel collection. |
||
1706 | * |
||
1707 | * @param Collection $bannersI18ns A Propel collection. |
||
1708 | * @param ConnectionInterface $con Optional connection object |
||
1709 | * @return $this|ChildBanners The current object (for fluent API support) |
||
1710 | */ |
||
1711 | View Code Duplication | public function setBannersI18ns(Collection $bannersI18ns, ConnectionInterface $con = null) |
|
1736 | |||
1737 | /** |
||
1738 | * Returns the number of related BannersI18n objects. |
||
1739 | * |
||
1740 | * @param Criteria $criteria |
||
1741 | * @param boolean $distinct |
||
1742 | * @param ConnectionInterface $con |
||
1743 | * @return int Count of related BannersI18n objects. |
||
1744 | * @throws PropelException |
||
1745 | */ |
||
1746 | View Code Duplication | public function countBannersI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) |
|
1770 | |||
1771 | /** |
||
1772 | * Method called to associate a ChildBannersI18n object to this object |
||
1773 | * through the ChildBannersI18n foreign key attribute. |
||
1774 | * |
||
1775 | * @param ChildBannersI18n $l ChildBannersI18n |
||
1776 | * @return $this|\xbanners\models\Banners The current object (for fluent API support) |
||
1777 | */ |
||
1778 | View Code Duplication | public function addBannersI18n(ChildBannersI18n $l) |
|
1799 | |||
1800 | /** |
||
1801 | * @param ChildBannersI18n $bannersI18n The ChildBannersI18n object to add. |
||
1802 | */ |
||
1803 | protected function doAddBannersI18n(ChildBannersI18n $bannersI18n) |
||
1808 | |||
1809 | /** |
||
1810 | * @param ChildBannersI18n $bannersI18n The ChildBannersI18n object to remove. |
||
1811 | * @return $this|ChildBanners The current object (for fluent API support) |
||
1812 | */ |
||
1813 | View Code Duplication | public function removeBannersI18n(ChildBannersI18n $bannersI18n) |
|
1828 | |||
1829 | /** |
||
1830 | * Clears the current object, sets all attributes to their default values and removes |
||
1831 | * outgoing references as well as back-references (from other objects to this one. Results probably in a database |
||
1832 | * change of those foreign objects when you call `save` there). |
||
1833 | */ |
||
1834 | public function clear() |
||
1848 | |||
1849 | /** |
||
1850 | * Resets all references and back-references to other model objects or collections of model objects. |
||
1851 | * |
||
1852 | * This method is used to reset all php object references (not the actual reference in the database). |
||
1853 | * Necessary for object serialisation. |
||
1854 | * |
||
1855 | * @param boolean $deep Whether to also clear the references on all referrer objects. |
||
1856 | */ |
||
1857 | public function clearAllReferences($deep = false) |
||
1879 | |||
1880 | /** |
||
1881 | * Return the string representation of this object |
||
1882 | * |
||
1883 | * @return string |
||
1884 | */ |
||
1885 | public function __toString() |
||
1889 | |||
1890 | // i18n behavior |
||
1891 | |||
1892 | /** |
||
1893 | * Sets the locale for translations |
||
1894 | * |
||
1895 | * @param string $locale Locale to use for the translation, e.g. 'fr_FR' |
||
1896 | * |
||
1897 | * @return $this|ChildBanners The current object (for fluent API support) |
||
1898 | */ |
||
1899 | public function setLocale($locale = 'ru') |
||
1905 | |||
1906 | /** |
||
1907 | * Gets the locale for translations |
||
1908 | * |
||
1909 | * @return string $locale Locale to use for the translation, e.g. 'fr_FR' |
||
1910 | */ |
||
1911 | public function getLocale() |
||
1915 | |||
1916 | /** |
||
1917 | * Returns the current translation for a given locale |
||
1918 | * |
||
1919 | * @param string $locale Locale to use for the translation, e.g. 'fr_FR' |
||
1920 | * @param ConnectionInterface $con an optional connection object |
||
1921 | * |
||
1922 | * @return ChildBannersI18n */ |
||
1923 | View Code Duplication | public function getTranslation($locale = 'ru', ConnectionInterface $con = null) |
|
1949 | |||
1950 | /** |
||
1951 | * Remove the translation for a given locale |
||
1952 | * |
||
1953 | * @param string $locale Locale to use for the translation, e.g. 'fr_FR' |
||
1954 | * @param ConnectionInterface $con an optional connection object |
||
1955 | * |
||
1956 | * @return $this|ChildBanners The current object (for fluent API support) |
||
1957 | */ |
||
1958 | View Code Duplication | public function removeTranslation($locale = 'ru', ConnectionInterface $con = null) |
|
1977 | |||
1978 | /** |
||
1979 | * Returns the current translation |
||
1980 | * |
||
1981 | * @param ConnectionInterface $con an optional connection object |
||
1982 | * |
||
1983 | * @return ChildBannersI18n */ |
||
1984 | public function getCurrentTranslation(ConnectionInterface $con = null) |
||
1988 | |||
1989 | |||
1990 | /** |
||
1991 | * Get the [name] column value. |
||
1992 | * |
||
1993 | * @return string |
||
1994 | */ |
||
1995 | public function getName() |
||
1999 | |||
2000 | |||
2001 | /** |
||
2002 | * Set the value of [name] column. |
||
2003 | * |
||
2004 | * @param string $v new value |
||
2005 | * @return $this|\xbanners\models\BannersI18n The current object (for fluent API support) |
||
2006 | */ |
||
2007 | public function setName($v) |
||
2012 | |||
2013 | /** |
||
2014 | * Code to be run before persisting the object |
||
2015 | * @param ConnectionInterface $con |
||
2016 | * @return boolean |
||
2017 | */ |
||
2018 | public function preSave(ConnectionInterface $con = null) |
||
2025 | |||
2026 | /** |
||
2027 | * Code to be run after persisting the object |
||
2028 | * @param ConnectionInterface $con |
||
2029 | */ |
||
2030 | public function postSave(ConnectionInterface $con = null) |
||
2036 | |||
2037 | /** |
||
2038 | * Code to be run before inserting to database |
||
2039 | * @param ConnectionInterface $con |
||
2040 | * @return boolean |
||
2041 | */ |
||
2042 | public function preInsert(ConnectionInterface $con = null) |
||
2049 | |||
2050 | /** |
||
2051 | * Code to be run after inserting to database |
||
2052 | * @param ConnectionInterface $con |
||
2053 | */ |
||
2054 | public function postInsert(ConnectionInterface $con = null) |
||
2060 | |||
2061 | /** |
||
2062 | * Code to be run before updating the object in database |
||
2063 | * @param ConnectionInterface $con |
||
2064 | * @return boolean |
||
2065 | */ |
||
2066 | public function preUpdate(ConnectionInterface $con = null) |
||
2073 | |||
2074 | /** |
||
2075 | * Code to be run after updating the object in database |
||
2076 | * @param ConnectionInterface $con |
||
2077 | */ |
||
2078 | public function postUpdate(ConnectionInterface $con = null) |
||
2084 | |||
2085 | /** |
||
2086 | * Code to be run before deleting the object in database |
||
2087 | * @param ConnectionInterface $con |
||
2088 | * @return boolean |
||
2089 | */ |
||
2090 | public function preDelete(ConnectionInterface $con = null) |
||
2097 | |||
2098 | /** |
||
2099 | * Code to be run after deleting the object in database |
||
2100 | * @param ConnectionInterface $con |
||
2101 | */ |
||
2102 | public function postDelete(ConnectionInterface $con = null) |
||
2108 | |||
2109 | |||
2110 | /** |
||
2111 | * Derived method to catches calls to undefined methods. |
||
2112 | * |
||
2113 | * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). |
||
2114 | * Allows to define default __call() behavior if you overwrite __call() |
||
2115 | * |
||
2116 | * @param string $name |
||
2117 | * @param mixed $params |
||
2118 | * |
||
2119 | * @return array|string |
||
2120 | */ |
||
2121 | View Code Duplication | public function __call($name, $params) |
|
2150 | |||
2151 | } |
||
2152 |