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 Input 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 Input, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 37 | abstract class Input implements ActiveRecordInterface |
||
| 38 | { |
||
| 39 | /** |
||
| 40 | * TableMap class name |
||
| 41 | */ |
||
| 42 | const TABLE_MAP = '\\Jalle19\\StatusManager\\Database\\Map\\InputTableMap'; |
||
| 43 | |||
| 44 | |||
| 45 | /** |
||
| 46 | * attribute to determine if this object has previously been saved. |
||
| 47 | * @var boolean |
||
| 48 | */ |
||
| 49 | protected $new = true; |
||
| 50 | |||
| 51 | /** |
||
| 52 | * attribute to determine whether this object has been deleted. |
||
| 53 | * @var boolean |
||
| 54 | */ |
||
| 55 | protected $deleted = false; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * The columns that have been modified in current object. |
||
| 59 | * Tracking modified columns allows us to only update modified columns. |
||
| 60 | * @var array |
||
| 61 | */ |
||
| 62 | protected $modifiedColumns = array(); |
||
| 63 | |||
| 64 | /** |
||
| 65 | * The (virtual) columns that are added at runtime |
||
| 66 | * The formatters can add supplementary columns based on a resultset |
||
| 67 | * @var array |
||
| 68 | */ |
||
| 69 | protected $virtualColumns = array(); |
||
| 70 | |||
| 71 | /** |
||
| 72 | * The value for the uuid field. |
||
| 73 | * |
||
| 74 | * @var string |
||
| 75 | */ |
||
| 76 | protected $uuid; |
||
| 77 | |||
| 78 | /** |
||
| 79 | * The value for the instance_name field. |
||
| 80 | * |
||
| 81 | * @var string |
||
| 82 | */ |
||
| 83 | protected $instance_name; |
||
| 84 | |||
| 85 | /** |
||
| 86 | * The value for the started field. |
||
| 87 | * |
||
| 88 | * @var \DateTime |
||
| 89 | */ |
||
| 90 | protected $started; |
||
| 91 | |||
| 92 | /** |
||
| 93 | * The value for the input field. |
||
| 94 | * |
||
| 95 | * @var string |
||
| 96 | */ |
||
| 97 | protected $input; |
||
| 98 | |||
| 99 | /** |
||
| 100 | * The value for the network field. |
||
| 101 | * |
||
| 102 | * @var string |
||
| 103 | */ |
||
| 104 | protected $network; |
||
| 105 | |||
| 106 | /** |
||
| 107 | * The value for the mux field. |
||
| 108 | * |
||
| 109 | * @var string |
||
| 110 | */ |
||
| 111 | protected $mux; |
||
| 112 | |||
| 113 | /** |
||
| 114 | * The value for the weight field. |
||
| 115 | * |
||
| 116 | * @var int |
||
| 117 | */ |
||
| 118 | protected $weight; |
||
| 119 | |||
| 120 | /** |
||
| 121 | * @var ChildInstance |
||
| 122 | */ |
||
| 123 | protected $aInstance; |
||
| 124 | |||
| 125 | /** |
||
| 126 | * @var ObjectCollection|ChildSubscription[] Collection to store aggregation of ChildSubscription objects. |
||
| 127 | */ |
||
| 128 | protected $collSubscriptions; |
||
| 129 | protected $collSubscriptionsPartial; |
||
| 130 | |||
| 131 | /** |
||
| 132 | * Flag to prevent endless save loop, if this object is referenced |
||
| 133 | * by another object which falls in this transaction. |
||
| 134 | * |
||
| 135 | * @var boolean |
||
| 136 | */ |
||
| 137 | protected $alreadyInSave = false; |
||
| 138 | |||
| 139 | /** |
||
| 140 | * An array of objects scheduled for deletion. |
||
| 141 | * @var ObjectCollection|ChildSubscription[] |
||
| 142 | */ |
||
| 143 | protected $subscriptionsScheduledForDeletion = null; |
||
| 144 | |||
| 145 | /** |
||
| 146 | * Initializes internal state of Jalle19\StatusManager\Database\Base\Input object. |
||
| 147 | */ |
||
| 148 | public function __construct() |
||
| 151 | |||
| 152 | /** |
||
| 153 | * Returns whether the object has been modified. |
||
| 154 | * |
||
| 155 | * @return boolean True if the object has been modified. |
||
| 156 | */ |
||
| 157 | public function isModified() |
||
| 161 | |||
| 162 | /** |
||
| 163 | * Has specified column been modified? |
||
| 164 | * |
||
| 165 | * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID |
||
| 166 | * @return boolean True if $col has been modified. |
||
| 167 | */ |
||
| 168 | public function isColumnModified($col) |
||
| 172 | |||
| 173 | /** |
||
| 174 | * Get the columns that have been modified in this object. |
||
| 175 | * @return array A unique list of the modified column names for this object. |
||
| 176 | */ |
||
| 177 | public function getModifiedColumns() |
||
| 181 | |||
| 182 | /** |
||
| 183 | * Returns whether the object has ever been saved. This will |
||
| 184 | * be false, if the object was retrieved from storage or was created |
||
| 185 | * and then saved. |
||
| 186 | * |
||
| 187 | * @return boolean true, if the object has never been persisted. |
||
| 188 | */ |
||
| 189 | public function isNew() |
||
| 193 | |||
| 194 | /** |
||
| 195 | * Setter for the isNew attribute. This method will be called |
||
| 196 | * by Propel-generated children and objects. |
||
| 197 | * |
||
| 198 | * @param boolean $b the state of the object. |
||
| 199 | */ |
||
| 200 | public function setNew($b) |
||
| 204 | |||
| 205 | /** |
||
| 206 | * Whether this object has been deleted. |
||
| 207 | * @return boolean The deleted state of this object. |
||
| 208 | */ |
||
| 209 | public function isDeleted() |
||
| 213 | |||
| 214 | /** |
||
| 215 | * Specify whether this object has been deleted. |
||
| 216 | * @param boolean $b The deleted state of this object. |
||
| 217 | * @return void |
||
| 218 | */ |
||
| 219 | public function setDeleted($b) |
||
| 223 | |||
| 224 | /** |
||
| 225 | * Sets the modified state for the object to be false. |
||
| 226 | * @param string $col If supplied, only the specified column is reset. |
||
| 227 | * @return void |
||
| 228 | */ |
||
| 229 | View Code Duplication | public function resetModified($col = null) |
|
| 239 | |||
| 240 | /** |
||
| 241 | * Compares this with another <code>Input</code> instance. If |
||
| 242 | * <code>obj</code> is an instance of <code>Input</code>, delegates to |
||
| 243 | * <code>equals(Input)</code>. Otherwise, returns <code>false</code>. |
||
| 244 | * |
||
| 245 | * @param mixed $obj The object to compare to. |
||
| 246 | * @return boolean Whether equal to the object specified. |
||
| 247 | */ |
||
| 248 | public function equals($obj) |
||
| 264 | |||
| 265 | /** |
||
| 266 | * Get the associative array of the virtual columns in this object |
||
| 267 | * |
||
| 268 | * @return array |
||
| 269 | */ |
||
| 270 | public function getVirtualColumns() |
||
| 274 | |||
| 275 | /** |
||
| 276 | * Checks the existence of a virtual column in this object |
||
| 277 | * |
||
| 278 | * @param string $name The virtual column name |
||
| 279 | * @return boolean |
||
| 280 | */ |
||
| 281 | public function hasVirtualColumn($name) |
||
| 285 | |||
| 286 | /** |
||
| 287 | * Get the value of a virtual column in this object |
||
| 288 | * |
||
| 289 | * @param string $name The virtual column name |
||
| 290 | * @return mixed |
||
| 291 | * |
||
| 292 | * @throws PropelException |
||
| 293 | */ |
||
| 294 | public function getVirtualColumn($name) |
||
| 302 | |||
| 303 | /** |
||
| 304 | * Set the value of a virtual column in this object |
||
| 305 | * |
||
| 306 | * @param string $name The virtual column name |
||
| 307 | * @param mixed $value The value to give to the virtual column |
||
| 308 | * |
||
| 309 | * @return $this|Input The current object, for fluid interface |
||
| 310 | */ |
||
| 311 | public function setVirtualColumn($name, $value) |
||
| 317 | |||
| 318 | /** |
||
| 319 | * Logs a message using Propel::log(). |
||
| 320 | * |
||
| 321 | * @param string $msg |
||
| 322 | * @param int $priority One of the Propel::LOG_* logging levels |
||
| 323 | * @return boolean |
||
| 324 | */ |
||
| 325 | protected function log($msg, $priority = Propel::LOG_INFO) |
||
| 329 | |||
| 330 | /** |
||
| 331 | * Export the current object properties to a string, using a given parser format |
||
| 332 | * <code> |
||
| 333 | * $book = BookQuery::create()->findPk(9012); |
||
| 334 | * echo $book->exportTo('JSON'); |
||
| 335 | * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
||
| 336 | * </code> |
||
| 337 | * |
||
| 338 | * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') |
||
| 339 | * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. |
||
| 340 | * @return string The exported data |
||
| 341 | */ |
||
| 342 | View Code Duplication | public function exportTo($parser, $includeLazyLoadColumns = true) |
|
| 350 | |||
| 351 | /** |
||
| 352 | * Clean up internal collections prior to serializing |
||
| 353 | * Avoids recursive loops that turn into segmentation faults when serializing |
||
| 354 | */ |
||
| 355 | View Code Duplication | public function __sleep() |
|
| 369 | |||
| 370 | /** |
||
| 371 | * Get the [uuid] column value. |
||
| 372 | * |
||
| 373 | * @return string |
||
| 374 | */ |
||
| 375 | public function getUuid() |
||
| 379 | |||
| 380 | /** |
||
| 381 | * Get the [instance_name] column value. |
||
| 382 | * |
||
| 383 | * @return string |
||
| 384 | */ |
||
| 385 | public function getInstanceName() |
||
| 389 | |||
| 390 | /** |
||
| 391 | * Get the [optionally formatted] temporal [started] column value. |
||
| 392 | * |
||
| 393 | * |
||
| 394 | * @param string $format The date/time format string (either date()-style or strftime()-style). |
||
| 395 | * If format is NULL, then the raw DateTime object will be returned. |
||
| 396 | * |
||
| 397 | * @return string|DateTime Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL |
||
| 398 | * |
||
| 399 | * @throws PropelException - if unable to parse/validate the date/time value. |
||
| 400 | */ |
||
| 401 | View Code Duplication | public function getStarted($format = NULL) |
|
| 409 | |||
| 410 | /** |
||
| 411 | * Get the [input] column value. |
||
| 412 | * |
||
| 413 | * @return string |
||
| 414 | */ |
||
| 415 | public function getInput() |
||
| 419 | |||
| 420 | /** |
||
| 421 | * Get the [network] column value. |
||
| 422 | * |
||
| 423 | * @return string |
||
| 424 | */ |
||
| 425 | public function getNetwork() |
||
| 429 | |||
| 430 | /** |
||
| 431 | * Get the [mux] column value. |
||
| 432 | * |
||
| 433 | * @return string |
||
| 434 | */ |
||
| 435 | public function getMux() |
||
| 439 | |||
| 440 | /** |
||
| 441 | * Get the [weight] column value. |
||
| 442 | * |
||
| 443 | * @return int |
||
| 444 | */ |
||
| 445 | public function getWeight() |
||
| 449 | |||
| 450 | /** |
||
| 451 | * Set the value of [uuid] column. |
||
| 452 | * |
||
| 453 | * @param string $v new value |
||
| 454 | * @return $this|\Jalle19\StatusManager\Database\Input The current object (for fluent API support) |
||
| 455 | */ |
||
| 456 | View Code Duplication | public function setUuid($v) |
|
| 469 | |||
| 470 | /** |
||
| 471 | * Set the value of [instance_name] column. |
||
| 472 | * |
||
| 473 | * @param string $v new value |
||
| 474 | * @return $this|\Jalle19\StatusManager\Database\Input The current object (for fluent API support) |
||
| 475 | */ |
||
| 476 | View Code Duplication | public function setInstanceName($v) |
|
| 493 | |||
| 494 | /** |
||
| 495 | * Sets the value of [started] column to a normalized version of the date/time value specified. |
||
| 496 | * |
||
| 497 | * @param mixed $v string, integer (timestamp), or \DateTime value. |
||
| 498 | * Empty strings are treated as NULL. |
||
| 499 | * @return $this|\Jalle19\StatusManager\Database\Input The current object (for fluent API support) |
||
| 500 | */ |
||
| 501 | View Code Duplication | public function setStarted($v) |
|
| 513 | |||
| 514 | /** |
||
| 515 | * Set the value of [input] column. |
||
| 516 | * |
||
| 517 | * @param string $v new value |
||
| 518 | * @return $this|\Jalle19\StatusManager\Database\Input The current object (for fluent API support) |
||
| 519 | */ |
||
| 520 | public function setInput($v) |
||
| 533 | |||
| 534 | /** |
||
| 535 | * Set the value of [network] column. |
||
| 536 | * |
||
| 537 | * @param string $v new value |
||
| 538 | * @return $this|\Jalle19\StatusManager\Database\Input The current object (for fluent API support) |
||
| 539 | */ |
||
| 540 | public function setNetwork($v) |
||
| 553 | |||
| 554 | /** |
||
| 555 | * Set the value of [mux] column. |
||
| 556 | * |
||
| 557 | * @param string $v new value |
||
| 558 | * @return $this|\Jalle19\StatusManager\Database\Input The current object (for fluent API support) |
||
| 559 | */ |
||
| 560 | public function setMux($v) |
||
| 573 | |||
| 574 | /** |
||
| 575 | * Set the value of [weight] column. |
||
| 576 | * |
||
| 577 | * @param int $v new value |
||
| 578 | * @return $this|\Jalle19\StatusManager\Database\Input The current object (for fluent API support) |
||
| 579 | */ |
||
| 580 | public function setWeight($v) |
||
| 593 | |||
| 594 | /** |
||
| 595 | * Indicates whether the columns in this object are only set to default values. |
||
| 596 | * |
||
| 597 | * This method can be used in conjunction with isModified() to indicate whether an object is both |
||
| 598 | * modified _and_ has some values set which are non-default. |
||
| 599 | * |
||
| 600 | * @return boolean Whether the columns in this object are only been set with default values. |
||
| 601 | */ |
||
| 602 | public function hasOnlyDefaultValues() |
||
| 607 | |||
| 608 | /** |
||
| 609 | * Hydrates (populates) the object variables with values from the database resultset. |
||
| 610 | * |
||
| 611 | * An offset (0-based "start column") is specified so that objects can be hydrated |
||
| 612 | * with a subset of the columns in the resultset rows. This is needed, for example, |
||
| 613 | * for results of JOIN queries where the resultset row includes columns from two or |
||
| 614 | * more tables. |
||
| 615 | * |
||
| 616 | * @param array $row The row returned by DataFetcher->fetch(). |
||
| 617 | * @param int $startcol 0-based offset column which indicates which restultset column to start with. |
||
| 618 | * @param boolean $rehydrate Whether this object is being re-hydrated from the database. |
||
| 619 | * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
||
| 620 | One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
| 621 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 622 | * |
||
| 623 | * @return int next starting column |
||
| 624 | * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. |
||
| 625 | */ |
||
| 626 | public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) |
||
| 664 | |||
| 665 | /** |
||
| 666 | * Checks and repairs the internal consistency of the object. |
||
| 667 | * |
||
| 668 | * This method is executed after an already-instantiated object is re-hydrated |
||
| 669 | * from the database. It exists to check any foreign keys to make sure that |
||
| 670 | * the objects related to the current object are correct based on foreign key. |
||
| 671 | * |
||
| 672 | * You can override this method in the stub class, but you should always invoke |
||
| 673 | * the base method from the overridden method (i.e. parent::ensureConsistency()), |
||
| 674 | * in case your model changes. |
||
| 675 | * |
||
| 676 | * @throws PropelException |
||
| 677 | */ |
||
| 678 | public function ensureConsistency() |
||
| 684 | |||
| 685 | /** |
||
| 686 | * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. |
||
| 687 | * |
||
| 688 | * This will only work if the object has been saved and has a valid primary key set. |
||
| 689 | * |
||
| 690 | * @param boolean $deep (optional) Whether to also de-associated any related objects. |
||
| 691 | * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. |
||
| 692 | * @return void |
||
| 693 | * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db |
||
| 694 | */ |
||
| 695 | View Code Duplication | public function reload($deep = false, ConnectionInterface $con = null) |
|
| 727 | |||
| 728 | /** |
||
| 729 | * Removes this object from datastore and sets delete attribute. |
||
| 730 | * |
||
| 731 | * @param ConnectionInterface $con |
||
| 732 | * @return void |
||
| 733 | * @throws PropelException |
||
| 734 | * @see Input::setDeleted() |
||
| 735 | * @see Input::isDeleted() |
||
| 736 | */ |
||
| 737 | View Code Duplication | public function delete(ConnectionInterface $con = null) |
|
| 758 | |||
| 759 | /** |
||
| 760 | * Persists this object to the database. |
||
| 761 | * |
||
| 762 | * If the object is new, it inserts it; otherwise an update is performed. |
||
| 763 | * All modified related objects will also be persisted in the doSave() |
||
| 764 | * method. This method wraps all precipitate database operations in a |
||
| 765 | * single transaction. |
||
| 766 | * |
||
| 767 | * @param ConnectionInterface $con |
||
| 768 | * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
||
| 769 | * @throws PropelException |
||
| 770 | * @see doSave() |
||
| 771 | */ |
||
| 772 | View Code Duplication | public function save(ConnectionInterface $con = null) |
|
| 806 | |||
| 807 | /** |
||
| 808 | * Performs the work of inserting or updating the row in the database. |
||
| 809 | * |
||
| 810 | * If the object is new, it inserts it; otherwise an update is performed. |
||
| 811 | * All related objects are also updated in this method. |
||
| 812 | * |
||
| 813 | * @param ConnectionInterface $con |
||
| 814 | * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
||
| 815 | * @throws PropelException |
||
| 816 | * @see save() |
||
| 817 | */ |
||
| 818 | protected function doSave(ConnectionInterface $con) |
||
| 871 | |||
| 872 | /** |
||
| 873 | * Insert the row in the database. |
||
| 874 | * |
||
| 875 | * @param ConnectionInterface $con |
||
| 876 | * |
||
| 877 | * @throws PropelException |
||
| 878 | * @see doSave() |
||
| 879 | */ |
||
| 880 | protected function doInsert(ConnectionInterface $con) |
||
| 950 | |||
| 951 | /** |
||
| 952 | * Update the row in the database. |
||
| 953 | * |
||
| 954 | * @param ConnectionInterface $con |
||
| 955 | * |
||
| 956 | * @return Integer Number of updated rows |
||
| 957 | * @see doSave() |
||
| 958 | */ |
||
| 959 | protected function doUpdate(ConnectionInterface $con) |
||
| 966 | |||
| 967 | /** |
||
| 968 | * Retrieves a field from the object by name passed in as a string. |
||
| 969 | * |
||
| 970 | * @param string $name name |
||
| 971 | * @param string $type The type of fieldname the $name is of: |
||
| 972 | * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
| 973 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 974 | * Defaults to TableMap::TYPE_PHPNAME. |
||
| 975 | * @return mixed Value of field. |
||
| 976 | */ |
||
| 977 | public function getByName($name, $type = TableMap::TYPE_PHPNAME) |
||
| 984 | |||
| 985 | /** |
||
| 986 | * Retrieves a field from the object by Position as specified in the xml schema. |
||
| 987 | * Zero-based. |
||
| 988 | * |
||
| 989 | * @param int $pos position in xml schema |
||
| 990 | * @return mixed Value of field at $pos |
||
| 991 | */ |
||
| 992 | public function getByPosition($pos) |
||
| 1021 | |||
| 1022 | /** |
||
| 1023 | * Exports the object as an array. |
||
| 1024 | * |
||
| 1025 | * You can specify the key type of the array by passing one of the class |
||
| 1026 | * type constants. |
||
| 1027 | * |
||
| 1028 | * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
| 1029 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1030 | * Defaults to TableMap::TYPE_PHPNAME. |
||
| 1031 | * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. |
||
| 1032 | * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion |
||
| 1033 | * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. |
||
| 1034 | * |
||
| 1035 | * @return array an associative array containing the field names (as keys) and field values |
||
| 1036 | */ |
||
| 1037 | View Code Duplication | public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) |
|
| 1098 | |||
| 1099 | /** |
||
| 1100 | * Sets a field from the object by name passed in as a string. |
||
| 1101 | * |
||
| 1102 | * @param string $name |
||
| 1103 | * @param mixed $value field value |
||
| 1104 | * @param string $type The type of fieldname the $name is of: |
||
| 1105 | * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
| 1106 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1107 | * Defaults to TableMap::TYPE_PHPNAME. |
||
| 1108 | * @return $this|\Jalle19\StatusManager\Database\Input |
||
| 1109 | */ |
||
| 1110 | public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) |
||
| 1116 | |||
| 1117 | /** |
||
| 1118 | * Sets a field from the object by Position as specified in the xml schema. |
||
| 1119 | * Zero-based. |
||
| 1120 | * |
||
| 1121 | * @param int $pos position in xml schema |
||
| 1122 | * @param mixed $value field value |
||
| 1123 | * @return $this|\Jalle19\StatusManager\Database\Input |
||
| 1124 | */ |
||
| 1125 | public function setByPosition($pos, $value) |
||
| 1153 | |||
| 1154 | /** |
||
| 1155 | * Populates the object using an array. |
||
| 1156 | * |
||
| 1157 | * This is particularly useful when populating an object from one of the |
||
| 1158 | * request arrays (e.g. $_POST). This method goes through the column |
||
| 1159 | * names, checking to see whether a matching key exists in populated |
||
| 1160 | * array. If so the setByName() method is called for that column. |
||
| 1161 | * |
||
| 1162 | * You can specify the key type of the array by additionally passing one |
||
| 1163 | * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
| 1164 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1165 | * The default key type is the column's TableMap::TYPE_PHPNAME. |
||
| 1166 | * |
||
| 1167 | * @param array $arr An array to populate the object from. |
||
| 1168 | * @param string $keyType The type of keys the array uses. |
||
| 1169 | * @return void |
||
| 1170 | */ |
||
| 1171 | public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) |
||
| 1197 | |||
| 1198 | /** |
||
| 1199 | * Populate the current object from a string, using a given parser format |
||
| 1200 | * <code> |
||
| 1201 | * $book = new Book(); |
||
| 1202 | * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
||
| 1203 | * </code> |
||
| 1204 | * |
||
| 1205 | * You can specify the key type of the array by additionally passing one |
||
| 1206 | * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
| 1207 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1208 | * The default key type is the column's TableMap::TYPE_PHPNAME. |
||
| 1209 | * |
||
| 1210 | * @param mixed $parser A AbstractParser instance, |
||
| 1211 | * or a format name ('XML', 'YAML', 'JSON', 'CSV') |
||
| 1212 | * @param string $data The source data to import from |
||
| 1213 | * @param string $keyType The type of keys the array uses. |
||
| 1214 | * |
||
| 1215 | * @return $this|\Jalle19\StatusManager\Database\Input The current object, for fluid interface |
||
| 1216 | */ |
||
| 1217 | View Code Duplication | public function importFrom($parser, $data, $keyType = TableMap::TYPE_PHPNAME) |
|
| 1227 | |||
| 1228 | /** |
||
| 1229 | * Build a Criteria object containing the values of all modified columns in this object. |
||
| 1230 | * |
||
| 1231 | * @return Criteria The Criteria object containing all modified values. |
||
| 1232 | */ |
||
| 1233 | public function buildCriteria() |
||
| 1261 | |||
| 1262 | /** |
||
| 1263 | * Builds a Criteria object containing the primary key for this object. |
||
| 1264 | * |
||
| 1265 | * Unlike buildCriteria() this method includes the primary key values regardless |
||
| 1266 | * of whether or not they have been modified. |
||
| 1267 | * |
||
| 1268 | * @throws LogicException if no primary key is defined |
||
| 1269 | * |
||
| 1270 | * @return Criteria The Criteria object containing value(s) for primary key(s). |
||
| 1271 | */ |
||
| 1272 | public function buildPkeyCriteria() |
||
| 1279 | |||
| 1280 | /** |
||
| 1281 | * If the primary key is not null, return the hashcode of the |
||
| 1282 | * primary key. Otherwise, return the hash code of the object. |
||
| 1283 | * |
||
| 1284 | * @return int Hashcode |
||
| 1285 | */ |
||
| 1286 | View Code Duplication | public function hashCode() |
|
| 1301 | |||
| 1302 | /** |
||
| 1303 | * Returns the primary key for this object (row). |
||
| 1304 | * @return string |
||
| 1305 | */ |
||
| 1306 | public function getPrimaryKey() |
||
| 1310 | |||
| 1311 | /** |
||
| 1312 | * Generic method to set the primary key (uuid column). |
||
| 1313 | * |
||
| 1314 | * @param string $key Primary key. |
||
| 1315 | * @return void |
||
| 1316 | */ |
||
| 1317 | public function setPrimaryKey($key) |
||
| 1321 | |||
| 1322 | /** |
||
| 1323 | * Returns true if the primary key for this object is null. |
||
| 1324 | * @return boolean |
||
| 1325 | */ |
||
| 1326 | public function isPrimaryKeyNull() |
||
| 1330 | |||
| 1331 | /** |
||
| 1332 | * Sets contents of passed object to values from current object. |
||
| 1333 | * |
||
| 1334 | * If desired, this method can also make copies of all associated (fkey referrers) |
||
| 1335 | * objects. |
||
| 1336 | * |
||
| 1337 | * @param object $copyObj An object of \Jalle19\StatusManager\Database\Input (or compatible) type. |
||
| 1338 | * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
||
| 1339 | * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. |
||
| 1340 | * @throws PropelException |
||
| 1341 | */ |
||
| 1342 | public function copyInto($copyObj, $deepCopy = false, $makeNew = true) |
||
| 1369 | |||
| 1370 | /** |
||
| 1371 | * Makes a copy of this object that will be inserted as a new row in table when saved. |
||
| 1372 | * It creates a new object filling in the simple attributes, but skipping any primary |
||
| 1373 | * keys that are defined for the table. |
||
| 1374 | * |
||
| 1375 | * If desired, this method can also make copies of all associated (fkey referrers) |
||
| 1376 | * objects. |
||
| 1377 | * |
||
| 1378 | * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
||
| 1379 | * @return \Jalle19\StatusManager\Database\Input Clone of current object. |
||
| 1380 | * @throws PropelException |
||
| 1381 | */ |
||
| 1382 | public function copy($deepCopy = false) |
||
| 1391 | |||
| 1392 | /** |
||
| 1393 | * Declares an association between this object and a ChildInstance object. |
||
| 1394 | * |
||
| 1395 | * @param ChildInstance $v |
||
| 1396 | * @return $this|\Jalle19\StatusManager\Database\Input The current object (for fluent API support) |
||
| 1397 | * @throws PropelException |
||
| 1398 | */ |
||
| 1399 | public function setInstance(ChildInstance $v = null) |
||
| 1418 | |||
| 1419 | |||
| 1420 | /** |
||
| 1421 | * Get the associated ChildInstance object |
||
| 1422 | * |
||
| 1423 | * @param ConnectionInterface $con Optional Connection object. |
||
| 1424 | * @return ChildInstance The associated ChildInstance object. |
||
| 1425 | * @throws PropelException |
||
| 1426 | */ |
||
| 1427 | public function getInstance(ConnectionInterface $con = null) |
||
| 1442 | |||
| 1443 | |||
| 1444 | /** |
||
| 1445 | * Initializes a collection based on the name of a relation. |
||
| 1446 | * Avoids crafting an 'init[$relationName]s' method name |
||
| 1447 | * that wouldn't work when StandardEnglishPluralizer is used. |
||
| 1448 | * |
||
| 1449 | * @param string $relationName The name of the relation to initialize |
||
| 1450 | * @return void |
||
| 1451 | */ |
||
| 1452 | public function initRelation($relationName) |
||
| 1458 | |||
| 1459 | /** |
||
| 1460 | * Clears out the collSubscriptions collection |
||
| 1461 | * |
||
| 1462 | * This does not modify the database; however, it will remove any associated objects, causing |
||
| 1463 | * them to be refetched by subsequent calls to accessor method. |
||
| 1464 | * |
||
| 1465 | * @return void |
||
| 1466 | * @see addSubscriptions() |
||
| 1467 | */ |
||
| 1468 | public function clearSubscriptions() |
||
| 1472 | |||
| 1473 | /** |
||
| 1474 | * Reset is the collSubscriptions collection loaded partially. |
||
| 1475 | */ |
||
| 1476 | public function resetPartialSubscriptions($v = true) |
||
| 1480 | |||
| 1481 | /** |
||
| 1482 | * Initializes the collSubscriptions collection. |
||
| 1483 | * |
||
| 1484 | * By default this just sets the collSubscriptions collection to an empty array (like clearcollSubscriptions()); |
||
| 1485 | * however, you may wish to override this method in your stub class to provide setting appropriate |
||
| 1486 | * to your application -- for example, setting the initial array to the values stored in database. |
||
| 1487 | * |
||
| 1488 | * @param boolean $overrideExisting If set to true, the method call initializes |
||
| 1489 | * the collection even if it is not empty |
||
| 1490 | * |
||
| 1491 | * @return void |
||
| 1492 | */ |
||
| 1493 | View Code Duplication | public function initSubscriptions($overrideExisting = true) |
|
| 1504 | |||
| 1505 | /** |
||
| 1506 | * Gets an array of ChildSubscription objects which contain a foreign key that references this object. |
||
| 1507 | * |
||
| 1508 | * If the $criteria is not null, it is used to always fetch the results from the database. |
||
| 1509 | * Otherwise the results are fetched from the database the first time, then cached. |
||
| 1510 | * Next time the same method is called without $criteria, the cached collection is returned. |
||
| 1511 | * If this ChildInput is new, it will return |
||
| 1512 | * an empty collection or the current collection; the criteria is ignored on a new object. |
||
| 1513 | * |
||
| 1514 | * @param Criteria $criteria optional Criteria object to narrow the query |
||
| 1515 | * @param ConnectionInterface $con optional connection object |
||
| 1516 | * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
||
| 1517 | * @throws PropelException |
||
| 1518 | */ |
||
| 1519 | View Code Duplication | public function getSubscriptions(Criteria $criteria = null, ConnectionInterface $con = null) |
|
| 1562 | |||
| 1563 | /** |
||
| 1564 | * Sets a collection of ChildSubscription objects related by a one-to-many relationship |
||
| 1565 | * to the current object. |
||
| 1566 | * It will also schedule objects for deletion based on a diff between old objects (aka persisted) |
||
| 1567 | * and new objects from the given Propel collection. |
||
| 1568 | * |
||
| 1569 | * @param Collection $subscriptions A Propel collection. |
||
| 1570 | * @param ConnectionInterface $con Optional connection object |
||
| 1571 | * @return $this|ChildInput The current object (for fluent API support) |
||
| 1572 | */ |
||
| 1573 | View Code Duplication | public function setSubscriptions(Collection $subscriptions, ConnectionInterface $con = null) |
|
| 1595 | |||
| 1596 | /** |
||
| 1597 | * Returns the number of related Subscription objects. |
||
| 1598 | * |
||
| 1599 | * @param Criteria $criteria |
||
| 1600 | * @param boolean $distinct |
||
| 1601 | * @param ConnectionInterface $con |
||
| 1602 | * @return int Count of related Subscription objects. |
||
| 1603 | * @throws PropelException |
||
| 1604 | */ |
||
| 1605 | public function countSubscriptions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) |
||
| 1629 | |||
| 1630 | /** |
||
| 1631 | * Method called to associate a ChildSubscription object to this object |
||
| 1632 | * through the ChildSubscription foreign key attribute. |
||
| 1633 | * |
||
| 1634 | * @param ChildSubscription $l ChildSubscription |
||
| 1635 | * @return $this|\Jalle19\StatusManager\Database\Input The current object (for fluent API support) |
||
| 1636 | */ |
||
| 1637 | View Code Duplication | public function addSubscription(ChildSubscription $l) |
|
| 1654 | |||
| 1655 | /** |
||
| 1656 | * @param ChildSubscription $subscription The ChildSubscription object to add. |
||
| 1657 | */ |
||
| 1658 | protected function doAddSubscription(ChildSubscription $subscription) |
||
| 1663 | |||
| 1664 | /** |
||
| 1665 | * @param ChildSubscription $subscription The ChildSubscription object to remove. |
||
| 1666 | * @return $this|ChildInput The current object (for fluent API support) |
||
| 1667 | */ |
||
| 1668 | View Code Duplication | public function removeSubscription(ChildSubscription $subscription) |
|
| 1683 | |||
| 1684 | |||
| 1685 | /** |
||
| 1686 | * If this collection has already been initialized with |
||
| 1687 | * an identical criteria, it returns the collection. |
||
| 1688 | * Otherwise if this Input is new, it will return |
||
| 1689 | * an empty collection; or if this Input has previously |
||
| 1690 | * been saved, it will retrieve related Subscriptions from storage. |
||
| 1691 | * |
||
| 1692 | * This method is protected by default in order to keep the public |
||
| 1693 | * api reasonable. You can provide public methods for those you |
||
| 1694 | * actually need in Input. |
||
| 1695 | * |
||
| 1696 | * @param Criteria $criteria optional Criteria object to narrow the query |
||
| 1697 | * @param ConnectionInterface $con optional connection object |
||
| 1698 | * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
||
| 1699 | * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
||
| 1700 | */ |
||
| 1701 | View Code Duplication | public function getSubscriptionsJoinInstance(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 1708 | |||
| 1709 | |||
| 1710 | /** |
||
| 1711 | * If this collection has already been initialized with |
||
| 1712 | * an identical criteria, it returns the collection. |
||
| 1713 | * Otherwise if this Input is new, it will return |
||
| 1714 | * an empty collection; or if this Input has previously |
||
| 1715 | * been saved, it will retrieve related Subscriptions from storage. |
||
| 1716 | * |
||
| 1717 | * This method is protected by default in order to keep the public |
||
| 1718 | * api reasonable. You can provide public methods for those you |
||
| 1719 | * actually need in Input. |
||
| 1720 | * |
||
| 1721 | * @param Criteria $criteria optional Criteria object to narrow the query |
||
| 1722 | * @param ConnectionInterface $con optional connection object |
||
| 1723 | * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
||
| 1724 | * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
||
| 1725 | */ |
||
| 1726 | View Code Duplication | public function getSubscriptionsJoinUser(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 1733 | |||
| 1734 | |||
| 1735 | /** |
||
| 1736 | * If this collection has already been initialized with |
||
| 1737 | * an identical criteria, it returns the collection. |
||
| 1738 | * Otherwise if this Input is new, it will return |
||
| 1739 | * an empty collection; or if this Input has previously |
||
| 1740 | * been saved, it will retrieve related Subscriptions from storage. |
||
| 1741 | * |
||
| 1742 | * This method is protected by default in order to keep the public |
||
| 1743 | * api reasonable. You can provide public methods for those you |
||
| 1744 | * actually need in Input. |
||
| 1745 | * |
||
| 1746 | * @param Criteria $criteria optional Criteria object to narrow the query |
||
| 1747 | * @param ConnectionInterface $con optional connection object |
||
| 1748 | * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
||
| 1749 | * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
||
| 1750 | */ |
||
| 1751 | View Code Duplication | public function getSubscriptionsJoinChannel(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 1758 | |||
| 1759 | /** |
||
| 1760 | * Clears the current object, sets all attributes to their default values and removes |
||
| 1761 | * outgoing references as well as back-references (from other objects to this one. Results probably in a database |
||
| 1762 | * change of those foreign objects when you call `save` there). |
||
| 1763 | */ |
||
| 1764 | View Code Duplication | public function clear() |
|
| 1782 | |||
| 1783 | /** |
||
| 1784 | * Resets all references and back-references to other model objects or collections of model objects. |
||
| 1785 | * |
||
| 1786 | * This method is used to reset all php object references (not the actual reference in the database). |
||
| 1787 | * Necessary for object serialisation. |
||
| 1788 | * |
||
| 1789 | * @param boolean $deep Whether to also clear the references on all referrer objects. |
||
| 1790 | */ |
||
| 1791 | View Code Duplication | public function clearAllReferences($deep = false) |
|
| 1804 | |||
| 1805 | /** |
||
| 1806 | * Return the string representation of this object |
||
| 1807 | * |
||
| 1808 | * @return string |
||
| 1809 | */ |
||
| 1810 | public function __toString() |
||
| 1814 | |||
| 1815 | /** |
||
| 1816 | * Code to be run before persisting the object |
||
| 1817 | * @param ConnectionInterface $con |
||
| 1818 | * @return boolean |
||
| 1819 | */ |
||
| 1820 | public function preSave(ConnectionInterface $con = null) |
||
| 1824 | |||
| 1825 | /** |
||
| 1826 | * Code to be run after persisting the object |
||
| 1827 | * @param ConnectionInterface $con |
||
| 1828 | */ |
||
| 1829 | public function postSave(ConnectionInterface $con = null) |
||
| 1833 | |||
| 1834 | /** |
||
| 1835 | * Code to be run before inserting to database |
||
| 1836 | * @param ConnectionInterface $con |
||
| 1837 | * @return boolean |
||
| 1838 | */ |
||
| 1839 | public function preInsert(ConnectionInterface $con = null) |
||
| 1843 | |||
| 1844 | /** |
||
| 1845 | * Code to be run after inserting to database |
||
| 1846 | * @param ConnectionInterface $con |
||
| 1847 | */ |
||
| 1848 | public function postInsert(ConnectionInterface $con = null) |
||
| 1852 | |||
| 1853 | /** |
||
| 1854 | * Code to be run before updating the object in database |
||
| 1855 | * @param ConnectionInterface $con |
||
| 1856 | * @return boolean |
||
| 1857 | */ |
||
| 1858 | public function preUpdate(ConnectionInterface $con = null) |
||
| 1862 | |||
| 1863 | /** |
||
| 1864 | * Code to be run after updating the object in database |
||
| 1865 | * @param ConnectionInterface $con |
||
| 1866 | */ |
||
| 1867 | public function postUpdate(ConnectionInterface $con = null) |
||
| 1871 | |||
| 1872 | /** |
||
| 1873 | * Code to be run before deleting the object in database |
||
| 1874 | * @param ConnectionInterface $con |
||
| 1875 | * @return boolean |
||
| 1876 | */ |
||
| 1877 | public function preDelete(ConnectionInterface $con = null) |
||
| 1881 | |||
| 1882 | /** |
||
| 1883 | * Code to be run after deleting the object in database |
||
| 1884 | * @param ConnectionInterface $con |
||
| 1885 | */ |
||
| 1886 | public function postDelete(ConnectionInterface $con = null) |
||
| 1890 | |||
| 1891 | |||
| 1892 | /** |
||
| 1893 | * Derived method to catches calls to undefined methods. |
||
| 1894 | * |
||
| 1895 | * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). |
||
| 1896 | * Allows to define default __call() behavior if you overwrite __call() |
||
| 1897 | * |
||
| 1898 | * @param string $name |
||
| 1899 | * @param mixed $params |
||
| 1900 | * |
||
| 1901 | * @return array|string |
||
| 1902 | */ |
||
| 1903 | View Code Duplication | public function __call($name, $params) |
|
| 1932 | |||
| 1933 | } |
||
| 1934 |
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.