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 BannerImage 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 BannerImage, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
35 | abstract class BannerImage implements ActiveRecordInterface |
||
36 | { |
||
|
|||
37 | /** |
||
38 | * TableMap class name |
||
39 | */ |
||
40 | const TABLE_MAP = '\\xbanners\\models\\Map\\BannerImageTableMap'; |
||
41 | |||
42 | |||
43 | /** |
||
44 | * attribute to determine if this object has previously been saved. |
||
45 | * @var boolean |
||
46 | */ |
||
47 | protected $new = true; |
||
48 | |||
49 | /** |
||
50 | * attribute to determine whether this object has been deleted. |
||
51 | * @var boolean |
||
52 | */ |
||
53 | protected $deleted = false; |
||
54 | |||
55 | /** |
||
56 | * The columns that have been modified in current object. |
||
57 | * Tracking modified columns allows us to only update modified columns. |
||
58 | * @var array |
||
59 | */ |
||
60 | protected $modifiedColumns = array(); |
||
61 | |||
62 | /** |
||
63 | * The (virtual) columns that are added at runtime |
||
64 | * The formatters can add supplementary columns based on a resultset |
||
65 | * @var array |
||
66 | */ |
||
67 | protected $virtualColumns = array(); |
||
68 | |||
69 | /** |
||
70 | * The value for the id field. |
||
71 | * |
||
72 | * @var int |
||
73 | */ |
||
74 | protected $id; |
||
75 | |||
76 | /** |
||
77 | * The value for the banner_id field. |
||
78 | * |
||
79 | * @var int |
||
80 | */ |
||
81 | protected $banner_id; |
||
82 | |||
83 | /** |
||
84 | * The value for the target field. |
||
85 | * |
||
86 | * @var int |
||
87 | */ |
||
88 | protected $target; |
||
89 | |||
90 | /** |
||
91 | * The value for the url field. |
||
92 | * |
||
93 | * @var string |
||
94 | */ |
||
95 | protected $url; |
||
96 | |||
97 | /** |
||
98 | * The value for the allowed_page field. |
||
99 | * |
||
100 | * @var int |
||
101 | */ |
||
102 | protected $allowed_page; |
||
103 | |||
104 | /** |
||
105 | * The value for the position field. |
||
106 | * |
||
107 | * @var int |
||
108 | */ |
||
109 | protected $position; |
||
110 | |||
111 | /** |
||
112 | * The value for the active_from field. |
||
113 | * |
||
114 | * @var int |
||
115 | */ |
||
116 | protected $active_from; |
||
117 | |||
118 | /** |
||
119 | * The value for the active_to field. |
||
120 | * |
||
121 | * @var int |
||
122 | */ |
||
123 | protected $active_to; |
||
124 | |||
125 | /** |
||
126 | * The value for the active field. |
||
127 | * |
||
128 | * @var int |
||
129 | */ |
||
130 | protected $active; |
||
131 | |||
132 | /** |
||
133 | * The value for the permanent field. |
||
134 | * |
||
135 | * @var int |
||
136 | */ |
||
137 | protected $permanent; |
||
138 | |||
139 | /** |
||
140 | * @var ChildBanners |
||
141 | */ |
||
142 | protected $aBanners; |
||
143 | |||
144 | /** |
||
145 | * @var ObjectCollection|ChildBannerImageI18n[] Collection to store aggregation of ChildBannerImageI18n objects. |
||
146 | */ |
||
147 | protected $collBannerImageI18ns; |
||
148 | protected $collBannerImageI18nsPartial; |
||
149 | |||
150 | /** |
||
151 | * Flag to prevent endless save loop, if this object is referenced |
||
152 | * by another object which falls in this transaction. |
||
153 | * |
||
154 | * @var boolean |
||
155 | */ |
||
156 | protected $alreadyInSave = false; |
||
157 | |||
158 | // i18n behavior |
||
159 | |||
160 | /** |
||
161 | * Current locale |
||
162 | * @var string |
||
163 | */ |
||
164 | protected $currentLocale = 'ru'; |
||
165 | |||
166 | /** |
||
167 | * Current translation objects |
||
168 | * @var array[ChildBannerImageI18n] |
||
169 | */ |
||
170 | protected $currentTranslations; |
||
171 | |||
172 | /** |
||
173 | * An array of objects scheduled for deletion. |
||
174 | * @var ObjectCollection|ChildBannerImageI18n[] |
||
175 | */ |
||
176 | protected $bannerImageI18nsScheduledForDeletion = null; |
||
177 | |||
178 | /** |
||
179 | * Initializes internal state of xbanners\models\Base\BannerImage object. |
||
180 | */ |
||
181 | public function __construct() |
||
184 | |||
185 | /** |
||
186 | * Returns whether the object has been modified. |
||
187 | * |
||
188 | * @return boolean True if the object has been modified. |
||
189 | */ |
||
190 | public function isModified() |
||
194 | |||
195 | /** |
||
196 | * Has specified column been modified? |
||
197 | * |
||
198 | * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID |
||
199 | * @return boolean True if $col has been modified. |
||
200 | */ |
||
201 | public function isColumnModified($col) |
||
205 | |||
206 | /** |
||
207 | * Get the columns that have been modified in this object. |
||
208 | * @return array A unique list of the modified column names for this object. |
||
209 | */ |
||
210 | public function getModifiedColumns() |
||
214 | |||
215 | /** |
||
216 | * Returns whether the object has ever been saved. This will |
||
217 | * be false, if the object was retrieved from storage or was created |
||
218 | * and then saved. |
||
219 | * |
||
220 | * @return boolean true, if the object has never been persisted. |
||
221 | */ |
||
222 | public function isNew() |
||
226 | |||
227 | /** |
||
228 | * Setter for the isNew attribute. This method will be called |
||
229 | * by Propel-generated children and objects. |
||
230 | * |
||
231 | * @param boolean $b the state of the object. |
||
232 | */ |
||
233 | public function setNew($b) |
||
237 | |||
238 | /** |
||
239 | * Whether this object has been deleted. |
||
240 | * @return boolean The deleted state of this object. |
||
241 | */ |
||
242 | public function isDeleted() |
||
246 | |||
247 | /** |
||
248 | * Specify whether this object has been deleted. |
||
249 | * @param boolean $b The deleted state of this object. |
||
250 | * @return void |
||
251 | */ |
||
252 | public function setDeleted($b) |
||
256 | |||
257 | /** |
||
258 | * Sets the modified state for the object to be false. |
||
259 | * @param string $col If supplied, only the specified column is reset. |
||
260 | * @return void |
||
261 | */ |
||
262 | View Code Duplication | public function resetModified($col = null) |
|
272 | |||
273 | /** |
||
274 | * Compares this with another <code>BannerImage</code> instance. If |
||
275 | * <code>obj</code> is an instance of <code>BannerImage</code>, delegates to |
||
276 | * <code>equals(BannerImage)</code>. Otherwise, returns <code>false</code>. |
||
277 | * |
||
278 | * @param mixed $obj The object to compare to. |
||
279 | * @return boolean Whether equal to the object specified. |
||
280 | */ |
||
281 | View Code Duplication | public function equals($obj) |
|
297 | |||
298 | /** |
||
299 | * Get the associative array of the virtual columns in this object |
||
300 | * |
||
301 | * @return array |
||
302 | */ |
||
303 | public function getVirtualColumns() |
||
307 | |||
308 | /** |
||
309 | * Checks the existence of a virtual column in this object |
||
310 | * |
||
311 | * @param string $name The virtual column name |
||
312 | * @return boolean |
||
313 | */ |
||
314 | public function hasVirtualColumn($name) |
||
318 | |||
319 | /** |
||
320 | * Get the value of a virtual column in this object |
||
321 | * |
||
322 | * @param string $name The virtual column name |
||
323 | * @return mixed |
||
324 | * |
||
325 | * @throws PropelException |
||
326 | */ |
||
327 | View Code Duplication | public function getVirtualColumn($name) |
|
335 | |||
336 | /** |
||
337 | * Set the value of a virtual column in this object |
||
338 | * |
||
339 | * @param string $name The virtual column name |
||
340 | * @param mixed $value The value to give to the virtual column |
||
341 | * |
||
342 | * @return $this|BannerImage The current object, for fluid interface |
||
343 | */ |
||
344 | public function setVirtualColumn($name, $value) |
||
350 | |||
351 | /** |
||
352 | * Logs a message using Propel::log(). |
||
353 | * |
||
354 | * @param string $msg |
||
355 | * @param int $priority One of the Propel::LOG_* logging levels |
||
356 | * @return boolean |
||
357 | */ |
||
358 | protected function log($msg, $priority = Propel::LOG_INFO) |
||
362 | |||
363 | /** |
||
364 | * Export the current object properties to a string, using a given parser format |
||
365 | * <code> |
||
366 | * $book = BookQuery::create()->findPk(9012); |
||
367 | * echo $book->exportTo('JSON'); |
||
368 | * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
||
369 | * </code> |
||
370 | * |
||
371 | * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') |
||
372 | * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. |
||
373 | * @return string The exported data |
||
374 | */ |
||
375 | View Code Duplication | public function exportTo($parser, $includeLazyLoadColumns = true) |
|
383 | |||
384 | /** |
||
385 | * Clean up internal collections prior to serializing |
||
386 | * Avoids recursive loops that turn into segmentation faults when serializing |
||
387 | */ |
||
388 | View Code Duplication | public function __sleep() |
|
402 | |||
403 | /** |
||
404 | * Get the [id] column value. |
||
405 | * |
||
406 | * @return int |
||
407 | */ |
||
408 | public function getId() |
||
412 | |||
413 | /** |
||
414 | * Get the [banner_id] column value. |
||
415 | * |
||
416 | * @return int |
||
417 | */ |
||
418 | public function getBannerId() |
||
422 | |||
423 | /** |
||
424 | * Get the [target] column value. |
||
425 | * |
||
426 | * @return int |
||
427 | */ |
||
428 | public function getTarget() |
||
432 | |||
433 | /** |
||
434 | * Get the [url] column value. |
||
435 | * |
||
436 | * @return string |
||
437 | */ |
||
438 | public function getUrl() |
||
442 | |||
443 | /** |
||
444 | * Get the [allowed_page] column value. |
||
445 | * |
||
446 | * @return int |
||
447 | */ |
||
448 | public function getAllowedPage() |
||
452 | |||
453 | /** |
||
454 | * Get the [position] column value. |
||
455 | * |
||
456 | * @return int |
||
457 | */ |
||
458 | public function getPosition() |
||
462 | |||
463 | /** |
||
464 | * Get the [active_from] column value. |
||
465 | * |
||
466 | * @return int |
||
467 | */ |
||
468 | public function getActiveFrom() |
||
472 | |||
473 | /** |
||
474 | * Get the [active_to] column value. |
||
475 | * |
||
476 | * @return int |
||
477 | */ |
||
478 | public function getActiveTo() |
||
482 | |||
483 | /** |
||
484 | * Get the [active] column value. |
||
485 | * |
||
486 | * @return int |
||
487 | */ |
||
488 | public function getActive() |
||
492 | |||
493 | /** |
||
494 | * Get the [permanent] column value. |
||
495 | * |
||
496 | * @return int |
||
497 | */ |
||
498 | public function getPermanent() |
||
502 | |||
503 | /** |
||
504 | * Set the value of [id] column. |
||
505 | * |
||
506 | * @param int $v new value |
||
507 | * @return $this|\xbanners\models\BannerImage The current object (for fluent API support) |
||
508 | */ |
||
509 | public function setId($v) |
||
522 | |||
523 | /** |
||
524 | * Set the value of [banner_id] column. |
||
525 | * |
||
526 | * @param int $v new value |
||
527 | * @return $this|\xbanners\models\BannerImage The current object (for fluent API support) |
||
528 | */ |
||
529 | View Code Duplication | public function setBannerId($v) |
|
546 | |||
547 | /** |
||
548 | * Set the value of [target] column. |
||
549 | * |
||
550 | * @param int $v new value |
||
551 | * @return $this|\xbanners\models\BannerImage The current object (for fluent API support) |
||
552 | */ |
||
553 | public function setTarget($v) |
||
566 | |||
567 | /** |
||
568 | * Set the value of [url] column. |
||
569 | * |
||
570 | * @param string $v new value |
||
571 | * @return $this|\xbanners\models\BannerImage The current object (for fluent API support) |
||
572 | */ |
||
573 | public function setUrl($v) |
||
586 | |||
587 | /** |
||
588 | * Set the value of [allowed_page] column. |
||
589 | * |
||
590 | * @param int $v new value |
||
591 | * @return $this|\xbanners\models\BannerImage The current object (for fluent API support) |
||
592 | */ |
||
593 | public function setAllowedPage($v) |
||
606 | |||
607 | /** |
||
608 | * Set the value of [position] column. |
||
609 | * |
||
610 | * @param int $v new value |
||
611 | * @return $this|\xbanners\models\BannerImage The current object (for fluent API support) |
||
612 | */ |
||
613 | public function setPosition($v) |
||
626 | |||
627 | /** |
||
628 | * Set the value of [active_from] column. |
||
629 | * |
||
630 | * @param int $v new value |
||
631 | * @return $this|\xbanners\models\BannerImage The current object (for fluent API support) |
||
632 | */ |
||
633 | public function setActiveFrom($v) |
||
646 | |||
647 | /** |
||
648 | * Set the value of [active_to] column. |
||
649 | * |
||
650 | * @param int $v new value |
||
651 | * @return $this|\xbanners\models\BannerImage The current object (for fluent API support) |
||
652 | */ |
||
653 | public function setActiveTo($v) |
||
666 | |||
667 | /** |
||
668 | * Set the value of [active] column. |
||
669 | * |
||
670 | * @param int $v new value |
||
671 | * @return $this|\xbanners\models\BannerImage The current object (for fluent API support) |
||
672 | */ |
||
673 | public function setActive($v) |
||
686 | |||
687 | /** |
||
688 | * Set the value of [permanent] column. |
||
689 | * |
||
690 | * @param int $v new value |
||
691 | * @return $this|\xbanners\models\BannerImage The current object (for fluent API support) |
||
692 | */ |
||
693 | public function setPermanent($v) |
||
706 | |||
707 | /** |
||
708 | * Indicates whether the columns in this object are only set to default values. |
||
709 | * |
||
710 | * This method can be used in conjunction with isModified() to indicate whether an object is both |
||
711 | * modified _and_ has some values set which are non-default. |
||
712 | * |
||
713 | * @return boolean Whether the columns in this object are only been set with default values. |
||
714 | */ |
||
715 | public function hasOnlyDefaultValues() |
||
720 | |||
721 | /** |
||
722 | * Hydrates (populates) the object variables with values from the database resultset. |
||
723 | * |
||
724 | * An offset (0-based "start column") is specified so that objects can be hydrated |
||
725 | * with a subset of the columns in the resultset rows. This is needed, for example, |
||
726 | * for results of JOIN queries where the resultset row includes columns from two or |
||
727 | * more tables. |
||
728 | * |
||
729 | * @param array $row The row returned by DataFetcher->fetch(). |
||
730 | * @param int $startcol 0-based offset column which indicates which restultset column to start with. |
||
731 | * @param boolean $rehydrate Whether this object is being re-hydrated from the database. |
||
732 | * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
||
733 | One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
734 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
735 | * |
||
736 | * @return int next starting column |
||
737 | * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. |
||
738 | */ |
||
739 | public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) |
||
786 | |||
787 | /** |
||
788 | * Checks and repairs the internal consistency of the object. |
||
789 | * |
||
790 | * This method is executed after an already-instantiated object is re-hydrated |
||
791 | * from the database. It exists to check any foreign keys to make sure that |
||
792 | * the objects related to the current object are correct based on foreign key. |
||
793 | * |
||
794 | * You can override this method in the stub class, but you should always invoke |
||
795 | * the base method from the overridden method (i.e. parent::ensureConsistency()), |
||
796 | * in case your model changes. |
||
797 | * |
||
798 | * @throws PropelException |
||
799 | */ |
||
800 | public function ensureConsistency() |
||
806 | |||
807 | /** |
||
808 | * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. |
||
809 | * |
||
810 | * This will only work if the object has been saved and has a valid primary key set. |
||
811 | * |
||
812 | * @param boolean $deep (optional) Whether to also de-associated any related objects. |
||
813 | * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. |
||
814 | * @return void |
||
815 | * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db |
||
816 | */ |
||
817 | View Code Duplication | public function reload($deep = false, ConnectionInterface $con = null) |
|
849 | |||
850 | /** |
||
851 | * Removes this object from datastore and sets delete attribute. |
||
852 | * |
||
853 | * @param ConnectionInterface $con |
||
854 | * @return void |
||
855 | * @throws PropelException |
||
856 | * @see BannerImage::setDeleted() |
||
857 | * @see BannerImage::isDeleted() |
||
858 | */ |
||
859 | View Code Duplication | public function delete(ConnectionInterface $con = null) |
|
880 | |||
881 | /** |
||
882 | * Persists this object to the database. |
||
883 | * |
||
884 | * If the object is new, it inserts it; otherwise an update is performed. |
||
885 | * All modified related objects will also be persisted in the doSave() |
||
886 | * method. This method wraps all precipitate database operations in a |
||
887 | * single transaction. |
||
888 | * |
||
889 | * @param ConnectionInterface $con |
||
890 | * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
||
891 | * @throws PropelException |
||
892 | * @see doSave() |
||
893 | */ |
||
894 | View Code Duplication | public function save(ConnectionInterface $con = null) |
|
928 | |||
929 | /** |
||
930 | * Performs the work of inserting or updating the row in the database. |
||
931 | * |
||
932 | * If the object is new, it inserts it; otherwise an update is performed. |
||
933 | * All related objects are also updated in this method. |
||
934 | * |
||
935 | * @param ConnectionInterface $con |
||
936 | * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
||
937 | * @throws PropelException |
||
938 | * @see save() |
||
939 | */ |
||
940 | protected function doSave(ConnectionInterface $con) |
||
992 | |||
993 | /** |
||
994 | * Insert the row in the database. |
||
995 | * |
||
996 | * @param ConnectionInterface $con |
||
997 | * |
||
998 | * @throws PropelException |
||
999 | * @see doSave() |
||
1000 | */ |
||
1001 | protected function doInsert(ConnectionInterface $con) |
||
1100 | |||
1101 | /** |
||
1102 | * Update the row in the database. |
||
1103 | * |
||
1104 | * @param ConnectionInterface $con |
||
1105 | * |
||
1106 | * @return Integer Number of updated rows |
||
1107 | * @see doSave() |
||
1108 | */ |
||
1109 | protected function doUpdate(ConnectionInterface $con) |
||
1116 | |||
1117 | /** |
||
1118 | * Retrieves a field from the object by name passed in as a string. |
||
1119 | * |
||
1120 | * @param string $name name |
||
1121 | * @param string $type The type of fieldname the $name is of: |
||
1122 | * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
1123 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
1124 | * Defaults to TableMap::TYPE_PHPNAME. |
||
1125 | * @return mixed Value of field. |
||
1126 | */ |
||
1127 | View Code Duplication | public function getByName($name, $type = TableMap::TYPE_PHPNAME) |
|
1134 | |||
1135 | /** |
||
1136 | * Retrieves a field from the object by Position as specified in the xml schema. |
||
1137 | * Zero-based. |
||
1138 | * |
||
1139 | * @param int $pos position in xml schema |
||
1140 | * @return mixed Value of field at $pos |
||
1141 | */ |
||
1142 | public function getByPosition($pos) |
||
1180 | |||
1181 | /** |
||
1182 | * Exports the object as an array. |
||
1183 | * |
||
1184 | * You can specify the key type of the array by passing one of the class |
||
1185 | * type constants. |
||
1186 | * |
||
1187 | * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
1188 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
1189 | * Defaults to TableMap::TYPE_PHPNAME. |
||
1190 | * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. |
||
1191 | * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion |
||
1192 | * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. |
||
1193 | * |
||
1194 | * @return array an associative array containing the field names (as keys) and field values |
||
1195 | */ |
||
1196 | public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) |
||
1197 | { |
||
1198 | |||
1199 | if (isset($alreadyDumpedObjects['BannerImage'][$this->hashCode()])) { |
||
1200 | return '*RECURSION*'; |
||
1201 | } |
||
1202 | $alreadyDumpedObjects['BannerImage'][$this->hashCode()] = true; |
||
1203 | $keys = BannerImageTableMap::getFieldNames($keyType); |
||
1204 | $result = array( |
||
1205 | $keys[0] => $this->getId(), |
||
1206 | $keys[1] => $this->getBannerId(), |
||
1207 | $keys[2] => $this->getTarget(), |
||
1208 | $keys[3] => $this->getUrl(), |
||
1209 | $keys[4] => $this->getAllowedPage(), |
||
1210 | $keys[5] => $this->getPosition(), |
||
1211 | $keys[6] => $this->getActiveFrom(), |
||
1212 | $keys[7] => $this->getActiveTo(), |
||
1213 | $keys[8] => $this->getActive(), |
||
1214 | $keys[9] => $this->getPermanent(), |
||
1215 | ); |
||
1216 | $virtualColumns = $this->virtualColumns; |
||
1217 | foreach ($virtualColumns as $key => $virtualColumn) { |
||
1218 | $result[$key] = $virtualColumn; |
||
1219 | } |
||
1220 | |||
1221 | if ($includeForeignObjects) { |
||
1222 | if (null !== $this->aBanners) { |
||
1223 | |||
1224 | switch ($keyType) { |
||
1225 | case TableMap::TYPE_CAMELNAME: |
||
1226 | $key = 'banners'; |
||
1227 | break; |
||
1228 | case TableMap::TYPE_FIELDNAME: |
||
1229 | $key = 'banners'; |
||
1230 | break; |
||
1231 | default: |
||
1232 | $key = 'Banners'; |
||
1233 | } |
||
1234 | |||
1235 | $result[$key] = $this->aBanners->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); |
||
1236 | } |
||
1237 | if (null !== $this->collBannerImageI18ns) { |
||
1238 | |||
1239 | switch ($keyType) { |
||
1240 | case TableMap::TYPE_CAMELNAME: |
||
1241 | $key = 'bannerImageI18ns'; |
||
1242 | break; |
||
1243 | case TableMap::TYPE_FIELDNAME: |
||
1244 | $key = 'banner_image_i18ns'; |
||
1245 | break; |
||
1246 | default: |
||
1247 | $key = 'BannerImageI18ns'; |
||
1248 | } |
||
1249 | |||
1250 | $result[$key] = $this->collBannerImageI18ns->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); |
||
1251 | } |
||
1252 | } |
||
1253 | |||
1254 | return $result; |
||
1255 | } |
||
1256 | |||
1257 | /** |
||
1258 | * Sets a field from the object by name passed in as a string. |
||
1259 | * |
||
1260 | * @param string $name |
||
1261 | * @param mixed $value field value |
||
1262 | * @param string $type The type of fieldname the $name is of: |
||
1263 | * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
1264 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
1265 | * Defaults to TableMap::TYPE_PHPNAME. |
||
1266 | * @return $this|\xbanners\models\BannerImage |
||
1267 | */ |
||
1268 | public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) |
||
1274 | |||
1275 | /** |
||
1276 | * Sets a field from the object by Position as specified in the xml schema. |
||
1277 | * Zero-based. |
||
1278 | * |
||
1279 | * @param int $pos position in xml schema |
||
1280 | * @param mixed $value field value |
||
1281 | * @return $this|\xbanners\models\BannerImage |
||
1282 | */ |
||
1283 | public function setByPosition($pos, $value) |
||
1320 | |||
1321 | /** |
||
1322 | * Populates the object using an array. |
||
1323 | * |
||
1324 | * This is particularly useful when populating an object from one of the |
||
1325 | * request arrays (e.g. $_POST). This method goes through the column |
||
1326 | * names, checking to see whether a matching key exists in populated |
||
1327 | * array. If so the setByName() method is called for that column. |
||
1328 | * |
||
1329 | * You can specify the key type of the array by additionally passing one |
||
1330 | * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
1331 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
1332 | * The default key type is the column's TableMap::TYPE_PHPNAME. |
||
1333 | * |
||
1334 | * @param array $arr An array to populate the object from. |
||
1335 | * @param string $keyType The type of keys the array uses. |
||
1336 | * @return void |
||
1337 | */ |
||
1338 | public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) |
||
1373 | |||
1374 | /** |
||
1375 | * Populate the current object from a string, using a given parser format |
||
1376 | * <code> |
||
1377 | * $book = new Book(); |
||
1378 | * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
||
1379 | * </code> |
||
1380 | * |
||
1381 | * You can specify the key type of the array by additionally passing one |
||
1382 | * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
1383 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
1384 | * The default key type is the column's TableMap::TYPE_PHPNAME. |
||
1385 | * |
||
1386 | * @param mixed $parser A AbstractParser instance, |
||
1387 | * or a format name ('XML', 'YAML', 'JSON', 'CSV') |
||
1388 | * @param string $data The source data to import from |
||
1389 | * @param string $keyType The type of keys the array uses. |
||
1390 | * |
||
1391 | * @return $this|\xbanners\models\BannerImage The current object, for fluid interface |
||
1392 | */ |
||
1393 | View Code Duplication | public function importFrom($parser, $data, $keyType = TableMap::TYPE_PHPNAME) |
|
1403 | |||
1404 | /** |
||
1405 | * Build a Criteria object containing the values of all modified columns in this object. |
||
1406 | * |
||
1407 | * @return Criteria The Criteria object containing all modified values. |
||
1408 | */ |
||
1409 | public function buildCriteria() |
||
1446 | |||
1447 | /** |
||
1448 | * Builds a Criteria object containing the primary key for this object. |
||
1449 | * |
||
1450 | * Unlike buildCriteria() this method includes the primary key values regardless |
||
1451 | * of whether or not they have been modified. |
||
1452 | * |
||
1453 | * @throws LogicException if no primary key is defined |
||
1454 | * |
||
1455 | * @return Criteria The Criteria object containing value(s) for primary key(s). |
||
1456 | */ |
||
1457 | public function buildPkeyCriteria() |
||
1464 | |||
1465 | /** |
||
1466 | * If the primary key is not null, return the hashcode of the |
||
1467 | * primary key. Otherwise, return the hash code of the object. |
||
1468 | * |
||
1469 | * @return int Hashcode |
||
1470 | */ |
||
1471 | View Code Duplication | public function hashCode() |
|
1486 | |||
1487 | /** |
||
1488 | * Returns the primary key for this object (row). |
||
1489 | * @return int |
||
1490 | */ |
||
1491 | public function getPrimaryKey() |
||
1495 | |||
1496 | /** |
||
1497 | * Generic method to set the primary key (id column). |
||
1498 | * |
||
1499 | * @param int $key Primary key. |
||
1500 | * @return void |
||
1501 | */ |
||
1502 | public function setPrimaryKey($key) |
||
1506 | |||
1507 | /** |
||
1508 | * Returns true if the primary key for this object is null. |
||
1509 | * @return boolean |
||
1510 | */ |
||
1511 | public function isPrimaryKeyNull() |
||
1515 | |||
1516 | /** |
||
1517 | * Sets contents of passed object to values from current object. |
||
1518 | * |
||
1519 | * If desired, this method can also make copies of all associated (fkey referrers) |
||
1520 | * objects. |
||
1521 | * |
||
1522 | * @param object $copyObj An object of \xbanners\models\BannerImage (or compatible) type. |
||
1523 | * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
||
1524 | * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. |
||
1525 | * @throws PropelException |
||
1526 | */ |
||
1527 | public function copyInto($copyObj, $deepCopy = false, $makeNew = true) |
||
1557 | |||
1558 | /** |
||
1559 | * Makes a copy of this object that will be inserted as a new row in table when saved. |
||
1560 | * It creates a new object filling in the simple attributes, but skipping any primary |
||
1561 | * keys that are defined for the table. |
||
1562 | * |
||
1563 | * If desired, this method can also make copies of all associated (fkey referrers) |
||
1564 | * objects. |
||
1565 | * |
||
1566 | * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
||
1567 | * @return \xbanners\models\BannerImage Clone of current object. |
||
1568 | * @throws PropelException |
||
1569 | */ |
||
1570 | View Code Duplication | public function copy($deepCopy = false) |
|
1579 | |||
1580 | /** |
||
1581 | * Declares an association between this object and a ChildBanners object. |
||
1582 | * |
||
1583 | * @param ChildBanners $v |
||
1584 | * @return $this|\xbanners\models\BannerImage The current object (for fluent API support) |
||
1585 | * @throws PropelException |
||
1586 | */ |
||
1587 | public function setBanners(ChildBanners $v = null) |
||
1606 | |||
1607 | |||
1608 | /** |
||
1609 | * Get the associated ChildBanners object |
||
1610 | * |
||
1611 | * @param ConnectionInterface $con Optional Connection object. |
||
1612 | * @return ChildBanners The associated ChildBanners object. |
||
1613 | * @throws PropelException |
||
1614 | */ |
||
1615 | View Code Duplication | public function getBanners(ConnectionInterface $con = null) |
|
1630 | |||
1631 | |||
1632 | /** |
||
1633 | * Initializes a collection based on the name of a relation. |
||
1634 | * Avoids crafting an 'init[$relationName]s' method name |
||
1635 | * that wouldn't work when StandardEnglishPluralizer is used. |
||
1636 | * |
||
1637 | * @param string $relationName The name of the relation to initialize |
||
1638 | * @return void |
||
1639 | */ |
||
1640 | public function initRelation($relationName) |
||
1646 | |||
1647 | /** |
||
1648 | * Clears out the collBannerImageI18ns collection |
||
1649 | * |
||
1650 | * This does not modify the database; however, it will remove any associated objects, causing |
||
1651 | * them to be refetched by subsequent calls to accessor method. |
||
1652 | * |
||
1653 | * @return void |
||
1654 | * @see addBannerImageI18ns() |
||
1655 | */ |
||
1656 | public function clearBannerImageI18ns() |
||
1660 | |||
1661 | /** |
||
1662 | * Reset is the collBannerImageI18ns collection loaded partially. |
||
1663 | */ |
||
1664 | public function resetPartialBannerImageI18ns($v = true) |
||
1668 | |||
1669 | /** |
||
1670 | * Initializes the collBannerImageI18ns collection. |
||
1671 | * |
||
1672 | * By default this just sets the collBannerImageI18ns collection to an empty array (like clearcollBannerImageI18ns()); |
||
1673 | * however, you may wish to override this method in your stub class to provide setting appropriate |
||
1674 | * to your application -- for example, setting the initial array to the values stored in database. |
||
1675 | * |
||
1676 | * @param boolean $overrideExisting If set to true, the method call initializes |
||
1677 | * the collection even if it is not empty |
||
1678 | * |
||
1679 | * @return void |
||
1680 | */ |
||
1681 | View Code Duplication | public function initBannerImageI18ns($overrideExisting = true) |
|
1692 | |||
1693 | /** |
||
1694 | * Gets an array of ChildBannerImageI18n objects which contain a foreign key that references this object. |
||
1695 | * |
||
1696 | * If the $criteria is not null, it is used to always fetch the results from the database. |
||
1697 | * Otherwise the results are fetched from the database the first time, then cached. |
||
1698 | * Next time the same method is called without $criteria, the cached collection is returned. |
||
1699 | * If this ChildBannerImage is new, it will return |
||
1700 | * an empty collection or the current collection; the criteria is ignored on a new object. |
||
1701 | * |
||
1702 | * @param Criteria $criteria optional Criteria object to narrow the query |
||
1703 | * @param ConnectionInterface $con optional connection object |
||
1704 | * @return ObjectCollection|ChildBannerImageI18n[] List of ChildBannerImageI18n objects |
||
1705 | * @throws PropelException |
||
1706 | */ |
||
1707 | View Code Duplication | public function getBannerImageI18ns(Criteria $criteria = null, ConnectionInterface $con = null) |
|
1750 | |||
1751 | /** |
||
1752 | * Sets a collection of ChildBannerImageI18n objects related by a one-to-many relationship |
||
1753 | * to the current object. |
||
1754 | * It will also schedule objects for deletion based on a diff between old objects (aka persisted) |
||
1755 | * and new objects from the given Propel collection. |
||
1756 | * |
||
1757 | * @param Collection $bannerImageI18ns A Propel collection. |
||
1758 | * @param ConnectionInterface $con Optional connection object |
||
1759 | * @return $this|ChildBannerImage The current object (for fluent API support) |
||
1760 | */ |
||
1761 | public function setBannerImageI18ns(Collection $bannerImageI18ns, ConnectionInterface $con = null) |
||
1786 | |||
1787 | /** |
||
1788 | * Returns the number of related BannerImageI18n objects. |
||
1789 | * |
||
1790 | * @param Criteria $criteria |
||
1791 | * @param boolean $distinct |
||
1792 | * @param ConnectionInterface $con |
||
1793 | * @return int Count of related BannerImageI18n objects. |
||
1794 | * @throws PropelException |
||
1795 | */ |
||
1796 | View Code Duplication | public function countBannerImageI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) |
|
1820 | |||
1821 | /** |
||
1822 | * Method called to associate a ChildBannerImageI18n object to this object |
||
1823 | * through the ChildBannerImageI18n foreign key attribute. |
||
1824 | * |
||
1825 | * @param ChildBannerImageI18n $l ChildBannerImageI18n |
||
1826 | * @return $this|\xbanners\models\BannerImage The current object (for fluent API support) |
||
1827 | */ |
||
1828 | View Code Duplication | public function addBannerImageI18n(ChildBannerImageI18n $l) |
|
1849 | |||
1850 | /** |
||
1851 | * @param ChildBannerImageI18n $bannerImageI18n The ChildBannerImageI18n object to add. |
||
1852 | */ |
||
1853 | protected function doAddBannerImageI18n(ChildBannerImageI18n $bannerImageI18n) |
||
1858 | |||
1859 | /** |
||
1860 | * @param ChildBannerImageI18n $bannerImageI18n The ChildBannerImageI18n object to remove. |
||
1861 | * @return $this|ChildBannerImage The current object (for fluent API support) |
||
1862 | */ |
||
1863 | public function removeBannerImageI18n(ChildBannerImageI18n $bannerImageI18n) |
||
1878 | |||
1879 | /** |
||
1880 | * Clears the current object, sets all attributes to their default values and removes |
||
1881 | * outgoing references as well as back-references (from other objects to this one. Results probably in a database |
||
1882 | * change of those foreign objects when you call `save` there). |
||
1883 | */ |
||
1884 | public function clear() |
||
1905 | |||
1906 | /** |
||
1907 | * Resets all references and back-references to other model objects or collections of model objects. |
||
1908 | * |
||
1909 | * This method is used to reset all php object references (not the actual reference in the database). |
||
1910 | * Necessary for object serialisation. |
||
1911 | * |
||
1912 | * @param boolean $deep Whether to also clear the references on all referrer objects. |
||
1913 | */ |
||
1914 | public function clearAllReferences($deep = false) |
||
1931 | |||
1932 | /** |
||
1933 | * Return the string representation of this object |
||
1934 | * |
||
1935 | * @return string |
||
1936 | */ |
||
1937 | public function __toString() |
||
1941 | |||
1942 | // i18n behavior |
||
1943 | |||
1944 | /** |
||
1945 | * Sets the locale for translations |
||
1946 | * |
||
1947 | * @param string $locale Locale to use for the translation, e.g. 'fr_FR' |
||
1948 | * |
||
1949 | * @return $this|ChildBannerImage The current object (for fluent API support) |
||
1950 | */ |
||
1951 | public function setLocale($locale = 'ru') |
||
1957 | |||
1958 | /** |
||
1959 | * Gets the locale for translations |
||
1960 | * |
||
1961 | * @return string $locale Locale to use for the translation, e.g. 'fr_FR' |
||
1962 | */ |
||
1963 | public function getLocale() |
||
1967 | |||
1968 | /** |
||
1969 | * Returns the current translation for a given locale |
||
1970 | * |
||
1971 | * @param string $locale Locale to use for the translation, e.g. 'fr_FR' |
||
1972 | * @param ConnectionInterface $con an optional connection object |
||
1973 | * |
||
1974 | * @return ChildBannerImageI18n */ |
||
1975 | View Code Duplication | public function getTranslation($locale = 'ru', ConnectionInterface $con = null) |
|
2001 | |||
2002 | /** |
||
2003 | * Remove the translation for a given locale |
||
2004 | * |
||
2005 | * @param string $locale Locale to use for the translation, e.g. 'fr_FR' |
||
2006 | * @param ConnectionInterface $con an optional connection object |
||
2007 | * |
||
2008 | * @return $this|ChildBannerImage The current object (for fluent API support) |
||
2009 | */ |
||
2010 | View Code Duplication | public function removeTranslation($locale = 'ru', ConnectionInterface $con = null) |
|
2029 | |||
2030 | /** |
||
2031 | * Returns the current translation |
||
2032 | * |
||
2033 | * @param ConnectionInterface $con an optional connection object |
||
2034 | * |
||
2035 | * @return ChildBannerImageI18n */ |
||
2036 | public function getCurrentTranslation(ConnectionInterface $con = null) |
||
2040 | |||
2041 | |||
2042 | /** |
||
2043 | * Get the [src] column value. |
||
2044 | * |
||
2045 | * @return string |
||
2046 | */ |
||
2047 | public function getSrc() |
||
2051 | |||
2052 | |||
2053 | /** |
||
2054 | * Set the value of [src] column. |
||
2055 | * |
||
2056 | * @param string $v new value |
||
2057 | * @return $this|\xbanners\models\BannerImageI18n The current object (for fluent API support) |
||
2058 | */ |
||
2059 | public function setSrc($v) |
||
2064 | |||
2065 | |||
2066 | /** |
||
2067 | * Get the [name] column value. |
||
2068 | * |
||
2069 | * @return string |
||
2070 | */ |
||
2071 | public function getName() |
||
2075 | |||
2076 | |||
2077 | /** |
||
2078 | * Set the value of [name] column. |
||
2079 | * |
||
2080 | * @param string $v new value |
||
2081 | * @return $this|\xbanners\models\BannerImageI18n The current object (for fluent API support) |
||
2082 | */ |
||
2083 | public function setName($v) |
||
2088 | |||
2089 | |||
2090 | /** |
||
2091 | * Get the [clicks] column value. |
||
2092 | * |
||
2093 | * @return int |
||
2094 | */ |
||
2095 | public function getClicks() |
||
2099 | |||
2100 | |||
2101 | /** |
||
2102 | * Set the value of [clicks] column. |
||
2103 | * |
||
2104 | * @param int $v new value |
||
2105 | * @return $this|\xbanners\models\BannerImageI18n The current object (for fluent API support) |
||
2106 | */ |
||
2107 | public function setClicks($v) |
||
2112 | |||
2113 | |||
2114 | /** |
||
2115 | * Get the [description] column value. |
||
2116 | * |
||
2117 | * @return string |
||
2118 | */ |
||
2119 | public function getDescription() |
||
2123 | |||
2124 | |||
2125 | /** |
||
2126 | * Set the value of [description] column. |
||
2127 | * |
||
2128 | * @param string $v new value |
||
2129 | * @return $this|\xbanners\models\BannerImageI18n The current object (for fluent API support) |
||
2130 | */ |
||
2131 | public function setDescription($v) |
||
2136 | |||
2137 | /** |
||
2138 | * Code to be run before persisting the object |
||
2139 | * @param ConnectionInterface $con |
||
2140 | * @return boolean |
||
2141 | */ |
||
2142 | public function preSave(ConnectionInterface $con = null) |
||
2149 | |||
2150 | /** |
||
2151 | * Code to be run after persisting the object |
||
2152 | * @param ConnectionInterface $con |
||
2153 | */ |
||
2154 | public function postSave(ConnectionInterface $con = null) |
||
2160 | |||
2161 | /** |
||
2162 | * Code to be run before inserting to database |
||
2163 | * @param ConnectionInterface $con |
||
2164 | * @return boolean |
||
2165 | */ |
||
2166 | public function preInsert(ConnectionInterface $con = null) |
||
2173 | |||
2174 | /** |
||
2175 | * Code to be run after inserting to database |
||
2176 | * @param ConnectionInterface $con |
||
2177 | */ |
||
2178 | public function postInsert(ConnectionInterface $con = null) |
||
2184 | |||
2185 | /** |
||
2186 | * Code to be run before updating the object in database |
||
2187 | * @param ConnectionInterface $con |
||
2188 | * @return boolean |
||
2189 | */ |
||
2190 | public function preUpdate(ConnectionInterface $con = null) |
||
2197 | |||
2198 | /** |
||
2199 | * Code to be run after updating the object in database |
||
2200 | * @param ConnectionInterface $con |
||
2201 | */ |
||
2202 | public function postUpdate(ConnectionInterface $con = null) |
||
2208 | |||
2209 | /** |
||
2210 | * Code to be run before deleting the object in database |
||
2211 | * @param ConnectionInterface $con |
||
2212 | * @return boolean |
||
2213 | */ |
||
2214 | public function preDelete(ConnectionInterface $con = null) |
||
2221 | |||
2222 | /** |
||
2223 | * Code to be run after deleting the object in database |
||
2224 | * @param ConnectionInterface $con |
||
2225 | */ |
||
2226 | public function postDelete(ConnectionInterface $con = null) |
||
2232 | |||
2233 | |||
2234 | /** |
||
2235 | * Derived method to catches calls to undefined methods. |
||
2236 | * |
||
2237 | * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). |
||
2238 | * Allows to define default __call() behavior if you overwrite __call() |
||
2239 | * |
||
2240 | * @param string $name |
||
2241 | * @param mixed $params |
||
2242 | * |
||
2243 | * @return array|string |
||
2244 | */ |
||
2245 | View Code Duplication | public function __call($name, $params) |
|
2274 | |||
2275 | } |
||
2276 |