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 User 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 User, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 38 | abstract class User implements ActiveRecordInterface |
||
| 39 | { |
||
| 40 | /** |
||
| 41 | * TableMap class name |
||
| 42 | */ |
||
| 43 | const TABLE_MAP = '\\Jalle19\\StatusManager\\Database\\Map\\UserTableMap'; |
||
| 44 | |||
| 45 | |||
| 46 | /** |
||
| 47 | * attribute to determine if this object has previously been saved. |
||
| 48 | * @var boolean |
||
| 49 | */ |
||
| 50 | protected $new = true; |
||
| 51 | |||
| 52 | /** |
||
| 53 | * attribute to determine whether this object has been deleted. |
||
| 54 | * @var boolean |
||
| 55 | */ |
||
| 56 | protected $deleted = false; |
||
| 57 | |||
| 58 | /** |
||
| 59 | * The columns that have been modified in current object. |
||
| 60 | * Tracking modified columns allows us to only update modified columns. |
||
| 61 | * @var array |
||
| 62 | */ |
||
| 63 | protected $modifiedColumns = array(); |
||
| 64 | |||
| 65 | /** |
||
| 66 | * The (virtual) columns that are added at runtime |
||
| 67 | * The formatters can add supplementary columns based on a resultset |
||
| 68 | * @var array |
||
| 69 | */ |
||
| 70 | protected $virtualColumns = array(); |
||
| 71 | |||
| 72 | /** |
||
| 73 | * The value for the id field. |
||
| 74 | * |
||
| 75 | * @var int |
||
| 76 | */ |
||
| 77 | protected $id; |
||
| 78 | |||
| 79 | /** |
||
| 80 | * The value for the instance_name field. |
||
| 81 | * |
||
| 82 | * @var string |
||
| 83 | */ |
||
| 84 | protected $instance_name; |
||
| 85 | |||
| 86 | /** |
||
| 87 | * The value for the name field. |
||
| 88 | * |
||
| 89 | * @var string |
||
| 90 | */ |
||
| 91 | protected $name; |
||
| 92 | |||
| 93 | /** |
||
| 94 | * @var ChildInstance |
||
| 95 | */ |
||
| 96 | protected $aInstance; |
||
| 97 | |||
| 98 | /** |
||
| 99 | * @var ObjectCollection|ChildConnection[] Collection to store aggregation of ChildConnection objects. |
||
| 100 | */ |
||
| 101 | protected $collConnections; |
||
| 102 | protected $collConnectionsPartial; |
||
| 103 | |||
| 104 | /** |
||
| 105 | * @var ObjectCollection|ChildSubscription[] Collection to store aggregation of ChildSubscription objects. |
||
| 106 | */ |
||
| 107 | protected $collSubscriptions; |
||
| 108 | protected $collSubscriptionsPartial; |
||
| 109 | |||
| 110 | /** |
||
| 111 | * Flag to prevent endless save loop, if this object is referenced |
||
| 112 | * by another object which falls in this transaction. |
||
| 113 | * |
||
| 114 | * @var boolean |
||
| 115 | */ |
||
| 116 | protected $alreadyInSave = false; |
||
| 117 | |||
| 118 | /** |
||
| 119 | * An array of objects scheduled for deletion. |
||
| 120 | * @var ObjectCollection|ChildConnection[] |
||
| 121 | */ |
||
| 122 | protected $connectionsScheduledForDeletion = null; |
||
| 123 | |||
| 124 | /** |
||
| 125 | * An array of objects scheduled for deletion. |
||
| 126 | * @var ObjectCollection|ChildSubscription[] |
||
| 127 | */ |
||
| 128 | protected $subscriptionsScheduledForDeletion = null; |
||
| 129 | |||
| 130 | /** |
||
| 131 | * Initializes internal state of Jalle19\StatusManager\Database\Base\User 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>User</code> instance. If |
||
| 227 | * <code>obj</code> is an instance of <code>User</code>, delegates to |
||
| 228 | * <code>equals(User)</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 | View Code Duplication | 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 | View Code Duplication | 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|User 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 [instance_name] column value. |
||
| 367 | * |
||
| 368 | * @return string |
||
| 369 | */ |
||
| 370 | public function getInstanceName() |
||
| 374 | |||
| 375 | /** |
||
| 376 | * Get the [name] column value. |
||
| 377 | * |
||
| 378 | * @return string |
||
| 379 | */ |
||
| 380 | public function getName() |
||
| 384 | |||
| 385 | /** |
||
| 386 | * Set the value of [id] column. |
||
| 387 | * |
||
| 388 | * @param int $v new value |
||
| 389 | * @return $this|\Jalle19\StatusManager\Database\User The current object (for fluent API support) |
||
| 390 | */ |
||
| 391 | public function setId($v) |
||
| 404 | |||
| 405 | /** |
||
| 406 | * Set the value of [instance_name] column. |
||
| 407 | * |
||
| 408 | * @param string $v new value |
||
| 409 | * @return $this|\Jalle19\StatusManager\Database\User The current object (for fluent API support) |
||
| 410 | */ |
||
| 411 | View Code Duplication | public function setInstanceName($v) |
|
| 428 | |||
| 429 | /** |
||
| 430 | * Set the value of [name] column. |
||
| 431 | * |
||
| 432 | * @param string $v new value |
||
| 433 | * @return $this|\Jalle19\StatusManager\Database\User The current object (for fluent API support) |
||
| 434 | */ |
||
| 435 | public function setName($v) |
||
| 448 | |||
| 449 | /** |
||
| 450 | * Indicates whether the columns in this object are only set to default values. |
||
| 451 | * |
||
| 452 | * This method can be used in conjunction with isModified() to indicate whether an object is both |
||
| 453 | * modified _and_ has some values set which are non-default. |
||
| 454 | * |
||
| 455 | * @return boolean Whether the columns in this object are only been set with default values. |
||
| 456 | */ |
||
| 457 | public function hasOnlyDefaultValues() |
||
| 462 | |||
| 463 | /** |
||
| 464 | * Hydrates (populates) the object variables with values from the database resultset. |
||
| 465 | * |
||
| 466 | * An offset (0-based "start column") is specified so that objects can be hydrated |
||
| 467 | * with a subset of the columns in the resultset rows. This is needed, for example, |
||
| 468 | * for results of JOIN queries where the resultset row includes columns from two or |
||
| 469 | * more tables. |
||
| 470 | * |
||
| 471 | * @param array $row The row returned by DataFetcher->fetch(). |
||
| 472 | * @param int $startcol 0-based offset column which indicates which restultset column to start with. |
||
| 473 | * @param boolean $rehydrate Whether this object is being re-hydrated from the database. |
||
| 474 | * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
||
| 475 | One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
| 476 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 477 | * |
||
| 478 | * @return int next starting column |
||
| 479 | * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. |
||
| 480 | */ |
||
| 481 | View Code Duplication | public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) |
|
| 507 | |||
| 508 | /** |
||
| 509 | * Checks and repairs the internal consistency of the object. |
||
| 510 | * |
||
| 511 | * This method is executed after an already-instantiated object is re-hydrated |
||
| 512 | * from the database. It exists to check any foreign keys to make sure that |
||
| 513 | * the objects related to the current object are correct based on foreign key. |
||
| 514 | * |
||
| 515 | * You can override this method in the stub class, but you should always invoke |
||
| 516 | * the base method from the overridden method (i.e. parent::ensureConsistency()), |
||
| 517 | * in case your model changes. |
||
| 518 | * |
||
| 519 | * @throws PropelException |
||
| 520 | */ |
||
| 521 | public function ensureConsistency() |
||
| 527 | |||
| 528 | /** |
||
| 529 | * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. |
||
| 530 | * |
||
| 531 | * This will only work if the object has been saved and has a valid primary key set. |
||
| 532 | * |
||
| 533 | * @param boolean $deep (optional) Whether to also de-associated any related objects. |
||
| 534 | * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. |
||
| 535 | * @return void |
||
| 536 | * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db |
||
| 537 | */ |
||
| 538 | View Code Duplication | public function reload($deep = false, ConnectionInterface $con = null) |
|
| 572 | |||
| 573 | /** |
||
| 574 | * Removes this object from datastore and sets delete attribute. |
||
| 575 | * |
||
| 576 | * @param ConnectionInterface $con |
||
| 577 | * @return void |
||
| 578 | * @throws PropelException |
||
| 579 | * @see User::setDeleted() |
||
| 580 | * @see User::isDeleted() |
||
| 581 | */ |
||
| 582 | View Code Duplication | public function delete(ConnectionInterface $con = null) |
|
| 603 | |||
| 604 | /** |
||
| 605 | * Persists this object to the database. |
||
| 606 | * |
||
| 607 | * If the object is new, it inserts it; otherwise an update is performed. |
||
| 608 | * All modified related objects will also be persisted in the doSave() |
||
| 609 | * method. This method wraps all precipitate database operations in a |
||
| 610 | * single transaction. |
||
| 611 | * |
||
| 612 | * @param ConnectionInterface $con |
||
| 613 | * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
||
| 614 | * @throws PropelException |
||
| 615 | * @see doSave() |
||
| 616 | */ |
||
| 617 | View Code Duplication | public function save(ConnectionInterface $con = null) |
|
| 651 | |||
| 652 | /** |
||
| 653 | * Performs the work of inserting or updating the row in the database. |
||
| 654 | * |
||
| 655 | * If the object is new, it inserts it; otherwise an update is performed. |
||
| 656 | * All related objects are also updated in this method. |
||
| 657 | * |
||
| 658 | * @param ConnectionInterface $con |
||
| 659 | * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
||
| 660 | * @throws PropelException |
||
| 661 | * @see save() |
||
| 662 | */ |
||
| 663 | protected function doSave(ConnectionInterface $con) |
||
| 734 | |||
| 735 | /** |
||
| 736 | * Insert the row in the database. |
||
| 737 | * |
||
| 738 | * @param ConnectionInterface $con |
||
| 739 | * |
||
| 740 | * @throws PropelException |
||
| 741 | * @see doSave() |
||
| 742 | */ |
||
| 743 | View Code Duplication | protected function doInsert(ConnectionInterface $con) |
|
| 800 | |||
| 801 | /** |
||
| 802 | * Update the row in the database. |
||
| 803 | * |
||
| 804 | * @param ConnectionInterface $con |
||
| 805 | * |
||
| 806 | * @return Integer Number of updated rows |
||
| 807 | * @see doSave() |
||
| 808 | */ |
||
| 809 | protected function doUpdate(ConnectionInterface $con) |
||
| 816 | |||
| 817 | /** |
||
| 818 | * Retrieves a field from the object by name passed in as a string. |
||
| 819 | * |
||
| 820 | * @param string $name name |
||
| 821 | * @param string $type The type of fieldname the $name is of: |
||
| 822 | * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
| 823 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 824 | * Defaults to TableMap::TYPE_PHPNAME. |
||
| 825 | * @return mixed Value of field. |
||
| 826 | */ |
||
| 827 | View Code Duplication | public function getByName($name, $type = TableMap::TYPE_PHPNAME) |
|
| 834 | |||
| 835 | /** |
||
| 836 | * Retrieves a field from the object by Position as specified in the xml schema. |
||
| 837 | * Zero-based. |
||
| 838 | * |
||
| 839 | * @param int $pos position in xml schema |
||
| 840 | * @return mixed Value of field at $pos |
||
| 841 | */ |
||
| 842 | View Code Duplication | public function getByPosition($pos) |
|
| 859 | |||
| 860 | /** |
||
| 861 | * Exports the object as an array. |
||
| 862 | * |
||
| 863 | * You can specify the key type of the array by passing one of the class |
||
| 864 | * type constants. |
||
| 865 | * |
||
| 866 | * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
| 867 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 868 | * Defaults to TableMap::TYPE_PHPNAME. |
||
| 869 | * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. |
||
| 870 | * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion |
||
| 871 | * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. |
||
| 872 | * |
||
| 873 | * @return array an associative array containing the field names (as keys) and field values |
||
| 874 | */ |
||
| 875 | public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) |
||
| 943 | |||
| 944 | /** |
||
| 945 | * Sets a field from the object by name passed in as a string. |
||
| 946 | * |
||
| 947 | * @param string $name |
||
| 948 | * @param mixed $value field value |
||
| 949 | * @param string $type The type of fieldname the $name is of: |
||
| 950 | * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
| 951 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 952 | * Defaults to TableMap::TYPE_PHPNAME. |
||
| 953 | * @return $this|\Jalle19\StatusManager\Database\User |
||
| 954 | */ |
||
| 955 | public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) |
||
| 961 | |||
| 962 | /** |
||
| 963 | * Sets a field from the object by Position as specified in the xml schema. |
||
| 964 | * Zero-based. |
||
| 965 | * |
||
| 966 | * @param int $pos position in xml schema |
||
| 967 | * @param mixed $value field value |
||
| 968 | * @return $this|\Jalle19\StatusManager\Database\User |
||
| 969 | */ |
||
| 970 | View Code Duplication | public function setByPosition($pos, $value) |
|
| 986 | |||
| 987 | /** |
||
| 988 | * Populates the object using an array. |
||
| 989 | * |
||
| 990 | * This is particularly useful when populating an object from one of the |
||
| 991 | * request arrays (e.g. $_POST). This method goes through the column |
||
| 992 | * names, checking to see whether a matching key exists in populated |
||
| 993 | * array. If so the setByName() method is called for that column. |
||
| 994 | * |
||
| 995 | * You can specify the key type of the array by additionally passing one |
||
| 996 | * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
| 997 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 998 | * The default key type is the column's TableMap::TYPE_PHPNAME. |
||
| 999 | * |
||
| 1000 | * @param array $arr An array to populate the object from. |
||
| 1001 | * @param string $keyType The type of keys the array uses. |
||
| 1002 | * @return void |
||
| 1003 | */ |
||
| 1004 | View Code Duplication | public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) |
|
| 1018 | |||
| 1019 | /** |
||
| 1020 | * Populate the current object from a string, using a given parser format |
||
| 1021 | * <code> |
||
| 1022 | * $book = new Book(); |
||
| 1023 | * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
||
| 1024 | * </code> |
||
| 1025 | * |
||
| 1026 | * You can specify the key type of the array by additionally passing one |
||
| 1027 | * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
| 1028 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1029 | * The default key type is the column's TableMap::TYPE_PHPNAME. |
||
| 1030 | * |
||
| 1031 | * @param mixed $parser A AbstractParser instance, |
||
| 1032 | * or a format name ('XML', 'YAML', 'JSON', 'CSV') |
||
| 1033 | * @param string $data The source data to import from |
||
| 1034 | * @param string $keyType The type of keys the array uses. |
||
| 1035 | * |
||
| 1036 | * @return $this|\Jalle19\StatusManager\Database\User The current object, for fluid interface |
||
| 1037 | */ |
||
| 1038 | View Code Duplication | public function importFrom($parser, $data, $keyType = TableMap::TYPE_PHPNAME) |
|
| 1048 | |||
| 1049 | /** |
||
| 1050 | * Build a Criteria object containing the values of all modified columns in this object. |
||
| 1051 | * |
||
| 1052 | * @return Criteria The Criteria object containing all modified values. |
||
| 1053 | */ |
||
| 1054 | View Code Duplication | public function buildCriteria() |
|
| 1070 | |||
| 1071 | /** |
||
| 1072 | * Builds a Criteria object containing the primary key for this object. |
||
| 1073 | * |
||
| 1074 | * Unlike buildCriteria() this method includes the primary key values regardless |
||
| 1075 | * of whether or not they have been modified. |
||
| 1076 | * |
||
| 1077 | * @throws LogicException if no primary key is defined |
||
| 1078 | * |
||
| 1079 | * @return Criteria The Criteria object containing value(s) for primary key(s). |
||
| 1080 | */ |
||
| 1081 | public function buildPkeyCriteria() |
||
| 1088 | |||
| 1089 | /** |
||
| 1090 | * If the primary key is not null, return the hashcode of the |
||
| 1091 | * primary key. Otherwise, return the hash code of the object. |
||
| 1092 | * |
||
| 1093 | * @return int Hashcode |
||
| 1094 | */ |
||
| 1095 | View Code Duplication | public function hashCode() |
|
| 1110 | |||
| 1111 | /** |
||
| 1112 | * Returns the primary key for this object (row). |
||
| 1113 | * @return int |
||
| 1114 | */ |
||
| 1115 | public function getPrimaryKey() |
||
| 1119 | |||
| 1120 | /** |
||
| 1121 | * Generic method to set the primary key (id column). |
||
| 1122 | * |
||
| 1123 | * @param int $key Primary key. |
||
| 1124 | * @return void |
||
| 1125 | */ |
||
| 1126 | public function setPrimaryKey($key) |
||
| 1130 | |||
| 1131 | /** |
||
| 1132 | * Returns true if the primary key for this object is null. |
||
| 1133 | * @return boolean |
||
| 1134 | */ |
||
| 1135 | public function isPrimaryKeyNull() |
||
| 1139 | |||
| 1140 | /** |
||
| 1141 | * Sets contents of passed object to values from current object. |
||
| 1142 | * |
||
| 1143 | * If desired, this method can also make copies of all associated (fkey referrers) |
||
| 1144 | * objects. |
||
| 1145 | * |
||
| 1146 | * @param object $copyObj An object of \Jalle19\StatusManager\Database\User (or compatible) type. |
||
| 1147 | * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
||
| 1148 | * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. |
||
| 1149 | * @throws PropelException |
||
| 1150 | */ |
||
| 1151 | public function copyInto($copyObj, $deepCopy = false, $makeNew = true) |
||
| 1180 | |||
| 1181 | /** |
||
| 1182 | * Makes a copy of this object that will be inserted as a new row in table when saved. |
||
| 1183 | * It creates a new object filling in the simple attributes, but skipping any primary |
||
| 1184 | * keys that are defined for the table. |
||
| 1185 | * |
||
| 1186 | * If desired, this method can also make copies of all associated (fkey referrers) |
||
| 1187 | * objects. |
||
| 1188 | * |
||
| 1189 | * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
||
| 1190 | * @return \Jalle19\StatusManager\Database\User Clone of current object. |
||
| 1191 | * @throws PropelException |
||
| 1192 | */ |
||
| 1193 | View Code Duplication | public function copy($deepCopy = false) |
|
| 1202 | |||
| 1203 | /** |
||
| 1204 | * Declares an association between this object and a ChildInstance object. |
||
| 1205 | * |
||
| 1206 | * @param ChildInstance $v |
||
| 1207 | * @return $this|\Jalle19\StatusManager\Database\User The current object (for fluent API support) |
||
| 1208 | * @throws PropelException |
||
| 1209 | */ |
||
| 1210 | public function setInstance(ChildInstance $v = null) |
||
| 1229 | |||
| 1230 | |||
| 1231 | /** |
||
| 1232 | * Get the associated ChildInstance object |
||
| 1233 | * |
||
| 1234 | * @param ConnectionInterface $con Optional Connection object. |
||
| 1235 | * @return ChildInstance The associated ChildInstance object. |
||
| 1236 | * @throws PropelException |
||
| 1237 | */ |
||
| 1238 | View Code Duplication | public function getInstance(ConnectionInterface $con = null) |
|
| 1253 | |||
| 1254 | |||
| 1255 | /** |
||
| 1256 | * Initializes a collection based on the name of a relation. |
||
| 1257 | * Avoids crafting an 'init[$relationName]s' method name |
||
| 1258 | * that wouldn't work when StandardEnglishPluralizer is used. |
||
| 1259 | * |
||
| 1260 | * @param string $relationName The name of the relation to initialize |
||
| 1261 | * @return void |
||
| 1262 | */ |
||
| 1263 | public function initRelation($relationName) |
||
| 1272 | |||
| 1273 | /** |
||
| 1274 | * Clears out the collConnections collection |
||
| 1275 | * |
||
| 1276 | * This does not modify the database; however, it will remove any associated objects, causing |
||
| 1277 | * them to be refetched by subsequent calls to accessor method. |
||
| 1278 | * |
||
| 1279 | * @return void |
||
| 1280 | * @see addConnections() |
||
| 1281 | */ |
||
| 1282 | public function clearConnections() |
||
| 1286 | |||
| 1287 | /** |
||
| 1288 | * Reset is the collConnections collection loaded partially. |
||
| 1289 | */ |
||
| 1290 | public function resetPartialConnections($v = true) |
||
| 1294 | |||
| 1295 | /** |
||
| 1296 | * Initializes the collConnections collection. |
||
| 1297 | * |
||
| 1298 | * By default this just sets the collConnections collection to an empty array (like clearcollConnections()); |
||
| 1299 | * however, you may wish to override this method in your stub class to provide setting appropriate |
||
| 1300 | * to your application -- for example, setting the initial array to the values stored in database. |
||
| 1301 | * |
||
| 1302 | * @param boolean $overrideExisting If set to true, the method call initializes |
||
| 1303 | * the collection even if it is not empty |
||
| 1304 | * |
||
| 1305 | * @return void |
||
| 1306 | */ |
||
| 1307 | View Code Duplication | public function initConnections($overrideExisting = true) |
|
| 1318 | |||
| 1319 | /** |
||
| 1320 | * Gets an array of ChildConnection objects which contain a foreign key that references this object. |
||
| 1321 | * |
||
| 1322 | * If the $criteria is not null, it is used to always fetch the results from the database. |
||
| 1323 | * Otherwise the results are fetched from the database the first time, then cached. |
||
| 1324 | * Next time the same method is called without $criteria, the cached collection is returned. |
||
| 1325 | * If this ChildUser is new, it will return |
||
| 1326 | * an empty collection or the current collection; the criteria is ignored on a new object. |
||
| 1327 | * |
||
| 1328 | * @param Criteria $criteria optional Criteria object to narrow the query |
||
| 1329 | * @param ConnectionInterface $con optional connection object |
||
| 1330 | * @return ObjectCollection|ChildConnection[] List of ChildConnection objects |
||
| 1331 | * @throws PropelException |
||
| 1332 | */ |
||
| 1333 | View Code Duplication | public function getConnections(Criteria $criteria = null, ConnectionInterface $con = null) |
|
| 1376 | |||
| 1377 | /** |
||
| 1378 | * Sets a collection of ChildConnection objects related by a one-to-many relationship |
||
| 1379 | * to the current object. |
||
| 1380 | * It will also schedule objects for deletion based on a diff between old objects (aka persisted) |
||
| 1381 | * and new objects from the given Propel collection. |
||
| 1382 | * |
||
| 1383 | * @param Collection $connections A Propel collection. |
||
| 1384 | * @param ConnectionInterface $con Optional connection object |
||
| 1385 | * @return $this|ChildUser The current object (for fluent API support) |
||
| 1386 | */ |
||
| 1387 | View Code Duplication | public function setConnections(Collection $connections, ConnectionInterface $con = null) |
|
| 1409 | |||
| 1410 | /** |
||
| 1411 | * Returns the number of related Connection objects. |
||
| 1412 | * |
||
| 1413 | * @param Criteria $criteria |
||
| 1414 | * @param boolean $distinct |
||
| 1415 | * @param ConnectionInterface $con |
||
| 1416 | * @return int Count of related Connection objects. |
||
| 1417 | * @throws PropelException |
||
| 1418 | */ |
||
| 1419 | View Code Duplication | public function countConnections(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) |
|
| 1443 | |||
| 1444 | /** |
||
| 1445 | * Method called to associate a ChildConnection object to this object |
||
| 1446 | * through the ChildConnection foreign key attribute. |
||
| 1447 | * |
||
| 1448 | * @param ChildConnection $l ChildConnection |
||
| 1449 | * @return $this|\Jalle19\StatusManager\Database\User The current object (for fluent API support) |
||
| 1450 | */ |
||
| 1451 | View Code Duplication | public function addConnection(ChildConnection $l) |
|
| 1468 | |||
| 1469 | /** |
||
| 1470 | * @param ChildConnection $connection The ChildConnection object to add. |
||
| 1471 | */ |
||
| 1472 | protected function doAddConnection(ChildConnection $connection) |
||
| 1477 | |||
| 1478 | /** |
||
| 1479 | * @param ChildConnection $connection The ChildConnection object to remove. |
||
| 1480 | * @return $this|ChildUser The current object (for fluent API support) |
||
| 1481 | */ |
||
| 1482 | View Code Duplication | public function removeConnection(ChildConnection $connection) |
|
| 1497 | |||
| 1498 | |||
| 1499 | /** |
||
| 1500 | * If this collection has already been initialized with |
||
| 1501 | * an identical criteria, it returns the collection. |
||
| 1502 | * Otherwise if this User is new, it will return |
||
| 1503 | * an empty collection; or if this User has previously |
||
| 1504 | * been saved, it will retrieve related Connections from storage. |
||
| 1505 | * |
||
| 1506 | * This method is protected by default in order to keep the public |
||
| 1507 | * api reasonable. You can provide public methods for those you |
||
| 1508 | * actually need in User. |
||
| 1509 | * |
||
| 1510 | * @param Criteria $criteria optional Criteria object to narrow the query |
||
| 1511 | * @param ConnectionInterface $con optional connection object |
||
| 1512 | * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
||
| 1513 | * @return ObjectCollection|ChildConnection[] List of ChildConnection objects |
||
| 1514 | */ |
||
| 1515 | View Code Duplication | public function getConnectionsJoinInstance(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 1522 | |||
| 1523 | /** |
||
| 1524 | * Clears out the collSubscriptions collection |
||
| 1525 | * |
||
| 1526 | * This does not modify the database; however, it will remove any associated objects, causing |
||
| 1527 | * them to be refetched by subsequent calls to accessor method. |
||
| 1528 | * |
||
| 1529 | * @return void |
||
| 1530 | * @see addSubscriptions() |
||
| 1531 | */ |
||
| 1532 | public function clearSubscriptions() |
||
| 1536 | |||
| 1537 | /** |
||
| 1538 | * Reset is the collSubscriptions collection loaded partially. |
||
| 1539 | */ |
||
| 1540 | public function resetPartialSubscriptions($v = true) |
||
| 1544 | |||
| 1545 | /** |
||
| 1546 | * Initializes the collSubscriptions collection. |
||
| 1547 | * |
||
| 1548 | * By default this just sets the collSubscriptions collection to an empty array (like clearcollSubscriptions()); |
||
| 1549 | * however, you may wish to override this method in your stub class to provide setting appropriate |
||
| 1550 | * to your application -- for example, setting the initial array to the values stored in database. |
||
| 1551 | * |
||
| 1552 | * @param boolean $overrideExisting If set to true, the method call initializes |
||
| 1553 | * the collection even if it is not empty |
||
| 1554 | * |
||
| 1555 | * @return void |
||
| 1556 | */ |
||
| 1557 | View Code Duplication | public function initSubscriptions($overrideExisting = true) |
|
| 1568 | |||
| 1569 | /** |
||
| 1570 | * Gets an array of ChildSubscription objects which contain a foreign key that references this object. |
||
| 1571 | * |
||
| 1572 | * If the $criteria is not null, it is used to always fetch the results from the database. |
||
| 1573 | * Otherwise the results are fetched from the database the first time, then cached. |
||
| 1574 | * Next time the same method is called without $criteria, the cached collection is returned. |
||
| 1575 | * If this ChildUser is new, it will return |
||
| 1576 | * an empty collection or the current collection; the criteria is ignored on a new object. |
||
| 1577 | * |
||
| 1578 | * @param Criteria $criteria optional Criteria object to narrow the query |
||
| 1579 | * @param ConnectionInterface $con optional connection object |
||
| 1580 | * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
||
| 1581 | * @throws PropelException |
||
| 1582 | */ |
||
| 1583 | View Code Duplication | public function getSubscriptions(Criteria $criteria = null, ConnectionInterface $con = null) |
|
| 1626 | |||
| 1627 | /** |
||
| 1628 | * Sets a collection of ChildSubscription objects related by a one-to-many relationship |
||
| 1629 | * to the current object. |
||
| 1630 | * It will also schedule objects for deletion based on a diff between old objects (aka persisted) |
||
| 1631 | * and new objects from the given Propel collection. |
||
| 1632 | * |
||
| 1633 | * @param Collection $subscriptions A Propel collection. |
||
| 1634 | * @param ConnectionInterface $con Optional connection object |
||
| 1635 | * @return $this|ChildUser The current object (for fluent API support) |
||
| 1636 | */ |
||
| 1637 | View Code Duplication | public function setSubscriptions(Collection $subscriptions, ConnectionInterface $con = null) |
|
| 1659 | |||
| 1660 | /** |
||
| 1661 | * Returns the number of related Subscription objects. |
||
| 1662 | * |
||
| 1663 | * @param Criteria $criteria |
||
| 1664 | * @param boolean $distinct |
||
| 1665 | * @param ConnectionInterface $con |
||
| 1666 | * @return int Count of related Subscription objects. |
||
| 1667 | * @throws PropelException |
||
| 1668 | */ |
||
| 1669 | View Code Duplication | public function countSubscriptions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) |
|
| 1693 | |||
| 1694 | /** |
||
| 1695 | * Method called to associate a ChildSubscription object to this object |
||
| 1696 | * through the ChildSubscription foreign key attribute. |
||
| 1697 | * |
||
| 1698 | * @param ChildSubscription $l ChildSubscription |
||
| 1699 | * @return $this|\Jalle19\StatusManager\Database\User The current object (for fluent API support) |
||
| 1700 | */ |
||
| 1701 | View Code Duplication | public function addSubscription(ChildSubscription $l) |
|
| 1718 | |||
| 1719 | /** |
||
| 1720 | * @param ChildSubscription $subscription The ChildSubscription object to add. |
||
| 1721 | */ |
||
| 1722 | protected function doAddSubscription(ChildSubscription $subscription) |
||
| 1727 | |||
| 1728 | /** |
||
| 1729 | * @param ChildSubscription $subscription The ChildSubscription object to remove. |
||
| 1730 | * @return $this|ChildUser The current object (for fluent API support) |
||
| 1731 | */ |
||
| 1732 | View Code Duplication | public function removeSubscription(ChildSubscription $subscription) |
|
| 1747 | |||
| 1748 | |||
| 1749 | /** |
||
| 1750 | * If this collection has already been initialized with |
||
| 1751 | * an identical criteria, it returns the collection. |
||
| 1752 | * Otherwise if this User is new, it will return |
||
| 1753 | * an empty collection; or if this User has previously |
||
| 1754 | * been saved, it will retrieve related Subscriptions from storage. |
||
| 1755 | * |
||
| 1756 | * This method is protected by default in order to keep the public |
||
| 1757 | * api reasonable. You can provide public methods for those you |
||
| 1758 | * actually need in User. |
||
| 1759 | * |
||
| 1760 | * @param Criteria $criteria optional Criteria object to narrow the query |
||
| 1761 | * @param ConnectionInterface $con optional connection object |
||
| 1762 | * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
||
| 1763 | * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
||
| 1764 | */ |
||
| 1765 | View Code Duplication | public function getSubscriptionsJoinInstance(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 1772 | |||
| 1773 | |||
| 1774 | /** |
||
| 1775 | * If this collection has already been initialized with |
||
| 1776 | * an identical criteria, it returns the collection. |
||
| 1777 | * Otherwise if this User is new, it will return |
||
| 1778 | * an empty collection; or if this User has previously |
||
| 1779 | * been saved, it will retrieve related Subscriptions from storage. |
||
| 1780 | * |
||
| 1781 | * This method is protected by default in order to keep the public |
||
| 1782 | * api reasonable. You can provide public methods for those you |
||
| 1783 | * actually need in User. |
||
| 1784 | * |
||
| 1785 | * @param Criteria $criteria optional Criteria object to narrow the query |
||
| 1786 | * @param ConnectionInterface $con optional connection object |
||
| 1787 | * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
||
| 1788 | * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
||
| 1789 | */ |
||
| 1790 | View Code Duplication | public function getSubscriptionsJoinChannel(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 1797 | |||
| 1798 | /** |
||
| 1799 | * Clears the current object, sets all attributes to their default values and removes |
||
| 1800 | * outgoing references as well as back-references (from other objects to this one. Results probably in a database |
||
| 1801 | * change of those foreign objects when you call `save` there). |
||
| 1802 | */ |
||
| 1803 | View Code Duplication | public function clear() |
|
| 1817 | |||
| 1818 | /** |
||
| 1819 | * Resets all references and back-references to other model objects or collections of model objects. |
||
| 1820 | * |
||
| 1821 | * This method is used to reset all php object references (not the actual reference in the database). |
||
| 1822 | * Necessary for object serialisation. |
||
| 1823 | * |
||
| 1824 | * @param boolean $deep Whether to also clear the references on all referrer objects. |
||
| 1825 | */ |
||
| 1826 | public function clearAllReferences($deep = false) |
||
| 1845 | |||
| 1846 | /** |
||
| 1847 | * Return the string representation of this object |
||
| 1848 | * |
||
| 1849 | * @return string |
||
| 1850 | */ |
||
| 1851 | public function __toString() |
||
| 1855 | |||
| 1856 | /** |
||
| 1857 | * Code to be run before persisting the object |
||
| 1858 | * @param ConnectionInterface $con |
||
| 1859 | * @return boolean |
||
| 1860 | */ |
||
| 1861 | public function preSave(ConnectionInterface $con = null) |
||
| 1865 | |||
| 1866 | /** |
||
| 1867 | * Code to be run after persisting the object |
||
| 1868 | * @param ConnectionInterface $con |
||
| 1869 | */ |
||
| 1870 | public function postSave(ConnectionInterface $con = null) |
||
| 1874 | |||
| 1875 | /** |
||
| 1876 | * Code to be run before inserting to database |
||
| 1877 | * @param ConnectionInterface $con |
||
| 1878 | * @return boolean |
||
| 1879 | */ |
||
| 1880 | public function preInsert(ConnectionInterface $con = null) |
||
| 1884 | |||
| 1885 | /** |
||
| 1886 | * Code to be run after inserting to database |
||
| 1887 | * @param ConnectionInterface $con |
||
| 1888 | */ |
||
| 1889 | public function postInsert(ConnectionInterface $con = null) |
||
| 1893 | |||
| 1894 | /** |
||
| 1895 | * Code to be run before updating the object in database |
||
| 1896 | * @param ConnectionInterface $con |
||
| 1897 | * @return boolean |
||
| 1898 | */ |
||
| 1899 | public function preUpdate(ConnectionInterface $con = null) |
||
| 1903 | |||
| 1904 | /** |
||
| 1905 | * Code to be run after updating the object in database |
||
| 1906 | * @param ConnectionInterface $con |
||
| 1907 | */ |
||
| 1908 | public function postUpdate(ConnectionInterface $con = null) |
||
| 1912 | |||
| 1913 | /** |
||
| 1914 | * Code to be run before deleting the object in database |
||
| 1915 | * @param ConnectionInterface $con |
||
| 1916 | * @return boolean |
||
| 1917 | */ |
||
| 1918 | public function preDelete(ConnectionInterface $con = null) |
||
| 1922 | |||
| 1923 | /** |
||
| 1924 | * Code to be run after deleting the object in database |
||
| 1925 | * @param ConnectionInterface $con |
||
| 1926 | */ |
||
| 1927 | public function postDelete(ConnectionInterface $con = null) |
||
| 1931 | |||
| 1932 | |||
| 1933 | /** |
||
| 1934 | * Derived method to catches calls to undefined methods. |
||
| 1935 | * |
||
| 1936 | * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). |
||
| 1937 | * Allows to define default __call() behavior if you overwrite __call() |
||
| 1938 | * |
||
| 1939 | * @param string $name |
||
| 1940 | * @param mixed $params |
||
| 1941 | * |
||
| 1942 | * @return array|string |
||
| 1943 | */ |
||
| 1944 | View Code Duplication | public function __call($name, $params) |
|
| 1973 | |||
| 1974 | } |
||
| 1975 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.