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 PageLink 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 PageLink, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 34 | abstract class PageLink extends PropelBaseModelClass implements ActiveRecordInterface |
||
| 35 | { |
||
|
|
|||
| 36 | /** |
||
| 37 | * TableMap class name |
||
| 38 | */ |
||
| 39 | const TABLE_MAP = '\\mod_link\\models\\Map\\PageLinkTableMap'; |
||
| 40 | |||
| 41 | |||
| 42 | /** |
||
| 43 | * attribute to determine if this object has previously been saved. |
||
| 44 | * @var boolean |
||
| 45 | */ |
||
| 46 | protected $new = true; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * attribute to determine whether this object has been deleted. |
||
| 50 | * @var boolean |
||
| 51 | */ |
||
| 52 | protected $deleted = false; |
||
| 53 | |||
| 54 | /** |
||
| 55 | * The columns that have been modified in current object. |
||
| 56 | * Tracking modified columns allows us to only update modified columns. |
||
| 57 | * @var array |
||
| 58 | */ |
||
| 59 | protected $modifiedColumns = array(); |
||
| 60 | |||
| 61 | /** |
||
| 62 | * The (virtual) columns that are added at runtime |
||
| 63 | * The formatters can add supplementary columns based on a resultset |
||
| 64 | * @var array |
||
| 65 | */ |
||
| 66 | protected $virtualColumns = array(); |
||
| 67 | |||
| 68 | /** |
||
| 69 | * The value for the id field. |
||
| 70 | * |
||
| 71 | * @var int |
||
| 72 | */ |
||
| 73 | protected $id; |
||
| 74 | |||
| 75 | /** |
||
| 76 | * The value for the page_id field. |
||
| 77 | * |
||
| 78 | * @var int |
||
| 79 | */ |
||
| 80 | protected $page_id; |
||
| 81 | |||
| 82 | /** |
||
| 83 | * The value for the active_from field. |
||
| 84 | * |
||
| 85 | * @var int |
||
| 86 | */ |
||
| 87 | protected $active_from; |
||
| 88 | |||
| 89 | /** |
||
| 90 | * The value for the active_to field. |
||
| 91 | * |
||
| 92 | * @var int |
||
| 93 | */ |
||
| 94 | protected $active_to; |
||
| 95 | |||
| 96 | /** |
||
| 97 | * The value for the show_on field. |
||
| 98 | * |
||
| 99 | * @var boolean |
||
| 100 | */ |
||
| 101 | protected $show_on; |
||
| 102 | |||
| 103 | /** |
||
| 104 | * The value for the permanent field. |
||
| 105 | * |
||
| 106 | * @var boolean |
||
| 107 | */ |
||
| 108 | protected $permanent; |
||
| 109 | |||
| 110 | /** |
||
| 111 | * @var ObjectCollection|ChildPageLinkProduct[] Collection to store aggregation of ChildPageLinkProduct objects. |
||
| 112 | */ |
||
| 113 | protected $collPageLinkProducts; |
||
| 114 | protected $collPageLinkProductsPartial; |
||
| 115 | |||
| 116 | /** |
||
| 117 | * Flag to prevent endless save loop, if this object is referenced |
||
| 118 | * by another object which falls in this transaction. |
||
| 119 | * |
||
| 120 | * @var boolean |
||
| 121 | */ |
||
| 122 | protected $alreadyInSave = false; |
||
| 123 | |||
| 124 | /** |
||
| 125 | * An array of objects scheduled for deletion. |
||
| 126 | * @var ObjectCollection|ChildPageLinkProduct[] |
||
| 127 | */ |
||
| 128 | protected $pageLinkProductsScheduledForDeletion = null; |
||
| 129 | |||
| 130 | /** |
||
| 131 | * Initializes internal state of mod_link\models\Base\PageLink object. |
||
| 132 | */ |
||
| 133 | public function __construct() |
||
| 136 | |||
| 137 | /** |
||
| 138 | * Returns whether the object has been modified. |
||
| 139 | * |
||
| 140 | * @return boolean True if the object has been modified. |
||
| 141 | */ |
||
| 142 | public function isModified() |
||
| 146 | |||
| 147 | /** |
||
| 148 | * Has specified column been modified? |
||
| 149 | * |
||
| 150 | * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID |
||
| 151 | * @return boolean True if $col has been modified. |
||
| 152 | */ |
||
| 153 | public function isColumnModified($col) |
||
| 157 | |||
| 158 | /** |
||
| 159 | * Get the columns that have been modified in this object. |
||
| 160 | * @return array A unique list of the modified column names for this object. |
||
| 161 | */ |
||
| 162 | public function getModifiedColumns() |
||
| 166 | |||
| 167 | /** |
||
| 168 | * Returns whether the object has ever been saved. This will |
||
| 169 | * be false, if the object was retrieved from storage or was created |
||
| 170 | * and then saved. |
||
| 171 | * |
||
| 172 | * @return boolean true, if the object has never been persisted. |
||
| 173 | */ |
||
| 174 | public function isNew() |
||
| 178 | |||
| 179 | /** |
||
| 180 | * Setter for the isNew attribute. This method will be called |
||
| 181 | * by Propel-generated children and objects. |
||
| 182 | * |
||
| 183 | * @param boolean $b the state of the object. |
||
| 184 | */ |
||
| 185 | public function setNew($b) |
||
| 189 | |||
| 190 | /** |
||
| 191 | * Whether this object has been deleted. |
||
| 192 | * @return boolean The deleted state of this object. |
||
| 193 | */ |
||
| 194 | public function isDeleted() |
||
| 198 | |||
| 199 | /** |
||
| 200 | * Specify whether this object has been deleted. |
||
| 201 | * @param boolean $b The deleted state of this object. |
||
| 202 | * @return void |
||
| 203 | */ |
||
| 204 | public function setDeleted($b) |
||
| 208 | |||
| 209 | /** |
||
| 210 | * Sets the modified state for the object to be false. |
||
| 211 | * @param string $col If supplied, only the specified column is reset. |
||
| 212 | * @return void |
||
| 213 | */ |
||
| 214 | View Code Duplication | public function resetModified($col = null) |
|
| 224 | |||
| 225 | /** |
||
| 226 | * Compares this with another <code>PageLink</code> instance. If |
||
| 227 | * <code>obj</code> is an instance of <code>PageLink</code>, delegates to |
||
| 228 | * <code>equals(PageLink)</code>. Otherwise, returns <code>false</code>. |
||
| 229 | * |
||
| 230 | * @param mixed $obj The object to compare to. |
||
| 231 | * @return boolean Whether equal to the object specified. |
||
| 232 | */ |
||
| 233 | public function equals($obj) |
||
| 249 | |||
| 250 | /** |
||
| 251 | * Get the associative array of the virtual columns in this object |
||
| 252 | * |
||
| 253 | * @return array |
||
| 254 | */ |
||
| 255 | public function getVirtualColumns() |
||
| 259 | |||
| 260 | /** |
||
| 261 | * Checks the existence of a virtual column in this object |
||
| 262 | * |
||
| 263 | * @param string $name The virtual column name |
||
| 264 | * @return boolean |
||
| 265 | */ |
||
| 266 | public function hasVirtualColumn($name) |
||
| 270 | |||
| 271 | /** |
||
| 272 | * Get the value of a virtual column in this object |
||
| 273 | * |
||
| 274 | * @param string $name The virtual column name |
||
| 275 | * @return mixed |
||
| 276 | * |
||
| 277 | * @throws PropelException |
||
| 278 | */ |
||
| 279 | public function getVirtualColumn($name) |
||
| 287 | |||
| 288 | /** |
||
| 289 | * Set the value of a virtual column in this object |
||
| 290 | * |
||
| 291 | * @param string $name The virtual column name |
||
| 292 | * @param mixed $value The value to give to the virtual column |
||
| 293 | * |
||
| 294 | * @return $this|PageLink The current object, for fluid interface |
||
| 295 | */ |
||
| 296 | public function setVirtualColumn($name, $value) |
||
| 302 | |||
| 303 | /** |
||
| 304 | * Logs a message using Propel::log(). |
||
| 305 | * |
||
| 306 | * @param string $msg |
||
| 307 | * @param int $priority One of the Propel::LOG_* logging levels |
||
| 308 | * @return boolean |
||
| 309 | */ |
||
| 310 | protected function log($msg, $priority = Propel::LOG_INFO) |
||
| 314 | |||
| 315 | /** |
||
| 316 | * Export the current object properties to a string, using a given parser format |
||
| 317 | * <code> |
||
| 318 | * $book = BookQuery::create()->findPk(9012); |
||
| 319 | * echo $book->exportTo('JSON'); |
||
| 320 | * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
||
| 321 | * </code> |
||
| 322 | * |
||
| 323 | * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') |
||
| 324 | * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. |
||
| 325 | * @return string The exported data |
||
| 326 | */ |
||
| 327 | View Code Duplication | public function exportTo($parser, $includeLazyLoadColumns = true) |
|
| 335 | |||
| 336 | /** |
||
| 337 | * Clean up internal collections prior to serializing |
||
| 338 | * Avoids recursive loops that turn into segmentation faults when serializing |
||
| 339 | */ |
||
| 340 | View Code Duplication | public function __sleep() |
|
| 354 | |||
| 355 | /** |
||
| 356 | * Get the [id] column value. |
||
| 357 | * |
||
| 358 | * @return int |
||
| 359 | */ |
||
| 360 | public function getId() |
||
| 364 | |||
| 365 | /** |
||
| 366 | * Get the [page_id] column value. |
||
| 367 | * |
||
| 368 | * @return int |
||
| 369 | */ |
||
| 370 | public function getPageId() |
||
| 374 | |||
| 375 | /** |
||
| 376 | * Get the [active_from] column value. |
||
| 377 | * |
||
| 378 | * @return int |
||
| 379 | */ |
||
| 380 | public function getActiveFrom() |
||
| 384 | |||
| 385 | /** |
||
| 386 | * Get the [active_to] column value. |
||
| 387 | * |
||
| 388 | * @return int |
||
| 389 | */ |
||
| 390 | public function getActiveTo() |
||
| 394 | |||
| 395 | /** |
||
| 396 | * Get the [show_on] column value. |
||
| 397 | * |
||
| 398 | * @return boolean |
||
| 399 | */ |
||
| 400 | public function getShowOn() |
||
| 404 | |||
| 405 | /** |
||
| 406 | * Get the [show_on] column value. |
||
| 407 | * |
||
| 408 | * @return boolean |
||
| 409 | */ |
||
| 410 | public function isShowOn() |
||
| 414 | |||
| 415 | /** |
||
| 416 | * Get the [permanent] column value. |
||
| 417 | * |
||
| 418 | * @return boolean |
||
| 419 | */ |
||
| 420 | public function getPermanent() |
||
| 424 | |||
| 425 | /** |
||
| 426 | * Get the [permanent] column value. |
||
| 427 | * |
||
| 428 | * @return boolean |
||
| 429 | */ |
||
| 430 | public function isPermanent() |
||
| 434 | |||
| 435 | /** |
||
| 436 | * Set the value of [id] column. |
||
| 437 | * |
||
| 438 | * @param int $v new value |
||
| 439 | * @return $this|\mod_link\models\PageLink The current object (for fluent API support) |
||
| 440 | */ |
||
| 441 | View Code Duplication | public function setId($v) |
|
| 454 | |||
| 455 | /** |
||
| 456 | * Set the value of [page_id] column. |
||
| 457 | * |
||
| 458 | * @param int $v new value |
||
| 459 | * @return $this|\mod_link\models\PageLink The current object (for fluent API support) |
||
| 460 | */ |
||
| 461 | public function setPageId($v) |
||
| 474 | |||
| 475 | /** |
||
| 476 | * Set the value of [active_from] column. |
||
| 477 | * |
||
| 478 | * @param int $v new value |
||
| 479 | * @return $this|\mod_link\models\PageLink The current object (for fluent API support) |
||
| 480 | */ |
||
| 481 | public function setActiveFrom($v) |
||
| 494 | |||
| 495 | /** |
||
| 496 | * Set the value of [active_to] column. |
||
| 497 | * |
||
| 498 | * @param int $v new value |
||
| 499 | * @return $this|\mod_link\models\PageLink The current object (for fluent API support) |
||
| 500 | */ |
||
| 501 | public function setActiveTo($v) |
||
| 514 | |||
| 515 | /** |
||
| 516 | * Sets the value of the [show_on] column. |
||
| 517 | * Non-boolean arguments are converted using the following rules: |
||
| 518 | * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true |
||
| 519 | * * 0, '0', 'false', 'off', and 'no' are converted to boolean false |
||
| 520 | * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). |
||
| 521 | * |
||
| 522 | * @param boolean|integer|string $v The new value |
||
| 523 | * @return $this|\mod_link\models\PageLink The current object (for fluent API support) |
||
| 524 | */ |
||
| 525 | View Code Duplication | public function setShowOn($v) |
|
| 542 | |||
| 543 | /** |
||
| 544 | * Sets the value of the [permanent] column. |
||
| 545 | * Non-boolean arguments are converted using the following rules: |
||
| 546 | * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true |
||
| 547 | * * 0, '0', 'false', 'off', and 'no' are converted to boolean false |
||
| 548 | * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). |
||
| 549 | * |
||
| 550 | * @param boolean|integer|string $v The new value |
||
| 551 | * @return $this|\mod_link\models\PageLink The current object (for fluent API support) |
||
| 552 | */ |
||
| 553 | View Code Duplication | public function setPermanent($v) |
|
| 570 | |||
| 571 | /** |
||
| 572 | * Indicates whether the columns in this object are only set to default values. |
||
| 573 | * |
||
| 574 | * This method can be used in conjunction with isModified() to indicate whether an object is both |
||
| 575 | * modified _and_ has some values set which are non-default. |
||
| 576 | * |
||
| 577 | * @return boolean Whether the columns in this object are only been set with default values. |
||
| 578 | */ |
||
| 579 | public function hasOnlyDefaultValues() |
||
| 584 | |||
| 585 | /** |
||
| 586 | * Hydrates (populates) the object variables with values from the database resultset. |
||
| 587 | * |
||
| 588 | * An offset (0-based "start column") is specified so that objects can be hydrated |
||
| 589 | * with a subset of the columns in the resultset rows. This is needed, for example, |
||
| 590 | * for results of JOIN queries where the resultset row includes columns from two or |
||
| 591 | * more tables. |
||
| 592 | * |
||
| 593 | * @param array $row The row returned by DataFetcher->fetch(). |
||
| 594 | * @param int $startcol 0-based offset column which indicates which restultset column to start with. |
||
| 595 | * @param boolean $rehydrate Whether this object is being re-hydrated from the database. |
||
| 596 | * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
||
| 597 | One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
| 598 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 599 | * |
||
| 600 | * @return int next starting column |
||
| 601 | * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. |
||
| 602 | */ |
||
| 603 | public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) |
||
| 638 | |||
| 639 | /** |
||
| 640 | * Checks and repairs the internal consistency of the object. |
||
| 641 | * |
||
| 642 | * This method is executed after an already-instantiated object is re-hydrated |
||
| 643 | * from the database. It exists to check any foreign keys to make sure that |
||
| 644 | * the objects related to the current object are correct based on foreign key. |
||
| 645 | * |
||
| 646 | * You can override this method in the stub class, but you should always invoke |
||
| 647 | * the base method from the overridden method (i.e. parent::ensureConsistency()), |
||
| 648 | * in case your model changes. |
||
| 649 | * |
||
| 650 | * @throws PropelException |
||
| 651 | */ |
||
| 652 | public function ensureConsistency() |
||
| 655 | |||
| 656 | /** |
||
| 657 | * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. |
||
| 658 | * |
||
| 659 | * This will only work if the object has been saved and has a valid primary key set. |
||
| 660 | * |
||
| 661 | * @param boolean $deep (optional) Whether to also de-associated any related objects. |
||
| 662 | * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. |
||
| 663 | * @return void |
||
| 664 | * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db |
||
| 665 | */ |
||
| 666 | public function reload($deep = false, ConnectionInterface $con = null) |
||
| 697 | |||
| 698 | /** |
||
| 699 | * Removes this object from datastore and sets delete attribute. |
||
| 700 | * |
||
| 701 | * @param ConnectionInterface $con |
||
| 702 | * @return void |
||
| 703 | * @throws PropelException |
||
| 704 | * @see PageLink::setDeleted() |
||
| 705 | * @see PageLink::isDeleted() |
||
| 706 | */ |
||
| 707 | View Code Duplication | public function delete(ConnectionInterface $con = null) |
|
| 728 | |||
| 729 | /** |
||
| 730 | * Persists this object to the database. |
||
| 731 | * |
||
| 732 | * If the object is new, it inserts it; otherwise an update is performed. |
||
| 733 | * All modified related objects will also be persisted in the doSave() |
||
| 734 | * method. This method wraps all precipitate database operations in a |
||
| 735 | * single transaction. |
||
| 736 | * |
||
| 737 | * @param ConnectionInterface $con |
||
| 738 | * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
||
| 739 | * @throws PropelException |
||
| 740 | * @see doSave() |
||
| 741 | */ |
||
| 742 | View Code Duplication | public function save(ConnectionInterface $con = null) |
|
| 776 | |||
| 777 | /** |
||
| 778 | * Performs the work of inserting or updating the row in the database. |
||
| 779 | * |
||
| 780 | * If the object is new, it inserts it; otherwise an update is performed. |
||
| 781 | * All related objects are also updated in this method. |
||
| 782 | * |
||
| 783 | * @param ConnectionInterface $con |
||
| 784 | * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
||
| 785 | * @throws PropelException |
||
| 786 | * @see save() |
||
| 787 | */ |
||
| 788 | protected function doSave(ConnectionInterface $con) |
||
| 828 | |||
| 829 | /** |
||
| 830 | * Insert the row in the database. |
||
| 831 | * |
||
| 832 | * @param ConnectionInterface $con |
||
| 833 | * |
||
| 834 | * @throws PropelException |
||
| 835 | * @see doSave() |
||
| 836 | */ |
||
| 837 | View Code Duplication | protected function doInsert(ConnectionInterface $con) |
|
| 912 | |||
| 913 | /** |
||
| 914 | * Update the row in the database. |
||
| 915 | * |
||
| 916 | * @param ConnectionInterface $con |
||
| 917 | * |
||
| 918 | * @return Integer Number of updated rows |
||
| 919 | * @see doSave() |
||
| 920 | */ |
||
| 921 | protected function doUpdate(ConnectionInterface $con) |
||
| 928 | |||
| 929 | /** |
||
| 930 | * Retrieves a field from the object by name passed in as a string. |
||
| 931 | * |
||
| 932 | * @param string $name name |
||
| 933 | * @param string $type The type of fieldname the $name is of: |
||
| 934 | * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
| 935 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 936 | * Defaults to TableMap::TYPE_PHPNAME. |
||
| 937 | * @return mixed Value of field. |
||
| 938 | */ |
||
| 939 | public function getByName($name, $type = TableMap::TYPE_PHPNAME) |
||
| 946 | |||
| 947 | /** |
||
| 948 | * Retrieves a field from the object by Position as specified in the xml schema. |
||
| 949 | * Zero-based. |
||
| 950 | * |
||
| 951 | * @param int $pos position in xml schema |
||
| 952 | * @return mixed Value of field at $pos |
||
| 953 | */ |
||
| 954 | public function getByPosition($pos) |
||
| 980 | |||
| 981 | /** |
||
| 982 | * Exports the object as an array. |
||
| 983 | * |
||
| 984 | * You can specify the key type of the array by passing one of the class |
||
| 985 | * type constants. |
||
| 986 | * |
||
| 987 | * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
| 988 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 989 | * Defaults to TableMap::TYPE_PHPNAME. |
||
| 990 | * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. |
||
| 991 | * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion |
||
| 992 | * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. |
||
| 993 | * |
||
| 994 | * @return array an associative array containing the field names (as keys) and field values |
||
| 995 | */ |
||
| 996 | View Code Duplication | public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) |
|
| 1037 | |||
| 1038 | /** |
||
| 1039 | * Sets a field from the object by name passed in as a string. |
||
| 1040 | * |
||
| 1041 | * @param string $name |
||
| 1042 | * @param mixed $value field value |
||
| 1043 | * @param string $type The type of fieldname the $name is of: |
||
| 1044 | * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
| 1045 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1046 | * Defaults to TableMap::TYPE_PHPNAME. |
||
| 1047 | * @return $this|\mod_link\models\PageLink |
||
| 1048 | */ |
||
| 1049 | public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) |
||
| 1055 | |||
| 1056 | /** |
||
| 1057 | * Sets a field from the object by Position as specified in the xml schema. |
||
| 1058 | * Zero-based. |
||
| 1059 | * |
||
| 1060 | * @param int $pos position in xml schema |
||
| 1061 | * @param mixed $value field value |
||
| 1062 | * @return $this|\mod_link\models\PageLink |
||
| 1063 | */ |
||
| 1064 | public function setByPosition($pos, $value) |
||
| 1089 | |||
| 1090 | /** |
||
| 1091 | * Populates the object using an array. |
||
| 1092 | * |
||
| 1093 | * This is particularly useful when populating an object from one of the |
||
| 1094 | * request arrays (e.g. $_POST). This method goes through the column |
||
| 1095 | * names, checking to see whether a matching key exists in populated |
||
| 1096 | * array. If so the setByName() method is called for that column. |
||
| 1097 | * |
||
| 1098 | * You can specify the key type of the array by additionally passing one |
||
| 1099 | * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
| 1100 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1101 | * The default key type is the column's TableMap::TYPE_PHPNAME. |
||
| 1102 | * |
||
| 1103 | * @param array $arr An array to populate the object from. |
||
| 1104 | * @param string $keyType The type of keys the array uses. |
||
| 1105 | * @return void |
||
| 1106 | */ |
||
| 1107 | View Code Duplication | public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) |
|
| 1130 | |||
| 1131 | /** |
||
| 1132 | * Populate the current object from a string, using a given parser format |
||
| 1133 | * <code> |
||
| 1134 | * $book = new Book(); |
||
| 1135 | * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
||
| 1136 | * </code> |
||
| 1137 | * |
||
| 1138 | * You can specify the key type of the array by additionally passing one |
||
| 1139 | * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
| 1140 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1141 | * The default key type is the column's TableMap::TYPE_PHPNAME. |
||
| 1142 | * |
||
| 1143 | * @param mixed $parser A AbstractParser instance, |
||
| 1144 | * or a format name ('XML', 'YAML', 'JSON', 'CSV') |
||
| 1145 | * @param string $data The source data to import from |
||
| 1146 | * @param string $keyType The type of keys the array uses. |
||
| 1147 | * |
||
| 1148 | * @return $this|\mod_link\models\PageLink The current object, for fluid interface |
||
| 1149 | */ |
||
| 1150 | View Code Duplication | public function importFrom($parser, $data, $keyType = TableMap::TYPE_PHPNAME) |
|
| 1160 | |||
| 1161 | /** |
||
| 1162 | * Build a Criteria object containing the values of all modified columns in this object. |
||
| 1163 | * |
||
| 1164 | * @return Criteria The Criteria object containing all modified values. |
||
| 1165 | */ |
||
| 1166 | public function buildCriteria() |
||
| 1191 | |||
| 1192 | /** |
||
| 1193 | * Builds a Criteria object containing the primary key for this object. |
||
| 1194 | * |
||
| 1195 | * Unlike buildCriteria() this method includes the primary key values regardless |
||
| 1196 | * of whether or not they have been modified. |
||
| 1197 | * |
||
| 1198 | * @throws LogicException if no primary key is defined |
||
| 1199 | * |
||
| 1200 | * @return Criteria The Criteria object containing value(s) for primary key(s). |
||
| 1201 | */ |
||
| 1202 | public function buildPkeyCriteria() |
||
| 1209 | |||
| 1210 | /** |
||
| 1211 | * If the primary key is not null, return the hashcode of the |
||
| 1212 | * primary key. Otherwise, return the hash code of the object. |
||
| 1213 | * |
||
| 1214 | * @return int Hashcode |
||
| 1215 | */ |
||
| 1216 | View Code Duplication | public function hashCode() |
|
| 1231 | |||
| 1232 | /** |
||
| 1233 | * Returns the primary key for this object (row). |
||
| 1234 | * @return int |
||
| 1235 | */ |
||
| 1236 | public function getPrimaryKey() |
||
| 1240 | |||
| 1241 | /** |
||
| 1242 | * Generic method to set the primary key (id column). |
||
| 1243 | * |
||
| 1244 | * @param int $key Primary key. |
||
| 1245 | * @return void |
||
| 1246 | */ |
||
| 1247 | public function setPrimaryKey($key) |
||
| 1251 | |||
| 1252 | /** |
||
| 1253 | * Returns true if the primary key for this object is null. |
||
| 1254 | * @return boolean |
||
| 1255 | */ |
||
| 1256 | public function isPrimaryKeyNull() |
||
| 1260 | |||
| 1261 | /** |
||
| 1262 | * Sets contents of passed object to values from current object. |
||
| 1263 | * |
||
| 1264 | * If desired, this method can also make copies of all associated (fkey referrers) |
||
| 1265 | * objects. |
||
| 1266 | * |
||
| 1267 | * @param object $copyObj An object of \mod_link\models\PageLink (or compatible) type. |
||
| 1268 | * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
||
| 1269 | * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. |
||
| 1270 | * @throws PropelException |
||
| 1271 | */ |
||
| 1272 | public function copyInto($copyObj, $deepCopy = false, $makeNew = true) |
||
| 1298 | |||
| 1299 | /** |
||
| 1300 | * Makes a copy of this object that will be inserted as a new row in table when saved. |
||
| 1301 | * It creates a new object filling in the simple attributes, but skipping any primary |
||
| 1302 | * keys that are defined for the table. |
||
| 1303 | * |
||
| 1304 | * If desired, this method can also make copies of all associated (fkey referrers) |
||
| 1305 | * objects. |
||
| 1306 | * |
||
| 1307 | * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
||
| 1308 | * @return \mod_link\models\PageLink Clone of current object. |
||
| 1309 | * @throws PropelException |
||
| 1310 | */ |
||
| 1311 | public function copy($deepCopy = false) |
||
| 1320 | |||
| 1321 | |||
| 1322 | /** |
||
| 1323 | * Initializes a collection based on the name of a relation. |
||
| 1324 | * Avoids crafting an 'init[$relationName]s' method name |
||
| 1325 | * that wouldn't work when StandardEnglishPluralizer is used. |
||
| 1326 | * |
||
| 1327 | * @param string $relationName The name of the relation to initialize |
||
| 1328 | * @return void |
||
| 1329 | */ |
||
| 1330 | public function initRelation($relationName) |
||
| 1336 | |||
| 1337 | /** |
||
| 1338 | * Clears out the collPageLinkProducts collection |
||
| 1339 | * |
||
| 1340 | * This does not modify the database; however, it will remove any associated objects, causing |
||
| 1341 | * them to be refetched by subsequent calls to accessor method. |
||
| 1342 | * |
||
| 1343 | * @return void |
||
| 1344 | * @see addPageLinkProducts() |
||
| 1345 | */ |
||
| 1346 | public function clearPageLinkProducts() |
||
| 1350 | |||
| 1351 | /** |
||
| 1352 | * Reset is the collPageLinkProducts collection loaded partially. |
||
| 1353 | */ |
||
| 1354 | public function resetPartialPageLinkProducts($v = true) |
||
| 1358 | |||
| 1359 | /** |
||
| 1360 | * Initializes the collPageLinkProducts collection. |
||
| 1361 | * |
||
| 1362 | * By default this just sets the collPageLinkProducts collection to an empty array (like clearcollPageLinkProducts()); |
||
| 1363 | * however, you may wish to override this method in your stub class to provide setting appropriate |
||
| 1364 | * to your application -- for example, setting the initial array to the values stored in database. |
||
| 1365 | * |
||
| 1366 | * @param boolean $overrideExisting If set to true, the method call initializes |
||
| 1367 | * the collection even if it is not empty |
||
| 1368 | * |
||
| 1369 | * @return void |
||
| 1370 | */ |
||
| 1371 | View Code Duplication | public function initPageLinkProducts($overrideExisting = true) |
|
| 1382 | |||
| 1383 | /** |
||
| 1384 | * Gets an array of ChildPageLinkProduct objects which contain a foreign key that references this object. |
||
| 1385 | * |
||
| 1386 | * If the $criteria is not null, it is used to always fetch the results from the database. |
||
| 1387 | * Otherwise the results are fetched from the database the first time, then cached. |
||
| 1388 | * Next time the same method is called without $criteria, the cached collection is returned. |
||
| 1389 | * If this ChildPageLink is new, it will return |
||
| 1390 | * an empty collection or the current collection; the criteria is ignored on a new object. |
||
| 1391 | * |
||
| 1392 | * @param Criteria $criteria optional Criteria object to narrow the query |
||
| 1393 | * @param ConnectionInterface $con optional connection object |
||
| 1394 | * @return ObjectCollection|ChildPageLinkProduct[] List of ChildPageLinkProduct objects |
||
| 1395 | * @throws PropelException |
||
| 1396 | */ |
||
| 1397 | View Code Duplication | public function getPageLinkProducts(Criteria $criteria = null, ConnectionInterface $con = null) |
|
| 1440 | |||
| 1441 | /** |
||
| 1442 | * Sets a collection of ChildPageLinkProduct objects related by a one-to-many relationship |
||
| 1443 | * to the current object. |
||
| 1444 | * It will also schedule objects for deletion based on a diff between old objects (aka persisted) |
||
| 1445 | * and new objects from the given Propel collection. |
||
| 1446 | * |
||
| 1447 | * @param Collection $pageLinkProducts A Propel collection. |
||
| 1448 | * @param ConnectionInterface $con Optional connection object |
||
| 1449 | * @return $this|ChildPageLink The current object (for fluent API support) |
||
| 1450 | */ |
||
| 1451 | public function setPageLinkProducts(Collection $pageLinkProducts, ConnectionInterface $con = null) |
||
| 1476 | |||
| 1477 | /** |
||
| 1478 | * Returns the number of related PageLinkProduct objects. |
||
| 1479 | * |
||
| 1480 | * @param Criteria $criteria |
||
| 1481 | * @param boolean $distinct |
||
| 1482 | * @param ConnectionInterface $con |
||
| 1483 | * @return int Count of related PageLinkProduct objects. |
||
| 1484 | * @throws PropelException |
||
| 1485 | */ |
||
| 1486 | public function countPageLinkProducts(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) |
||
| 1510 | |||
| 1511 | /** |
||
| 1512 | * Method called to associate a ChildPageLinkProduct object to this object |
||
| 1513 | * through the ChildPageLinkProduct foreign key attribute. |
||
| 1514 | * |
||
| 1515 | * @param ChildPageLinkProduct $l ChildPageLinkProduct |
||
| 1516 | * @return $this|\mod_link\models\PageLink The current object (for fluent API support) |
||
| 1517 | */ |
||
| 1518 | public function addPageLinkProduct(ChildPageLinkProduct $l) |
||
| 1535 | |||
| 1536 | /** |
||
| 1537 | * @param ChildPageLinkProduct $pageLinkProduct The ChildPageLinkProduct object to add. |
||
| 1538 | */ |
||
| 1539 | protected function doAddPageLinkProduct(ChildPageLinkProduct $pageLinkProduct) |
||
| 1544 | |||
| 1545 | /** |
||
| 1546 | * @param ChildPageLinkProduct $pageLinkProduct The ChildPageLinkProduct object to remove. |
||
| 1547 | * @return $this|ChildPageLink The current object (for fluent API support) |
||
| 1548 | */ |
||
| 1549 | public function removePageLinkProduct(ChildPageLinkProduct $pageLinkProduct) |
||
| 1564 | |||
| 1565 | /** |
||
| 1566 | * Clears the current object, sets all attributes to their default values and removes |
||
| 1567 | * outgoing references as well as back-references (from other objects to this one. Results probably in a database |
||
| 1568 | * change of those foreign objects when you call `save` there). |
||
| 1569 | */ |
||
| 1570 | View Code Duplication | public function clear() |
|
| 1584 | |||
| 1585 | /** |
||
| 1586 | * Resets all references and back-references to other model objects or collections of model objects. |
||
| 1587 | * |
||
| 1588 | * This method is used to reset all php object references (not the actual reference in the database). |
||
| 1589 | * Necessary for object serialisation. |
||
| 1590 | * |
||
| 1591 | * @param boolean $deep Whether to also clear the references on all referrer objects. |
||
| 1592 | */ |
||
| 1593 | public function clearAllReferences($deep = false) |
||
| 1605 | |||
| 1606 | /** |
||
| 1607 | * Return the string representation of this object |
||
| 1608 | * |
||
| 1609 | * @return string |
||
| 1610 | */ |
||
| 1611 | public function __toString() |
||
| 1615 | |||
| 1616 | /** |
||
| 1617 | * Code to be run before persisting the object |
||
| 1618 | * @param ConnectionInterface $con |
||
| 1619 | * @return boolean |
||
| 1620 | */ |
||
| 1621 | public function preSave(ConnectionInterface $con = null) |
||
| 1628 | |||
| 1629 | /** |
||
| 1630 | * Code to be run after persisting the object |
||
| 1631 | * @param ConnectionInterface $con |
||
| 1632 | */ |
||
| 1633 | public function postSave(ConnectionInterface $con = null) |
||
| 1639 | |||
| 1640 | /** |
||
| 1641 | * Code to be run before inserting to database |
||
| 1642 | * @param ConnectionInterface $con |
||
| 1643 | * @return boolean |
||
| 1644 | */ |
||
| 1645 | public function preInsert(ConnectionInterface $con = null) |
||
| 1652 | |||
| 1653 | /** |
||
| 1654 | * Code to be run after inserting to database |
||
| 1655 | * @param ConnectionInterface $con |
||
| 1656 | */ |
||
| 1657 | public function postInsert(ConnectionInterface $con = null) |
||
| 1663 | |||
| 1664 | /** |
||
| 1665 | * Code to be run before updating the object in database |
||
| 1666 | * @param ConnectionInterface $con |
||
| 1667 | * @return boolean |
||
| 1668 | */ |
||
| 1669 | public function preUpdate(ConnectionInterface $con = null) |
||
| 1676 | |||
| 1677 | /** |
||
| 1678 | * Code to be run after updating the object in database |
||
| 1679 | * @param ConnectionInterface $con |
||
| 1680 | */ |
||
| 1681 | public function postUpdate(ConnectionInterface $con = null) |
||
| 1687 | |||
| 1688 | /** |
||
| 1689 | * Code to be run before deleting the object in database |
||
| 1690 | * @param ConnectionInterface $con |
||
| 1691 | * @return boolean |
||
| 1692 | */ |
||
| 1693 | public function preDelete(ConnectionInterface $con = null) |
||
| 1700 | |||
| 1701 | /** |
||
| 1702 | * Code to be run after deleting the object in database |
||
| 1703 | * @param ConnectionInterface $con |
||
| 1704 | */ |
||
| 1705 | public function postDelete(ConnectionInterface $con = null) |
||
| 1711 | |||
| 1712 | |||
| 1713 | /** |
||
| 1714 | * Derived method to catches calls to undefined methods. |
||
| 1715 | * |
||
| 1716 | * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). |
||
| 1717 | * Allows to define default __call() behavior if you overwrite __call() |
||
| 1718 | * |
||
| 1719 | * @param string $name |
||
| 1720 | * @param mixed $params |
||
| 1721 | * |
||
| 1722 | * @return array|string |
||
| 1723 | */ |
||
| 1724 | View Code Duplication | public function __call($name, $params) |
|
| 1753 | |||
| 1754 | } |
||
| 1755 |