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 |
||
| 36 | abstract class BannerImage extends PropelBaseModelClass implements ActiveRecordInterface |
||
| 37 | { |
||
| 38 | /** |
||
| 39 | * TableMap class name |
||
| 40 | */ |
||
| 41 | const TABLE_MAP = '\\xbanners\\models\\Map\\BannerImageTableMap'; |
||
| 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 banner_id field. |
||
| 79 | * |
||
| 80 | * @var int |
||
| 81 | */ |
||
| 82 | protected $banner_id; |
||
| 83 | |||
| 84 | /** |
||
| 85 | * The value for the target field. |
||
| 86 | * |
||
| 87 | * @var int |
||
| 88 | */ |
||
| 89 | protected $target; |
||
| 90 | |||
| 91 | /** |
||
| 92 | * The value for the url field. |
||
| 93 | * |
||
| 94 | * @var string |
||
| 95 | */ |
||
| 96 | protected $url; |
||
| 97 | |||
| 98 | /** |
||
| 99 | * The value for the allowed_page field. |
||
| 100 | * |
||
| 101 | * @var int |
||
| 102 | */ |
||
| 103 | protected $allowed_page; |
||
| 104 | |||
| 105 | /** |
||
| 106 | * The value for the position field. |
||
| 107 | * |
||
| 108 | * @var int |
||
| 109 | */ |
||
| 110 | protected $position; |
||
| 111 | |||
| 112 | /** |
||
| 113 | * The value for the active_from field. |
||
| 114 | * |
||
| 115 | * @var int |
||
| 116 | */ |
||
| 117 | protected $active_from; |
||
| 118 | |||
| 119 | /** |
||
| 120 | * The value for the active_to field. |
||
| 121 | * |
||
| 122 | * @var int |
||
| 123 | */ |
||
| 124 | protected $active_to; |
||
| 125 | |||
| 126 | /** |
||
| 127 | * The value for the active field. |
||
| 128 | * |
||
| 129 | * @var int |
||
| 130 | */ |
||
| 131 | protected $active; |
||
| 132 | |||
| 133 | /** |
||
| 134 | * The value for the permanent field. |
||
| 135 | * |
||
| 136 | * @var int |
||
| 137 | */ |
||
| 138 | protected $permanent; |
||
| 139 | |||
| 140 | /** |
||
| 141 | * @var ChildBanners |
||
| 142 | */ |
||
| 143 | protected $aBanners; |
||
| 144 | |||
| 145 | /** |
||
| 146 | * @var ObjectCollection|ChildBannerImageI18n[] Collection to store aggregation of ChildBannerImageI18n objects. |
||
| 147 | */ |
||
| 148 | protected $collBannerImageI18ns; |
||
| 149 | protected $collBannerImageI18nsPartial; |
||
| 150 | |||
| 151 | /** |
||
| 152 | * Flag to prevent endless save loop, if this object is referenced |
||
| 153 | * by another object which falls in this transaction. |
||
| 154 | * |
||
| 155 | * @var boolean |
||
| 156 | */ |
||
| 157 | protected $alreadyInSave = false; |
||
| 158 | |||
| 159 | // i18n behavior |
||
| 160 | |||
| 161 | /** |
||
| 162 | * Current locale |
||
| 163 | * @var string |
||
| 164 | */ |
||
| 165 | protected $currentLocale = 'ru'; |
||
| 166 | |||
| 167 | /** |
||
| 168 | * Current translation objects |
||
| 169 | * @var array[ChildBannerImageI18n] |
||
| 170 | */ |
||
| 171 | protected $currentTranslations; |
||
| 172 | |||
| 173 | /** |
||
| 174 | * An array of objects scheduled for deletion. |
||
| 175 | * @var ObjectCollection|ChildBannerImageI18n[] |
||
| 176 | */ |
||
| 177 | protected $bannerImageI18nsScheduledForDeletion = null; |
||
| 178 | |||
| 179 | /** |
||
| 180 | * Initializes internal state of xbanners\models\Base\BannerImage object. |
||
| 181 | */ |
||
| 182 | public function __construct() |
||
| 185 | |||
| 186 | /** |
||
| 187 | * Returns whether the object has been modified. |
||
| 188 | * |
||
| 189 | * @return boolean True if the object has been modified. |
||
| 190 | */ |
||
| 191 | public function isModified() |
||
| 195 | |||
| 196 | /** |
||
| 197 | * Has specified column been modified? |
||
| 198 | * |
||
| 199 | * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID |
||
| 200 | * @return boolean True if $col has been modified. |
||
| 201 | */ |
||
| 202 | public function isColumnModified($col) |
||
| 206 | |||
| 207 | /** |
||
| 208 | * Get the columns that have been modified in this object. |
||
| 209 | * @return array A unique list of the modified column names for this object. |
||
| 210 | */ |
||
| 211 | public function getModifiedColumns() |
||
| 215 | |||
| 216 | /** |
||
| 217 | * Returns whether the object has ever been saved. This will |
||
| 218 | * be false, if the object was retrieved from storage or was created |
||
| 219 | * and then saved. |
||
| 220 | * |
||
| 221 | * @return boolean true, if the object has never been persisted. |
||
| 222 | */ |
||
| 223 | public function isNew() |
||
| 227 | |||
| 228 | /** |
||
| 229 | * Setter for the isNew attribute. This method will be called |
||
| 230 | * by Propel-generated children and objects. |
||
| 231 | * |
||
| 232 | * @param boolean $b the state of the object. |
||
| 233 | */ |
||
| 234 | public function setNew($b) |
||
| 238 | |||
| 239 | /** |
||
| 240 | * Whether this object has been deleted. |
||
| 241 | * @return boolean The deleted state of this object. |
||
| 242 | */ |
||
| 243 | public function isDeleted() |
||
| 247 | |||
| 248 | /** |
||
| 249 | * Specify whether this object has been deleted. |
||
| 250 | * @param boolean $b The deleted state of this object. |
||
| 251 | * @return void |
||
| 252 | */ |
||
| 253 | public function setDeleted($b) |
||
| 257 | |||
| 258 | /** |
||
| 259 | * Sets the modified state for the object to be false. |
||
| 260 | * @param string $col If supplied, only the specified column is reset. |
||
| 261 | * @return void |
||
| 262 | */ |
||
| 263 | View Code Duplication | public function resetModified($col = null) |
|
| 273 | |||
| 274 | /** |
||
| 275 | * Compares this with another <code>BannerImage</code> instance. If |
||
| 276 | * <code>obj</code> is an instance of <code>BannerImage</code>, delegates to |
||
| 277 | * <code>equals(BannerImage)</code>. Otherwise, returns <code>false</code>. |
||
| 278 | * |
||
| 279 | * @param mixed $obj The object to compare to. |
||
| 280 | * @return boolean Whether equal to the object specified. |
||
| 281 | */ |
||
| 282 | View Code Duplication | public function equals($obj) |
|
| 298 | |||
| 299 | /** |
||
| 300 | * Get the associative array of the virtual columns in this object |
||
| 301 | * |
||
| 302 | * @return array |
||
| 303 | */ |
||
| 304 | public function getVirtualColumns() |
||
| 308 | |||
| 309 | /** |
||
| 310 | * Checks the existence of a virtual column in this object |
||
| 311 | * |
||
| 312 | * @param string $name The virtual column name |
||
| 313 | * @return boolean |
||
| 314 | */ |
||
| 315 | public function hasVirtualColumn($name) |
||
| 319 | |||
| 320 | /** |
||
| 321 | * Get the value of a virtual column in this object |
||
| 322 | * |
||
| 323 | * @param string $name The virtual column name |
||
| 324 | * @return mixed |
||
| 325 | * |
||
| 326 | * @throws PropelException |
||
| 327 | */ |
||
| 328 | View Code Duplication | public function getVirtualColumn($name) |
|
| 336 | |||
| 337 | /** |
||
| 338 | * Set the value of a virtual column in this object |
||
| 339 | * |
||
| 340 | * @param string $name The virtual column name |
||
| 341 | * @param mixed $value The value to give to the virtual column |
||
| 342 | * |
||
| 343 | * @return $this|BannerImage The current object, for fluid interface |
||
| 344 | */ |
||
| 345 | public function setVirtualColumn($name, $value) |
||
| 351 | |||
| 352 | /** |
||
| 353 | * Logs a message using Propel::log(). |
||
| 354 | * |
||
| 355 | * @param string $msg |
||
| 356 | * @param int $priority One of the Propel::LOG_* logging levels |
||
| 357 | * @return boolean |
||
|
|
|||
| 358 | */ |
||
| 359 | protected function log($msg, $priority = Propel::LOG_INFO) |
||
| 363 | |||
| 364 | /** |
||
| 365 | * Export the current object properties to a string, using a given parser format |
||
| 366 | * <code> |
||
| 367 | * $book = BookQuery::create()->findPk(9012); |
||
| 368 | * echo $book->exportTo('JSON'); |
||
| 369 | * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
||
| 370 | * </code> |
||
| 371 | * |
||
| 372 | * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') |
||
| 373 | * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. |
||
| 374 | * @return string The exported data |
||
| 375 | */ |
||
| 376 | View Code Duplication | public function exportTo($parser, $includeLazyLoadColumns = true) |
|
| 384 | |||
| 385 | /** |
||
| 386 | * Clean up internal collections prior to serializing |
||
| 387 | * Avoids recursive loops that turn into segmentation faults when serializing |
||
| 388 | */ |
||
| 389 | View Code Duplication | public function __sleep() |
|
| 403 | |||
| 404 | /** |
||
| 405 | * Get the [id] column value. |
||
| 406 | * |
||
| 407 | * @return int |
||
| 408 | */ |
||
| 409 | public function getId() |
||
| 413 | |||
| 414 | /** |
||
| 415 | * Get the [banner_id] column value. |
||
| 416 | * |
||
| 417 | * @return int |
||
| 418 | */ |
||
| 419 | public function getBannerId() |
||
| 423 | |||
| 424 | /** |
||
| 425 | * Get the [target] column value. |
||
| 426 | * |
||
| 427 | * @return int |
||
| 428 | */ |
||
| 429 | public function getTarget() |
||
| 433 | |||
| 434 | /** |
||
| 435 | * Get the [url] column value. |
||
| 436 | * |
||
| 437 | * @return string |
||
| 438 | */ |
||
| 439 | public function getUrl() |
||
| 443 | |||
| 444 | /** |
||
| 445 | * Get the [allowed_page] column value. |
||
| 446 | * |
||
| 447 | * @return int |
||
| 448 | */ |
||
| 449 | public function getAllowedPage() |
||
| 453 | |||
| 454 | /** |
||
| 455 | * Get the [position] column value. |
||
| 456 | * |
||
| 457 | * @return int |
||
| 458 | */ |
||
| 459 | public function getPosition() |
||
| 463 | |||
| 464 | /** |
||
| 465 | * Get the [active_from] column value. |
||
| 466 | * |
||
| 467 | * @return int |
||
| 468 | */ |
||
| 469 | public function getActiveFrom() |
||
| 473 | |||
| 474 | /** |
||
| 475 | * Get the [active_to] column value. |
||
| 476 | * |
||
| 477 | * @return int |
||
| 478 | */ |
||
| 479 | public function getActiveTo() |
||
| 483 | |||
| 484 | /** |
||
| 485 | * Get the [active] column value. |
||
| 486 | * |
||
| 487 | * @return int |
||
| 488 | */ |
||
| 489 | public function getActive() |
||
| 493 | |||
| 494 | /** |
||
| 495 | * Get the [permanent] column value. |
||
| 496 | * |
||
| 497 | * @return int |
||
| 498 | */ |
||
| 499 | public function getPermanent() |
||
| 503 | |||
| 504 | /** |
||
| 505 | * Set the value of [id] column. |
||
| 506 | * |
||
| 507 | * @param int $v new value |
||
| 508 | * @return $this|\xbanners\models\BannerImage The current object (for fluent API support) |
||
| 509 | */ |
||
| 510 | View Code Duplication | public function setId($v) |
|
| 523 | |||
| 524 | /** |
||
| 525 | * Set the value of [banner_id] column. |
||
| 526 | * |
||
| 527 | * @param int $v new value |
||
| 528 | * @return $this|\xbanners\models\BannerImage The current object (for fluent API support) |
||
| 529 | */ |
||
| 530 | View Code Duplication | public function setBannerId($v) |
|
| 547 | |||
| 548 | /** |
||
| 549 | * Set the value of [target] column. |
||
| 550 | * |
||
| 551 | * @param int $v new value |
||
| 552 | * @return $this|\xbanners\models\BannerImage The current object (for fluent API support) |
||
| 553 | */ |
||
| 554 | View Code Duplication | public function setTarget($v) |
|
| 567 | |||
| 568 | /** |
||
| 569 | * Set the value of [url] column. |
||
| 570 | * |
||
| 571 | * @param string $v new value |
||
| 572 | * @return $this|\xbanners\models\BannerImage The current object (for fluent API support) |
||
| 573 | */ |
||
| 574 | View Code Duplication | public function setUrl($v) |
|
| 587 | |||
| 588 | /** |
||
| 589 | * Set the value of [allowed_page] column. |
||
| 590 | * |
||
| 591 | * @param int $v new value |
||
| 592 | * @return $this|\xbanners\models\BannerImage The current object (for fluent API support) |
||
| 593 | */ |
||
| 594 | View Code Duplication | public function setAllowedPage($v) |
|
| 607 | |||
| 608 | /** |
||
| 609 | * Set the value of [position] column. |
||
| 610 | * |
||
| 611 | * @param int $v new value |
||
| 612 | * @return $this|\xbanners\models\BannerImage The current object (for fluent API support) |
||
| 613 | */ |
||
| 614 | View Code Duplication | public function setPosition($v) |
|
| 627 | |||
| 628 | /** |
||
| 629 | * Set the value of [active_from] column. |
||
| 630 | * |
||
| 631 | * @param int $v new value |
||
| 632 | * @return $this|\xbanners\models\BannerImage The current object (for fluent API support) |
||
| 633 | */ |
||
| 634 | View Code Duplication | public function setActiveFrom($v) |
|
| 647 | |||
| 648 | /** |
||
| 649 | * Set the value of [active_to] column. |
||
| 650 | * |
||
| 651 | * @param int $v new value |
||
| 652 | * @return $this|\xbanners\models\BannerImage The current object (for fluent API support) |
||
| 653 | */ |
||
| 654 | View Code Duplication | public function setActiveTo($v) |
|
| 667 | |||
| 668 | /** |
||
| 669 | * Set the value of [active] column. |
||
| 670 | * |
||
| 671 | * @param int $v new value |
||
| 672 | * @return $this|\xbanners\models\BannerImage The current object (for fluent API support) |
||
| 673 | */ |
||
| 674 | View Code Duplication | public function setActive($v) |
|
| 687 | |||
| 688 | /** |
||
| 689 | * Set the value of [permanent] column. |
||
| 690 | * |
||
| 691 | * @param int $v new value |
||
| 692 | * @return $this|\xbanners\models\BannerImage The current object (for fluent API support) |
||
| 693 | */ |
||
| 694 | View Code Duplication | public function setPermanent($v) |
|
| 707 | |||
| 708 | /** |
||
| 709 | * Indicates whether the columns in this object are only set to default values. |
||
| 710 | * |
||
| 711 | * This method can be used in conjunction with isModified() to indicate whether an object is both |
||
| 712 | * modified _and_ has some values set which are non-default. |
||
| 713 | * |
||
| 714 | * @return boolean Whether the columns in this object are only been set with default values. |
||
| 715 | */ |
||
| 716 | public function hasOnlyDefaultValues() |
||
| 721 | |||
| 722 | /** |
||
| 723 | * Hydrates (populates) the object variables with values from the database resultset. |
||
| 724 | * |
||
| 725 | * An offset (0-based "start column") is specified so that objects can be hydrated |
||
| 726 | * with a subset of the columns in the resultset rows. This is needed, for example, |
||
| 727 | * for results of JOIN queries where the resultset row includes columns from two or |
||
| 728 | * more tables. |
||
| 729 | * |
||
| 730 | * @param array $row The row returned by DataFetcher->fetch(). |
||
| 731 | * @param int $startcol 0-based offset column which indicates which restultset column to start with. |
||
| 732 | * @param boolean $rehydrate Whether this object is being re-hydrated from the database. |
||
| 733 | * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
||
| 734 | One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
| 735 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 736 | * |
||
| 737 | * @return int next starting column |
||
| 738 | * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. |
||
| 739 | */ |
||
| 740 | public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) |
||
| 787 | |||
| 788 | /** |
||
| 789 | * Checks and repairs the internal consistency of the object. |
||
| 790 | * |
||
| 791 | * This method is executed after an already-instantiated object is re-hydrated |
||
| 792 | * from the database. It exists to check any foreign keys to make sure that |
||
| 793 | * the objects related to the current object are correct based on foreign key. |
||
| 794 | * |
||
| 795 | * You can override this method in the stub class, but you should always invoke |
||
| 796 | * the base method from the overridden method (i.e. parent::ensureConsistency()), |
||
| 797 | * in case your model changes. |
||
| 798 | * |
||
| 799 | * @throws PropelException |
||
| 800 | */ |
||
| 801 | public function ensureConsistency() |
||
| 807 | |||
| 808 | /** |
||
| 809 | * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. |
||
| 810 | * |
||
| 811 | * This will only work if the object has been saved and has a valid primary key set. |
||
| 812 | * |
||
| 813 | * @param boolean $deep (optional) Whether to also de-associated any related objects. |
||
| 814 | * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. |
||
| 815 | * @return void |
||
| 816 | * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db |
||
| 817 | */ |
||
| 818 | View Code Duplication | public function reload($deep = false, ConnectionInterface $con = null) |
|
| 850 | |||
| 851 | /** |
||
| 852 | * Removes this object from datastore and sets delete attribute. |
||
| 853 | * |
||
| 854 | * @param ConnectionInterface $con |
||
| 855 | * @return void |
||
| 856 | * @throws PropelException |
||
| 857 | * @see BannerImage::setDeleted() |
||
| 858 | * @see BannerImage::isDeleted() |
||
| 859 | */ |
||
| 860 | View Code Duplication | public function delete(ConnectionInterface $con = null) |
|
| 881 | |||
| 882 | /** |
||
| 883 | * Persists this object to the database. |
||
| 884 | * |
||
| 885 | * If the object is new, it inserts it; otherwise an update is performed. |
||
| 886 | * All modified related objects will also be persisted in the doSave() |
||
| 887 | * method. This method wraps all precipitate database operations in a |
||
| 888 | * single transaction. |
||
| 889 | * |
||
| 890 | * @param ConnectionInterface $con |
||
| 891 | * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
||
| 892 | * @throws PropelException |
||
| 893 | * @see doSave() |
||
| 894 | */ |
||
| 895 | View Code Duplication | public function save(ConnectionInterface $con = null) |
|
| 933 | |||
| 934 | /** |
||
| 935 | * Performs the work of inserting or updating the row in the database. |
||
| 936 | * |
||
| 937 | * If the object is new, it inserts it; otherwise an update is performed. |
||
| 938 | * All related objects are also updated in this method. |
||
| 939 | * |
||
| 940 | * @param ConnectionInterface $con |
||
| 941 | * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
||
| 942 | * @throws PropelException |
||
| 943 | * @see save() |
||
| 944 | */ |
||
| 945 | protected function doSave(ConnectionInterface $con) |
||
| 997 | |||
| 998 | /** |
||
| 999 | * Insert the row in the database. |
||
| 1000 | * |
||
| 1001 | * @param ConnectionInterface $con |
||
| 1002 | * |
||
| 1003 | * @throws PropelException |
||
| 1004 | * @see doSave() |
||
| 1005 | */ |
||
| 1006 | protected function doInsert(ConnectionInterface $con) |
||
| 1105 | |||
| 1106 | /** |
||
| 1107 | * Update the row in the database. |
||
| 1108 | * |
||
| 1109 | * @param ConnectionInterface $con |
||
| 1110 | * |
||
| 1111 | * @return Integer Number of updated rows |
||
| 1112 | * @see doSave() |
||
| 1113 | */ |
||
| 1114 | protected function doUpdate(ConnectionInterface $con) |
||
| 1121 | |||
| 1122 | /** |
||
| 1123 | * Retrieves a field from the object by name passed in as a string. |
||
| 1124 | * |
||
| 1125 | * @param string $name name |
||
| 1126 | * @param string $type The type of fieldname the $name is of: |
||
| 1127 | * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
| 1128 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1129 | * Defaults to TableMap::TYPE_PHPNAME. |
||
| 1130 | * @return mixed Value of field. |
||
| 1131 | */ |
||
| 1132 | View Code Duplication | public function getByName($name, $type = TableMap::TYPE_PHPNAME) |
|
| 1139 | |||
| 1140 | /** |
||
| 1141 | * Retrieves a field from the object by Position as specified in the xml schema. |
||
| 1142 | * Zero-based. |
||
| 1143 | * |
||
| 1144 | * @param int $pos position in xml schema |
||
| 1145 | * @return mixed Value of field at $pos |
||
| 1146 | */ |
||
| 1147 | public function getByPosition($pos) |
||
| 1185 | |||
| 1186 | /** |
||
| 1187 | * Exports the object as an array. |
||
| 1188 | * |
||
| 1189 | * You can specify the key type of the array by passing one of the class |
||
| 1190 | * type constants. |
||
| 1191 | * |
||
| 1192 | * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
| 1193 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1194 | * Defaults to TableMap::TYPE_PHPNAME. |
||
| 1195 | * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. |
||
| 1196 | * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion |
||
| 1197 | * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. |
||
| 1198 | * |
||
| 1199 | * @return array an associative array containing the field names (as keys) and field values |
||
| 1200 | */ |
||
| 1201 | public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) |
||
| 1261 | |||
| 1262 | /** |
||
| 1263 | * Sets a field from the object by name passed in as a string. |
||
| 1264 | * |
||
| 1265 | * @param string $name |
||
| 1266 | * @param mixed $value field value |
||
| 1267 | * @param string $type The type of fieldname the $name is of: |
||
| 1268 | * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
| 1269 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1270 | * Defaults to TableMap::TYPE_PHPNAME. |
||
| 1271 | * @return $this|\xbanners\models\BannerImage |
||
| 1272 | */ |
||
| 1273 | public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) |
||
| 1279 | |||
| 1280 | /** |
||
| 1281 | * Sets a field from the object by Position as specified in the xml schema. |
||
| 1282 | * Zero-based. |
||
| 1283 | * |
||
| 1284 | * @param int $pos position in xml schema |
||
| 1285 | * @param mixed $value field value |
||
| 1286 | * @return $this|\xbanners\models\BannerImage |
||
| 1287 | */ |
||
| 1288 | public function setByPosition($pos, $value) |
||
| 1325 | |||
| 1326 | /** |
||
| 1327 | * Populates the object using an array. |
||
| 1328 | * |
||
| 1329 | * This is particularly useful when populating an object from one of the |
||
| 1330 | * request arrays (e.g. $_POST). This method goes through the column |
||
| 1331 | * names, checking to see whether a matching key exists in populated |
||
| 1332 | * array. If so the setByName() method is called for that column. |
||
| 1333 | * |
||
| 1334 | * You can specify the key type of the array by additionally passing one |
||
| 1335 | * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
| 1336 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1337 | * The default key type is the column's TableMap::TYPE_PHPNAME. |
||
| 1338 | * |
||
| 1339 | * @param array $arr An array to populate the object from. |
||
| 1340 | * @param string $keyType The type of keys the array uses. |
||
| 1341 | * @return void |
||
| 1342 | */ |
||
| 1343 | public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) |
||
| 1378 | |||
| 1379 | /** |
||
| 1380 | * Populate the current object from a string, using a given parser format |
||
| 1381 | * <code> |
||
| 1382 | * $book = new Book(); |
||
| 1383 | * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
||
| 1384 | * </code> |
||
| 1385 | * |
||
| 1386 | * You can specify the key type of the array by additionally passing one |
||
| 1387 | * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
| 1388 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1389 | * The default key type is the column's TableMap::TYPE_PHPNAME. |
||
| 1390 | * |
||
| 1391 | * @param mixed $parser A AbstractParser instance, |
||
| 1392 | * or a format name ('XML', 'YAML', 'JSON', 'CSV') |
||
| 1393 | * @param string $data The source data to import from |
||
| 1394 | * @param string $keyType The type of keys the array uses. |
||
| 1395 | * |
||
| 1396 | * @return $this|\xbanners\models\BannerImage The current object, for fluid interface |
||
| 1397 | */ |
||
| 1398 | View Code Duplication | public function importFrom($parser, $data, $keyType = TableMap::TYPE_PHPNAME) |
|
| 1408 | |||
| 1409 | /** |
||
| 1410 | * Build a Criteria object containing the values of all modified columns in this object. |
||
| 1411 | * |
||
| 1412 | * @return Criteria The Criteria object containing all modified values. |
||
| 1413 | */ |
||
| 1414 | public function buildCriteria() |
||
| 1451 | |||
| 1452 | /** |
||
| 1453 | * Builds a Criteria object containing the primary key for this object. |
||
| 1454 | * |
||
| 1455 | * Unlike buildCriteria() this method includes the primary key values regardless |
||
| 1456 | * of whether or not they have been modified. |
||
| 1457 | * |
||
| 1458 | * @throws LogicException if no primary key is defined |
||
| 1459 | * |
||
| 1460 | * @return Criteria The Criteria object containing value(s) for primary key(s). |
||
| 1461 | */ |
||
| 1462 | public function buildPkeyCriteria() |
||
| 1469 | |||
| 1470 | /** |
||
| 1471 | * If the primary key is not null, return the hashcode of the |
||
| 1472 | * primary key. Otherwise, return the hash code of the object. |
||
| 1473 | * |
||
| 1474 | * @return int Hashcode |
||
| 1475 | */ |
||
| 1476 | View Code Duplication | public function hashCode() |
|
| 1491 | |||
| 1492 | /** |
||
| 1493 | * Returns the primary key for this object (row). |
||
| 1494 | * @return int |
||
| 1495 | */ |
||
| 1496 | public function getPrimaryKey() |
||
| 1500 | |||
| 1501 | /** |
||
| 1502 | * Generic method to set the primary key (id column). |
||
| 1503 | * |
||
| 1504 | * @param int $key Primary key. |
||
| 1505 | * @return void |
||
| 1506 | */ |
||
| 1507 | public function setPrimaryKey($key) |
||
| 1511 | |||
| 1512 | /** |
||
| 1513 | * Returns true if the primary key for this object is null. |
||
| 1514 | * @return boolean |
||
| 1515 | */ |
||
| 1516 | public function isPrimaryKeyNull() |
||
| 1520 | |||
| 1521 | /** |
||
| 1522 | * Sets contents of passed object to values from current object. |
||
| 1523 | * |
||
| 1524 | * If desired, this method can also make copies of all associated (fkey referrers) |
||
| 1525 | * objects. |
||
| 1526 | * |
||
| 1527 | * @param object $copyObj An object of \xbanners\models\BannerImage (or compatible) type. |
||
| 1528 | * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
||
| 1529 | * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. |
||
| 1530 | * @throws PropelException |
||
| 1531 | */ |
||
| 1532 | public function copyInto($copyObj, $deepCopy = false, $makeNew = true) |
||
| 1562 | |||
| 1563 | /** |
||
| 1564 | * Makes a copy of this object that will be inserted as a new row in table when saved. |
||
| 1565 | * It creates a new object filling in the simple attributes, but skipping any primary |
||
| 1566 | * keys that are defined for the table. |
||
| 1567 | * |
||
| 1568 | * If desired, this method can also make copies of all associated (fkey referrers) |
||
| 1569 | * objects. |
||
| 1570 | * |
||
| 1571 | * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
||
| 1572 | * @return \xbanners\models\BannerImage Clone of current object. |
||
| 1573 | * @throws PropelException |
||
| 1574 | */ |
||
| 1575 | View Code Duplication | public function copy($deepCopy = false) |
|
| 1584 | |||
| 1585 | /** |
||
| 1586 | * Declares an association between this object and a ChildBanners object. |
||
| 1587 | * |
||
| 1588 | * @param ChildBanners $v |
||
| 1589 | * @return $this|\xbanners\models\BannerImage The current object (for fluent API support) |
||
| 1590 | * @throws PropelException |
||
| 1591 | */ |
||
| 1592 | public function setBanners(ChildBanners $v = null) |
||
| 1611 | |||
| 1612 | |||
| 1613 | /** |
||
| 1614 | * Get the associated ChildBanners object |
||
| 1615 | * |
||
| 1616 | * @param ConnectionInterface $con Optional Connection object. |
||
| 1617 | * @return ChildBanners The associated ChildBanners object. |
||
| 1618 | * @throws PropelException |
||
| 1619 | */ |
||
| 1620 | View Code Duplication | public function getBanners(ConnectionInterface $con = null) |
|
| 1635 | |||
| 1636 | |||
| 1637 | /** |
||
| 1638 | * Initializes a collection based on the name of a relation. |
||
| 1639 | * Avoids crafting an 'init[$relationName]s' method name |
||
| 1640 | * that wouldn't work when StandardEnglishPluralizer is used. |
||
| 1641 | * |
||
| 1642 | * @param string $relationName The name of the relation to initialize |
||
| 1643 | * @return void |
||
| 1644 | */ |
||
| 1645 | public function initRelation($relationName) |
||
| 1651 | |||
| 1652 | /** |
||
| 1653 | * Clears out the collBannerImageI18ns collection |
||
| 1654 | * |
||
| 1655 | * This does not modify the database; however, it will remove any associated objects, causing |
||
| 1656 | * them to be refetched by subsequent calls to accessor method. |
||
| 1657 | * |
||
| 1658 | * @return void |
||
| 1659 | * @see addBannerImageI18ns() |
||
| 1660 | */ |
||
| 1661 | public function clearBannerImageI18ns() |
||
| 1665 | |||
| 1666 | /** |
||
| 1667 | * Reset is the collBannerImageI18ns collection loaded partially. |
||
| 1668 | */ |
||
| 1669 | public function resetPartialBannerImageI18ns($v = true) |
||
| 1673 | |||
| 1674 | /** |
||
| 1675 | * Initializes the collBannerImageI18ns collection. |
||
| 1676 | * |
||
| 1677 | * By default this just sets the collBannerImageI18ns collection to an empty array (like clearcollBannerImageI18ns()); |
||
| 1678 | * however, you may wish to override this method in your stub class to provide setting appropriate |
||
| 1679 | * to your application -- for example, setting the initial array to the values stored in database. |
||
| 1680 | * |
||
| 1681 | * @param boolean $overrideExisting If set to true, the method call initializes |
||
| 1682 | * the collection even if it is not empty |
||
| 1683 | * |
||
| 1684 | * @return void |
||
| 1685 | */ |
||
| 1686 | View Code Duplication | public function initBannerImageI18ns($overrideExisting = true) |
|
| 1697 | |||
| 1698 | /** |
||
| 1699 | * Gets an array of ChildBannerImageI18n objects which contain a foreign key that references this object. |
||
| 1700 | * |
||
| 1701 | * If the $criteria is not null, it is used to always fetch the results from the database. |
||
| 1702 | * Otherwise the results are fetched from the database the first time, then cached. |
||
| 1703 | * Next time the same method is called without $criteria, the cached collection is returned. |
||
| 1704 | * If this ChildBannerImage is new, it will return |
||
| 1705 | * an empty collection or the current collection; the criteria is ignored on a new object. |
||
| 1706 | * |
||
| 1707 | * @param Criteria $criteria optional Criteria object to narrow the query |
||
| 1708 | * @param ConnectionInterface $con optional connection object |
||
| 1709 | * @return ObjectCollection|ChildBannerImageI18n[] List of ChildBannerImageI18n objects |
||
| 1710 | * @throws PropelException |
||
| 1711 | */ |
||
| 1712 | View Code Duplication | public function getBannerImageI18ns(Criteria $criteria = null, ConnectionInterface $con = null) |
|
| 1755 | |||
| 1756 | /** |
||
| 1757 | * Sets a collection of ChildBannerImageI18n objects related by a one-to-many relationship |
||
| 1758 | * to the current object. |
||
| 1759 | * It will also schedule objects for deletion based on a diff between old objects (aka persisted) |
||
| 1760 | * and new objects from the given Propel collection. |
||
| 1761 | * |
||
| 1762 | * @param Collection $bannerImageI18ns A Propel collection. |
||
| 1763 | * @param ConnectionInterface $con Optional connection object |
||
| 1764 | * @return $this|ChildBannerImage The current object (for fluent API support) |
||
| 1765 | */ |
||
| 1766 | public function setBannerImageI18ns(Collection $bannerImageI18ns, ConnectionInterface $con = null) |
||
| 1791 | |||
| 1792 | /** |
||
| 1793 | * Returns the number of related BannerImageI18n objects. |
||
| 1794 | * |
||
| 1795 | * @param Criteria $criteria |
||
| 1796 | * @param boolean $distinct |
||
| 1797 | * @param ConnectionInterface $con |
||
| 1798 | * @return int Count of related BannerImageI18n objects. |
||
| 1799 | * @throws PropelException |
||
| 1800 | */ |
||
| 1801 | View Code Duplication | public function countBannerImageI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) |
|
| 1825 | |||
| 1826 | /** |
||
| 1827 | * Method called to associate a ChildBannerImageI18n object to this object |
||
| 1828 | * through the ChildBannerImageI18n foreign key attribute. |
||
| 1829 | * |
||
| 1830 | * @param ChildBannerImageI18n $l ChildBannerImageI18n |
||
| 1831 | * @return $this|\xbanners\models\BannerImage The current object (for fluent API support) |
||
| 1832 | */ |
||
| 1833 | View Code Duplication | public function addBannerImageI18n(ChildBannerImageI18n $l) |
|
| 1854 | |||
| 1855 | /** |
||
| 1856 | * @param ChildBannerImageI18n $bannerImageI18n The ChildBannerImageI18n object to add. |
||
| 1857 | */ |
||
| 1858 | protected function doAddBannerImageI18n(ChildBannerImageI18n $bannerImageI18n) |
||
| 1863 | |||
| 1864 | /** |
||
| 1865 | * @param ChildBannerImageI18n $bannerImageI18n The ChildBannerImageI18n object to remove. |
||
| 1866 | * @return $this|ChildBannerImage The current object (for fluent API support) |
||
| 1867 | */ |
||
| 1868 | public function removeBannerImageI18n(ChildBannerImageI18n $bannerImageI18n) |
||
| 1883 | |||
| 1884 | /** |
||
| 1885 | * Clears the current object, sets all attributes to their default values and removes |
||
| 1886 | * outgoing references as well as back-references (from other objects to this one. Results probably in a database |
||
| 1887 | * change of those foreign objects when you call `save` there). |
||
| 1888 | */ |
||
| 1889 | public function clear() |
||
| 1910 | |||
| 1911 | /** |
||
| 1912 | * Resets all references and back-references to other model objects or collections of model objects. |
||
| 1913 | * |
||
| 1914 | * This method is used to reset all php object references (not the actual reference in the database). |
||
| 1915 | * Necessary for object serialisation. |
||
| 1916 | * |
||
| 1917 | * @param boolean $deep Whether to also clear the references on all referrer objects. |
||
| 1918 | */ |
||
| 1919 | public function clearAllReferences($deep = false) |
||
| 1936 | |||
| 1937 | /** |
||
| 1938 | * Return the string representation of this object |
||
| 1939 | * |
||
| 1940 | * @return string |
||
| 1941 | */ |
||
| 1942 | public function __toString() |
||
| 1946 | |||
| 1947 | // i18n behavior |
||
| 1948 | |||
| 1949 | /** |
||
| 1950 | * Sets the locale for translations |
||
| 1951 | * |
||
| 1952 | * @param string $locale Locale to use for the translation, e.g. 'fr_FR' |
||
| 1953 | * |
||
| 1954 | * @return $this|ChildBannerImage The current object (for fluent API support) |
||
| 1955 | */ |
||
| 1956 | public function setLocale($locale = 'ru') |
||
| 1962 | |||
| 1963 | /** |
||
| 1964 | * Gets the locale for translations |
||
| 1965 | * |
||
| 1966 | * @return string $locale Locale to use for the translation, e.g. 'fr_FR' |
||
| 1967 | */ |
||
| 1968 | public function getLocale() |
||
| 1972 | |||
| 1973 | /** |
||
| 1974 | * Returns the current translation for a given locale |
||
| 1975 | * |
||
| 1976 | * @param string $locale Locale to use for the translation, e.g. 'fr_FR' |
||
| 1977 | * @param ConnectionInterface $con an optional connection object |
||
| 1978 | * |
||
| 1979 | * @return ChildBannerImageI18n */ |
||
| 1980 | View Code Duplication | public function getTranslation($locale = 'ru', ConnectionInterface $con = null) |
|
| 2006 | |||
| 2007 | /** |
||
| 2008 | * Remove the translation for a given locale |
||
| 2009 | * |
||
| 2010 | * @param string $locale Locale to use for the translation, e.g. 'fr_FR' |
||
| 2011 | * @param ConnectionInterface $con an optional connection object |
||
| 2012 | * |
||
| 2013 | * @return $this|ChildBannerImage The current object (for fluent API support) |
||
| 2014 | */ |
||
| 2015 | View Code Duplication | public function removeTranslation($locale = 'ru', ConnectionInterface $con = null) |
|
| 2034 | |||
| 2035 | /** |
||
| 2036 | * Returns the current translation |
||
| 2037 | * |
||
| 2038 | * @param ConnectionInterface $con an optional connection object |
||
| 2039 | * |
||
| 2040 | * @return ChildBannerImageI18n */ |
||
| 2041 | public function getCurrentTranslation(ConnectionInterface $con = null) |
||
| 2045 | |||
| 2046 | |||
| 2047 | /** |
||
| 2048 | * Get the [src] column value. |
||
| 2049 | * |
||
| 2050 | * @return string |
||
| 2051 | */ |
||
| 2052 | public function getSrc() |
||
| 2056 | |||
| 2057 | |||
| 2058 | /** |
||
| 2059 | * Set the value of [src] column. |
||
| 2060 | * |
||
| 2061 | * @param string $v new value |
||
| 2062 | * @return $this|\xbanners\models\BannerImageI18n The current object (for fluent API support) |
||
| 2063 | */ |
||
| 2064 | public function setSrc($v) |
||
| 2069 | |||
| 2070 | |||
| 2071 | /** |
||
| 2072 | * Get the [name] column value. |
||
| 2073 | * |
||
| 2074 | * @return string |
||
| 2075 | */ |
||
| 2076 | public function getName() |
||
| 2080 | |||
| 2081 | |||
| 2082 | /** |
||
| 2083 | * Set the value of [name] column. |
||
| 2084 | * |
||
| 2085 | * @param string $v new value |
||
| 2086 | * @return $this|\xbanners\models\BannerImageI18n The current object (for fluent API support) |
||
| 2087 | */ |
||
| 2088 | public function setName($v) |
||
| 2093 | |||
| 2094 | |||
| 2095 | /** |
||
| 2096 | * Get the [clicks] column value. |
||
| 2097 | * |
||
| 2098 | * @return int |
||
| 2099 | */ |
||
| 2100 | public function getClicks() |
||
| 2104 | |||
| 2105 | |||
| 2106 | /** |
||
| 2107 | * Set the value of [clicks] column. |
||
| 2108 | * |
||
| 2109 | * @param int $v new value |
||
| 2110 | * @return $this|\xbanners\models\BannerImageI18n The current object (for fluent API support) |
||
| 2111 | */ |
||
| 2112 | public function setClicks($v) |
||
| 2117 | |||
| 2118 | |||
| 2119 | /** |
||
| 2120 | * Get the [description] column value. |
||
| 2121 | * |
||
| 2122 | * @return string |
||
| 2123 | */ |
||
| 2124 | public function getDescription() |
||
| 2128 | |||
| 2129 | |||
| 2130 | /** |
||
| 2131 | * Set the value of [description] column. |
||
| 2132 | * |
||
| 2133 | * @param string $v new value |
||
| 2134 | * @return $this|\xbanners\models\BannerImageI18n The current object (for fluent API support) |
||
| 2135 | */ |
||
| 2136 | public function setDescription($v) |
||
| 2141 | |||
| 2142 | /** |
||
| 2143 | * Code to be run before persisting the object |
||
| 2144 | * @param ConnectionInterface $con |
||
| 2145 | * @return boolean |
||
| 2146 | */ |
||
| 2147 | public function preSave(ConnectionInterface $con = null) |
||
| 2154 | |||
| 2155 | /** |
||
| 2156 | * Code to be run after persisting the object |
||
| 2157 | * @param ConnectionInterface $con |
||
| 2158 | */ |
||
| 2159 | public function postSave(ConnectionInterface $con = null) |
||
| 2165 | |||
| 2166 | /** |
||
| 2167 | * Code to be run before inserting to database |
||
| 2168 | * @param ConnectionInterface $con |
||
| 2169 | * @return boolean |
||
| 2170 | */ |
||
| 2171 | public function preInsert(ConnectionInterface $con = null) |
||
| 2178 | |||
| 2179 | /** |
||
| 2180 | * Code to be run after inserting to database |
||
| 2181 | * @param ConnectionInterface $con |
||
| 2182 | */ |
||
| 2183 | public function postInsert(ConnectionInterface $con = null) |
||
| 2189 | |||
| 2190 | /** |
||
| 2191 | * Code to be run before updating the object in database |
||
| 2192 | * @param ConnectionInterface $con |
||
| 2193 | * @return boolean |
||
| 2194 | */ |
||
| 2195 | public function preUpdate(ConnectionInterface $con = null) |
||
| 2202 | |||
| 2203 | /** |
||
| 2204 | * Code to be run after updating the object in database |
||
| 2205 | * @param ConnectionInterface $con |
||
| 2206 | */ |
||
| 2207 | public function postUpdate(ConnectionInterface $con = null) |
||
| 2213 | |||
| 2214 | /** |
||
| 2215 | * Code to be run before deleting the object in database |
||
| 2216 | * @param ConnectionInterface $con |
||
| 2217 | * @return boolean |
||
| 2218 | */ |
||
| 2219 | public function preDelete(ConnectionInterface $con = null) |
||
| 2226 | |||
| 2227 | /** |
||
| 2228 | * Code to be run after deleting the object in database |
||
| 2229 | * @param ConnectionInterface $con |
||
| 2230 | */ |
||
| 2231 | public function postDelete(ConnectionInterface $con = null) |
||
| 2237 | |||
| 2238 | |||
| 2239 | /** |
||
| 2240 | * Derived method to catches calls to undefined methods. |
||
| 2241 | * |
||
| 2242 | * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). |
||
| 2243 | * Allows to define default __call() behavior if you overwrite __call() |
||
| 2244 | * |
||
| 2245 | * @param string $name |
||
| 2246 | * @param mixed $params |
||
| 2247 | * |
||
| 2248 | * @return array|string |
||
| 2249 | */ |
||
| 2250 | View Code Duplication | public function __call($name, $params) |
|
| 2279 | |||
| 2280 | } |
||
| 2281 |
This check compares the return type specified in the
@returnannotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.