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 Channel 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 Channel, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 35 | abstract class Channel implements ActiveRecordInterface |
||
| 36 | { |
||
| 37 | /** |
||
| 38 | * TableMap class name |
||
| 39 | */ |
||
| 40 | const TABLE_MAP = '\\Jalle19\\StatusManager\\Database\\Map\\ChannelTableMap'; |
||
| 41 | |||
| 42 | |||
| 43 | /** |
||
| 44 | * attribute to determine if this object has previously been saved. |
||
| 45 | * @var boolean |
||
| 46 | */ |
||
| 47 | protected $new = true; |
||
| 48 | |||
| 49 | /** |
||
| 50 | * attribute to determine whether this object has been deleted. |
||
| 51 | * @var boolean |
||
| 52 | */ |
||
| 53 | protected $deleted = false; |
||
| 54 | |||
| 55 | /** |
||
| 56 | * The columns that have been modified in current object. |
||
| 57 | * Tracking modified columns allows us to only update modified columns. |
||
| 58 | * @var array |
||
| 59 | */ |
||
| 60 | protected $modifiedColumns = array(); |
||
| 61 | |||
| 62 | /** |
||
| 63 | * The (virtual) columns that are added at runtime |
||
| 64 | * The formatters can add supplementary columns based on a resultset |
||
| 65 | * @var array |
||
| 66 | */ |
||
| 67 | protected $virtualColumns = array(); |
||
| 68 | |||
| 69 | /** |
||
| 70 | * The value for the id field. |
||
| 71 | * |
||
| 72 | * @var int |
||
| 73 | */ |
||
| 74 | protected $id; |
||
| 75 | |||
| 76 | /** |
||
| 77 | * The value for the instance_name field. |
||
| 78 | * |
||
| 79 | * @var string |
||
| 80 | */ |
||
| 81 | protected $instance_name; |
||
| 82 | |||
| 83 | /** |
||
| 84 | * The value for the name field. |
||
| 85 | * |
||
| 86 | * @var string |
||
| 87 | */ |
||
| 88 | protected $name; |
||
| 89 | |||
| 90 | /** |
||
| 91 | * @var ChildInstance |
||
| 92 | */ |
||
| 93 | protected $aInstance; |
||
| 94 | |||
| 95 | /** |
||
| 96 | * @var ObjectCollection|ChildSubscription[] Collection to store aggregation of ChildSubscription objects. |
||
| 97 | */ |
||
| 98 | protected $collSubscriptions; |
||
| 99 | protected $collSubscriptionsPartial; |
||
| 100 | |||
| 101 | /** |
||
| 102 | * Flag to prevent endless save loop, if this object is referenced |
||
| 103 | * by another object which falls in this transaction. |
||
| 104 | * |
||
| 105 | * @var boolean |
||
| 106 | */ |
||
| 107 | protected $alreadyInSave = false; |
||
| 108 | |||
| 109 | /** |
||
| 110 | * An array of objects scheduled for deletion. |
||
| 111 | * @var ObjectCollection|ChildSubscription[] |
||
| 112 | */ |
||
| 113 | protected $subscriptionsScheduledForDeletion = null; |
||
| 114 | |||
| 115 | /** |
||
| 116 | * Initializes internal state of Jalle19\StatusManager\Database\Base\Channel object. |
||
| 117 | */ |
||
| 118 | public function __construct() |
||
| 121 | |||
| 122 | /** |
||
| 123 | * Returns whether the object has been modified. |
||
| 124 | * |
||
| 125 | * @return boolean True if the object has been modified. |
||
| 126 | */ |
||
| 127 | public function isModified() |
||
| 131 | |||
| 132 | /** |
||
| 133 | * Has specified column been modified? |
||
| 134 | * |
||
| 135 | * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID |
||
| 136 | * @return boolean True if $col has been modified. |
||
| 137 | */ |
||
| 138 | public function isColumnModified($col) |
||
| 142 | |||
| 143 | /** |
||
| 144 | * Get the columns that have been modified in this object. |
||
| 145 | * @return array A unique list of the modified column names for this object. |
||
| 146 | */ |
||
| 147 | public function getModifiedColumns() |
||
| 151 | |||
| 152 | /** |
||
| 153 | * Returns whether the object has ever been saved. This will |
||
| 154 | * be false, if the object was retrieved from storage or was created |
||
| 155 | * and then saved. |
||
| 156 | * |
||
| 157 | * @return boolean true, if the object has never been persisted. |
||
| 158 | */ |
||
| 159 | public function isNew() |
||
| 163 | |||
| 164 | /** |
||
| 165 | * Setter for the isNew attribute. This method will be called |
||
| 166 | * by Propel-generated children and objects. |
||
| 167 | * |
||
| 168 | * @param boolean $b the state of the object. |
||
| 169 | */ |
||
| 170 | public function setNew($b) |
||
| 174 | |||
| 175 | /** |
||
| 176 | * Whether this object has been deleted. |
||
| 177 | * @return boolean The deleted state of this object. |
||
| 178 | */ |
||
| 179 | public function isDeleted() |
||
| 183 | |||
| 184 | /** |
||
| 185 | * Specify whether this object has been deleted. |
||
| 186 | * @param boolean $b The deleted state of this object. |
||
| 187 | * @return void |
||
| 188 | */ |
||
| 189 | public function setDeleted($b) |
||
| 193 | |||
| 194 | /** |
||
| 195 | * Sets the modified state for the object to be false. |
||
| 196 | * @param string $col If supplied, only the specified column is reset. |
||
| 197 | * @return void |
||
| 198 | */ |
||
| 199 | View Code Duplication | public function resetModified($col = null) |
|
| 209 | |||
| 210 | /** |
||
| 211 | * Compares this with another <code>Channel</code> instance. If |
||
| 212 | * <code>obj</code> is an instance of <code>Channel</code>, delegates to |
||
| 213 | * <code>equals(Channel)</code>. Otherwise, returns <code>false</code>. |
||
| 214 | * |
||
| 215 | * @param mixed $obj The object to compare to. |
||
| 216 | * @return boolean Whether equal to the object specified. |
||
| 217 | */ |
||
| 218 | View Code Duplication | public function equals($obj) |
|
| 234 | |||
| 235 | /** |
||
| 236 | * Get the associative array of the virtual columns in this object |
||
| 237 | * |
||
| 238 | * @return array |
||
| 239 | */ |
||
| 240 | public function getVirtualColumns() |
||
| 244 | |||
| 245 | /** |
||
| 246 | * Checks the existence of a virtual column in this object |
||
| 247 | * |
||
| 248 | * @param string $name The virtual column name |
||
| 249 | * @return boolean |
||
| 250 | */ |
||
| 251 | public function hasVirtualColumn($name) |
||
| 255 | |||
| 256 | /** |
||
| 257 | * Get the value of a virtual column in this object |
||
| 258 | * |
||
| 259 | * @param string $name The virtual column name |
||
| 260 | * @return mixed |
||
| 261 | * |
||
| 262 | * @throws PropelException |
||
| 263 | */ |
||
| 264 | View Code Duplication | public function getVirtualColumn($name) |
|
| 272 | |||
| 273 | /** |
||
| 274 | * Set the value of a virtual column in this object |
||
| 275 | * |
||
| 276 | * @param string $name The virtual column name |
||
| 277 | * @param mixed $value The value to give to the virtual column |
||
| 278 | * |
||
| 279 | * @return $this|Channel The current object, for fluid interface |
||
| 280 | */ |
||
| 281 | public function setVirtualColumn($name, $value) |
||
| 287 | |||
| 288 | /** |
||
| 289 | * Logs a message using Propel::log(). |
||
| 290 | * |
||
| 291 | * @param string $msg |
||
| 292 | * @param int $priority One of the Propel::LOG_* logging levels |
||
| 293 | * @return boolean |
||
| 294 | */ |
||
| 295 | protected function log($msg, $priority = Propel::LOG_INFO) |
||
| 299 | |||
| 300 | /** |
||
| 301 | * Export the current object properties to a string, using a given parser format |
||
| 302 | * <code> |
||
| 303 | * $book = BookQuery::create()->findPk(9012); |
||
| 304 | * echo $book->exportTo('JSON'); |
||
| 305 | * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
||
| 306 | * </code> |
||
| 307 | * |
||
| 308 | * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') |
||
| 309 | * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. |
||
| 310 | * @return string The exported data |
||
| 311 | */ |
||
| 312 | View Code Duplication | public function exportTo($parser, $includeLazyLoadColumns = true) |
|
| 320 | |||
| 321 | /** |
||
| 322 | * Clean up internal collections prior to serializing |
||
| 323 | * Avoids recursive loops that turn into segmentation faults when serializing |
||
| 324 | */ |
||
| 325 | View Code Duplication | public function __sleep() |
|
| 339 | |||
| 340 | /** |
||
| 341 | * Get the [id] column value. |
||
| 342 | * |
||
| 343 | * @return int |
||
| 344 | */ |
||
| 345 | public function getId() |
||
| 349 | |||
| 350 | /** |
||
| 351 | * Get the [instance_name] column value. |
||
| 352 | * |
||
| 353 | * @return string |
||
| 354 | */ |
||
| 355 | public function getInstanceName() |
||
| 359 | |||
| 360 | /** |
||
| 361 | * Get the [name] column value. |
||
| 362 | * |
||
| 363 | * @return string |
||
| 364 | */ |
||
| 365 | public function getName() |
||
| 369 | |||
| 370 | /** |
||
| 371 | * Set the value of [id] column. |
||
| 372 | * |
||
| 373 | * @param int $v new value |
||
| 374 | * @return $this|\Jalle19\StatusManager\Database\Channel The current object (for fluent API support) |
||
| 375 | */ |
||
| 376 | public function setId($v) |
||
| 389 | |||
| 390 | /** |
||
| 391 | * Set the value of [instance_name] column. |
||
| 392 | * |
||
| 393 | * @param string $v new value |
||
| 394 | * @return $this|\Jalle19\StatusManager\Database\Channel The current object (for fluent API support) |
||
| 395 | */ |
||
| 396 | View Code Duplication | public function setInstanceName($v) |
|
| 413 | |||
| 414 | /** |
||
| 415 | * Set the value of [name] column. |
||
| 416 | * |
||
| 417 | * @param string $v new value |
||
| 418 | * @return $this|\Jalle19\StatusManager\Database\Channel The current object (for fluent API support) |
||
| 419 | */ |
||
| 420 | public function setName($v) |
||
| 433 | |||
| 434 | /** |
||
| 435 | * Indicates whether the columns in this object are only set to default values. |
||
| 436 | * |
||
| 437 | * This method can be used in conjunction with isModified() to indicate whether an object is both |
||
| 438 | * modified _and_ has some values set which are non-default. |
||
| 439 | * |
||
| 440 | * @return boolean Whether the columns in this object are only been set with default values. |
||
| 441 | */ |
||
| 442 | public function hasOnlyDefaultValues() |
||
| 447 | |||
| 448 | /** |
||
| 449 | * Hydrates (populates) the object variables with values from the database resultset. |
||
| 450 | * |
||
| 451 | * An offset (0-based "start column") is specified so that objects can be hydrated |
||
| 452 | * with a subset of the columns in the resultset rows. This is needed, for example, |
||
| 453 | * for results of JOIN queries where the resultset row includes columns from two or |
||
| 454 | * more tables. |
||
| 455 | * |
||
| 456 | * @param array $row The row returned by DataFetcher->fetch(). |
||
| 457 | * @param int $startcol 0-based offset column which indicates which restultset column to start with. |
||
| 458 | * @param boolean $rehydrate Whether this object is being re-hydrated from the database. |
||
| 459 | * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
||
| 460 | One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
| 461 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 462 | * |
||
| 463 | * @return int next starting column |
||
| 464 | * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. |
||
| 465 | */ |
||
| 466 | View Code Duplication | public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) |
|
| 492 | |||
| 493 | /** |
||
| 494 | * Checks and repairs the internal consistency of the object. |
||
| 495 | * |
||
| 496 | * This method is executed after an already-instantiated object is re-hydrated |
||
| 497 | * from the database. It exists to check any foreign keys to make sure that |
||
| 498 | * the objects related to the current object are correct based on foreign key. |
||
| 499 | * |
||
| 500 | * You can override this method in the stub class, but you should always invoke |
||
| 501 | * the base method from the overridden method (i.e. parent::ensureConsistency()), |
||
| 502 | * in case your model changes. |
||
| 503 | * |
||
| 504 | * @throws PropelException |
||
| 505 | */ |
||
| 506 | public function ensureConsistency() |
||
| 512 | |||
| 513 | /** |
||
| 514 | * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. |
||
| 515 | * |
||
| 516 | * This will only work if the object has been saved and has a valid primary key set. |
||
| 517 | * |
||
| 518 | * @param boolean $deep (optional) Whether to also de-associated any related objects. |
||
| 519 | * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. |
||
| 520 | * @return void |
||
| 521 | * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db |
||
| 522 | */ |
||
| 523 | public function reload($deep = false, ConnectionInterface $con = null) |
||
| 555 | |||
| 556 | /** |
||
| 557 | * Removes this object from datastore and sets delete attribute. |
||
| 558 | * |
||
| 559 | * @param ConnectionInterface $con |
||
| 560 | * @return void |
||
| 561 | * @throws PropelException |
||
| 562 | * @see Channel::setDeleted() |
||
| 563 | * @see Channel::isDeleted() |
||
| 564 | */ |
||
| 565 | View Code Duplication | public function delete(ConnectionInterface $con = null) |
|
| 586 | |||
| 587 | /** |
||
| 588 | * Persists this object to the database. |
||
| 589 | * |
||
| 590 | * If the object is new, it inserts it; otherwise an update is performed. |
||
| 591 | * All modified related objects will also be persisted in the doSave() |
||
| 592 | * method. This method wraps all precipitate database operations in a |
||
| 593 | * single transaction. |
||
| 594 | * |
||
| 595 | * @param ConnectionInterface $con |
||
| 596 | * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
||
| 597 | * @throws PropelException |
||
| 598 | * @see doSave() |
||
| 599 | */ |
||
| 600 | View Code Duplication | public function save(ConnectionInterface $con = null) |
|
| 634 | |||
| 635 | /** |
||
| 636 | * Performs the work of inserting or updating the row in the database. |
||
| 637 | * |
||
| 638 | * If the object is new, it inserts it; otherwise an update is performed. |
||
| 639 | * All related objects are also updated in this method. |
||
| 640 | * |
||
| 641 | * @param ConnectionInterface $con |
||
| 642 | * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
||
| 643 | * @throws PropelException |
||
| 644 | * @see save() |
||
| 645 | */ |
||
| 646 | protected function doSave(ConnectionInterface $con) |
||
| 698 | |||
| 699 | /** |
||
| 700 | * Insert the row in the database. |
||
| 701 | * |
||
| 702 | * @param ConnectionInterface $con |
||
| 703 | * |
||
| 704 | * @throws PropelException |
||
| 705 | * @see doSave() |
||
| 706 | */ |
||
| 707 | View Code Duplication | protected function doInsert(ConnectionInterface $con) |
|
| 764 | |||
| 765 | /** |
||
| 766 | * Update the row in the database. |
||
| 767 | * |
||
| 768 | * @param ConnectionInterface $con |
||
| 769 | * |
||
| 770 | * @return Integer Number of updated rows |
||
| 771 | * @see doSave() |
||
| 772 | */ |
||
| 773 | protected function doUpdate(ConnectionInterface $con) |
||
| 780 | |||
| 781 | /** |
||
| 782 | * Retrieves a field from the object by name passed in as a string. |
||
| 783 | * |
||
| 784 | * @param string $name name |
||
| 785 | * @param string $type The type of fieldname the $name is of: |
||
| 786 | * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
| 787 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 788 | * Defaults to TableMap::TYPE_PHPNAME. |
||
| 789 | * @return mixed Value of field. |
||
| 790 | */ |
||
| 791 | View Code Duplication | public function getByName($name, $type = TableMap::TYPE_PHPNAME) |
|
| 798 | |||
| 799 | /** |
||
| 800 | * Retrieves a field from the object by Position as specified in the xml schema. |
||
| 801 | * Zero-based. |
||
| 802 | * |
||
| 803 | * @param int $pos position in xml schema |
||
| 804 | * @return mixed Value of field at $pos |
||
| 805 | */ |
||
| 806 | View Code Duplication | public function getByPosition($pos) |
|
| 823 | |||
| 824 | /** |
||
| 825 | * Exports the object as an array. |
||
| 826 | * |
||
| 827 | * You can specify the key type of the array by passing one of the class |
||
| 828 | * type constants. |
||
| 829 | * |
||
| 830 | * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
| 831 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 832 | * Defaults to TableMap::TYPE_PHPNAME. |
||
| 833 | * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. |
||
| 834 | * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion |
||
| 835 | * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. |
||
| 836 | * |
||
| 837 | * @return array an associative array containing the field names (as keys) and field values |
||
| 838 | */ |
||
| 839 | public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) |
||
| 892 | |||
| 893 | /** |
||
| 894 | * Sets a field from the object by name passed in as a string. |
||
| 895 | * |
||
| 896 | * @param string $name |
||
| 897 | * @param mixed $value field value |
||
| 898 | * @param string $type The type of fieldname the $name is of: |
||
| 899 | * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
| 900 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 901 | * Defaults to TableMap::TYPE_PHPNAME. |
||
| 902 | * @return $this|\Jalle19\StatusManager\Database\Channel |
||
| 903 | */ |
||
| 904 | public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) |
||
| 910 | |||
| 911 | /** |
||
| 912 | * Sets a field from the object by Position as specified in the xml schema. |
||
| 913 | * Zero-based. |
||
| 914 | * |
||
| 915 | * @param int $pos position in xml schema |
||
| 916 | * @param mixed $value field value |
||
| 917 | * @return $this|\Jalle19\StatusManager\Database\Channel |
||
| 918 | */ |
||
| 919 | View Code Duplication | public function setByPosition($pos, $value) |
|
| 935 | |||
| 936 | /** |
||
| 937 | * Populates the object using an array. |
||
| 938 | * |
||
| 939 | * This is particularly useful when populating an object from one of the |
||
| 940 | * request arrays (e.g. $_POST). This method goes through the column |
||
| 941 | * names, checking to see whether a matching key exists in populated |
||
| 942 | * array. If so the setByName() method is called for that column. |
||
| 943 | * |
||
| 944 | * You can specify the key type of the array by additionally passing one |
||
| 945 | * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
| 946 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 947 | * The default key type is the column's TableMap::TYPE_PHPNAME. |
||
| 948 | * |
||
| 949 | * @param array $arr An array to populate the object from. |
||
| 950 | * @param string $keyType The type of keys the array uses. |
||
| 951 | * @return void |
||
| 952 | */ |
||
| 953 | View Code Duplication | public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) |
|
| 967 | |||
| 968 | /** |
||
| 969 | * Populate the current object from a string, using a given parser format |
||
| 970 | * <code> |
||
| 971 | * $book = new Book(); |
||
| 972 | * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
||
| 973 | * </code> |
||
| 974 | * |
||
| 975 | * You can specify the key type of the array by additionally passing one |
||
| 976 | * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
| 977 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 978 | * The default key type is the column's TableMap::TYPE_PHPNAME. |
||
| 979 | * |
||
| 980 | * @param mixed $parser A AbstractParser instance, |
||
| 981 | * or a format name ('XML', 'YAML', 'JSON', 'CSV') |
||
| 982 | * @param string $data The source data to import from |
||
| 983 | * @param string $keyType The type of keys the array uses. |
||
| 984 | * |
||
| 985 | * @return $this|\Jalle19\StatusManager\Database\Channel The current object, for fluid interface |
||
| 986 | */ |
||
| 987 | View Code Duplication | public function importFrom($parser, $data, $keyType = TableMap::TYPE_PHPNAME) |
|
| 997 | |||
| 998 | /** |
||
| 999 | * Build a Criteria object containing the values of all modified columns in this object. |
||
| 1000 | * |
||
| 1001 | * @return Criteria The Criteria object containing all modified values. |
||
| 1002 | */ |
||
| 1003 | View Code Duplication | public function buildCriteria() |
|
| 1019 | |||
| 1020 | /** |
||
| 1021 | * Builds a Criteria object containing the primary key for this object. |
||
| 1022 | * |
||
| 1023 | * Unlike buildCriteria() this method includes the primary key values regardless |
||
| 1024 | * of whether or not they have been modified. |
||
| 1025 | * |
||
| 1026 | * @throws LogicException if no primary key is defined |
||
| 1027 | * |
||
| 1028 | * @return Criteria The Criteria object containing value(s) for primary key(s). |
||
| 1029 | */ |
||
| 1030 | public function buildPkeyCriteria() |
||
| 1037 | |||
| 1038 | /** |
||
| 1039 | * If the primary key is not null, return the hashcode of the |
||
| 1040 | * primary key. Otherwise, return the hash code of the object. |
||
| 1041 | * |
||
| 1042 | * @return int Hashcode |
||
| 1043 | */ |
||
| 1044 | View Code Duplication | public function hashCode() |
|
| 1059 | |||
| 1060 | /** |
||
| 1061 | * Returns the primary key for this object (row). |
||
| 1062 | * @return int |
||
| 1063 | */ |
||
| 1064 | public function getPrimaryKey() |
||
| 1068 | |||
| 1069 | /** |
||
| 1070 | * Generic method to set the primary key (id column). |
||
| 1071 | * |
||
| 1072 | * @param int $key Primary key. |
||
| 1073 | * @return void |
||
| 1074 | */ |
||
| 1075 | public function setPrimaryKey($key) |
||
| 1079 | |||
| 1080 | /** |
||
| 1081 | * Returns true if the primary key for this object is null. |
||
| 1082 | * @return boolean |
||
| 1083 | */ |
||
| 1084 | public function isPrimaryKeyNull() |
||
| 1088 | |||
| 1089 | /** |
||
| 1090 | * Sets contents of passed object to values from current object. |
||
| 1091 | * |
||
| 1092 | * If desired, this method can also make copies of all associated (fkey referrers) |
||
| 1093 | * objects. |
||
| 1094 | * |
||
| 1095 | * @param object $copyObj An object of \Jalle19\StatusManager\Database\Channel (or compatible) type. |
||
| 1096 | * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
||
| 1097 | * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. |
||
| 1098 | * @throws PropelException |
||
| 1099 | */ |
||
| 1100 | public function copyInto($copyObj, $deepCopy = false, $makeNew = true) |
||
| 1123 | |||
| 1124 | /** |
||
| 1125 | * Makes a copy of this object that will be inserted as a new row in table when saved. |
||
| 1126 | * It creates a new object filling in the simple attributes, but skipping any primary |
||
| 1127 | * keys that are defined for the table. |
||
| 1128 | * |
||
| 1129 | * If desired, this method can also make copies of all associated (fkey referrers) |
||
| 1130 | * objects. |
||
| 1131 | * |
||
| 1132 | * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
||
| 1133 | * @return \Jalle19\StatusManager\Database\Channel Clone of current object. |
||
| 1134 | * @throws PropelException |
||
| 1135 | */ |
||
| 1136 | View Code Duplication | public function copy($deepCopy = false) |
|
| 1145 | |||
| 1146 | /** |
||
| 1147 | * Declares an association between this object and a ChildInstance object. |
||
| 1148 | * |
||
| 1149 | * @param ChildInstance $v |
||
| 1150 | * @return $this|\Jalle19\StatusManager\Database\Channel The current object (for fluent API support) |
||
| 1151 | * @throws PropelException |
||
| 1152 | */ |
||
| 1153 | public function setInstance(ChildInstance $v = null) |
||
| 1172 | |||
| 1173 | |||
| 1174 | /** |
||
| 1175 | * Get the associated ChildInstance object |
||
| 1176 | * |
||
| 1177 | * @param ConnectionInterface $con Optional Connection object. |
||
| 1178 | * @return ChildInstance The associated ChildInstance object. |
||
| 1179 | * @throws PropelException |
||
| 1180 | */ |
||
| 1181 | View Code Duplication | public function getInstance(ConnectionInterface $con = null) |
|
| 1196 | |||
| 1197 | |||
| 1198 | /** |
||
| 1199 | * Initializes a collection based on the name of a relation. |
||
| 1200 | * Avoids crafting an 'init[$relationName]s' method name |
||
| 1201 | * that wouldn't work when StandardEnglishPluralizer is used. |
||
| 1202 | * |
||
| 1203 | * @param string $relationName The name of the relation to initialize |
||
| 1204 | * @return void |
||
| 1205 | */ |
||
| 1206 | public function initRelation($relationName) |
||
| 1212 | |||
| 1213 | /** |
||
| 1214 | * Clears out the collSubscriptions collection |
||
| 1215 | * |
||
| 1216 | * This does not modify the database; however, it will remove any associated objects, causing |
||
| 1217 | * them to be refetched by subsequent calls to accessor method. |
||
| 1218 | * |
||
| 1219 | * @return void |
||
| 1220 | * @see addSubscriptions() |
||
| 1221 | */ |
||
| 1222 | public function clearSubscriptions() |
||
| 1226 | |||
| 1227 | /** |
||
| 1228 | * Reset is the collSubscriptions collection loaded partially. |
||
| 1229 | */ |
||
| 1230 | public function resetPartialSubscriptions($v = true) |
||
| 1234 | |||
| 1235 | /** |
||
| 1236 | * Initializes the collSubscriptions collection. |
||
| 1237 | * |
||
| 1238 | * By default this just sets the collSubscriptions collection to an empty array (like clearcollSubscriptions()); |
||
| 1239 | * however, you may wish to override this method in your stub class to provide setting appropriate |
||
| 1240 | * to your application -- for example, setting the initial array to the values stored in database. |
||
| 1241 | * |
||
| 1242 | * @param boolean $overrideExisting If set to true, the method call initializes |
||
| 1243 | * the collection even if it is not empty |
||
| 1244 | * |
||
| 1245 | * @return void |
||
| 1246 | */ |
||
| 1247 | View Code Duplication | public function initSubscriptions($overrideExisting = true) |
|
| 1258 | |||
| 1259 | /** |
||
| 1260 | * Gets an array of ChildSubscription objects which contain a foreign key that references this object. |
||
| 1261 | * |
||
| 1262 | * If the $criteria is not null, it is used to always fetch the results from the database. |
||
| 1263 | * Otherwise the results are fetched from the database the first time, then cached. |
||
| 1264 | * Next time the same method is called without $criteria, the cached collection is returned. |
||
| 1265 | * If this ChildChannel is new, it will return |
||
| 1266 | * an empty collection or the current collection; the criteria is ignored on a new object. |
||
| 1267 | * |
||
| 1268 | * @param Criteria $criteria optional Criteria object to narrow the query |
||
| 1269 | * @param ConnectionInterface $con optional connection object |
||
| 1270 | * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
||
| 1271 | * @throws PropelException |
||
| 1272 | */ |
||
| 1273 | View Code Duplication | public function getSubscriptions(Criteria $criteria = null, ConnectionInterface $con = null) |
|
| 1316 | |||
| 1317 | /** |
||
| 1318 | * Sets a collection of ChildSubscription objects related by a one-to-many relationship |
||
| 1319 | * to the current object. |
||
| 1320 | * It will also schedule objects for deletion based on a diff between old objects (aka persisted) |
||
| 1321 | * and new objects from the given Propel collection. |
||
| 1322 | * |
||
| 1323 | * @param Collection $subscriptions A Propel collection. |
||
| 1324 | * @param ConnectionInterface $con Optional connection object |
||
| 1325 | * @return $this|ChildChannel The current object (for fluent API support) |
||
| 1326 | */ |
||
| 1327 | public function setSubscriptions(Collection $subscriptions, ConnectionInterface $con = null) |
||
| 1349 | |||
| 1350 | /** |
||
| 1351 | * Returns the number of related Subscription objects. |
||
| 1352 | * |
||
| 1353 | * @param Criteria $criteria |
||
| 1354 | * @param boolean $distinct |
||
| 1355 | * @param ConnectionInterface $con |
||
| 1356 | * @return int Count of related Subscription objects. |
||
| 1357 | * @throws PropelException |
||
| 1358 | */ |
||
| 1359 | View Code Duplication | public function countSubscriptions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) |
|
| 1383 | |||
| 1384 | /** |
||
| 1385 | * Method called to associate a ChildSubscription object to this object |
||
| 1386 | * through the ChildSubscription foreign key attribute. |
||
| 1387 | * |
||
| 1388 | * @param ChildSubscription $l ChildSubscription |
||
| 1389 | * @return $this|\Jalle19\StatusManager\Database\Channel The current object (for fluent API support) |
||
| 1390 | */ |
||
| 1391 | View Code Duplication | public function addSubscription(ChildSubscription $l) |
|
| 1408 | |||
| 1409 | /** |
||
| 1410 | * @param ChildSubscription $subscription The ChildSubscription object to add. |
||
| 1411 | */ |
||
| 1412 | protected function doAddSubscription(ChildSubscription $subscription) |
||
| 1417 | |||
| 1418 | /** |
||
| 1419 | * @param ChildSubscription $subscription The ChildSubscription object to remove. |
||
| 1420 | * @return $this|ChildChannel The current object (for fluent API support) |
||
| 1421 | */ |
||
| 1422 | public function removeSubscription(ChildSubscription $subscription) |
||
| 1437 | |||
| 1438 | |||
| 1439 | /** |
||
| 1440 | * If this collection has already been initialized with |
||
| 1441 | * an identical criteria, it returns the collection. |
||
| 1442 | * Otherwise if this Channel is new, it will return |
||
| 1443 | * an empty collection; or if this Channel has previously |
||
| 1444 | * been saved, it will retrieve related Subscriptions from storage. |
||
| 1445 | * |
||
| 1446 | * This method is protected by default in order to keep the public |
||
| 1447 | * api reasonable. You can provide public methods for those you |
||
| 1448 | * actually need in Channel. |
||
| 1449 | * |
||
| 1450 | * @param Criteria $criteria optional Criteria object to narrow the query |
||
| 1451 | * @param ConnectionInterface $con optional connection object |
||
| 1452 | * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
||
| 1453 | * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
||
| 1454 | */ |
||
| 1455 | View Code Duplication | public function getSubscriptionsJoinInstance(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 1462 | |||
| 1463 | |||
| 1464 | /** |
||
| 1465 | * If this collection has already been initialized with |
||
| 1466 | * an identical criteria, it returns the collection. |
||
| 1467 | * Otherwise if this Channel is new, it will return |
||
| 1468 | * an empty collection; or if this Channel has previously |
||
| 1469 | * been saved, it will retrieve related Subscriptions from storage. |
||
| 1470 | * |
||
| 1471 | * This method is protected by default in order to keep the public |
||
| 1472 | * api reasonable. You can provide public methods for those you |
||
| 1473 | * actually need in Channel. |
||
| 1474 | * |
||
| 1475 | * @param Criteria $criteria optional Criteria object to narrow the query |
||
| 1476 | * @param ConnectionInterface $con optional connection object |
||
| 1477 | * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
||
| 1478 | * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
||
| 1479 | */ |
||
| 1480 | View Code Duplication | public function getSubscriptionsJoinUser(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 1487 | |||
| 1488 | /** |
||
| 1489 | * Clears the current object, sets all attributes to their default values and removes |
||
| 1490 | * outgoing references as well as back-references (from other objects to this one. Results probably in a database |
||
| 1491 | * change of those foreign objects when you call `save` there). |
||
| 1492 | */ |
||
| 1493 | View Code Duplication | public function clear() |
|
| 1507 | |||
| 1508 | /** |
||
| 1509 | * Resets all references and back-references to other model objects or collections of model objects. |
||
| 1510 | * |
||
| 1511 | * This method is used to reset all php object references (not the actual reference in the database). |
||
| 1512 | * Necessary for object serialisation. |
||
| 1513 | * |
||
| 1514 | * @param boolean $deep Whether to also clear the references on all referrer objects. |
||
| 1515 | */ |
||
| 1516 | public function clearAllReferences($deep = false) |
||
| 1529 | |||
| 1530 | /** |
||
| 1531 | * Return the string representation of this object |
||
| 1532 | * |
||
| 1533 | * @return string |
||
| 1534 | */ |
||
| 1535 | public function __toString() |
||
| 1539 | |||
| 1540 | /** |
||
| 1541 | * Code to be run before persisting the object |
||
| 1542 | * @param ConnectionInterface $con |
||
| 1543 | * @return boolean |
||
| 1544 | */ |
||
| 1545 | public function preSave(ConnectionInterface $con = null) |
||
| 1549 | |||
| 1550 | /** |
||
| 1551 | * Code to be run after persisting the object |
||
| 1552 | * @param ConnectionInterface $con |
||
| 1553 | */ |
||
| 1554 | public function postSave(ConnectionInterface $con = null) |
||
| 1558 | |||
| 1559 | /** |
||
| 1560 | * Code to be run before inserting to database |
||
| 1561 | * @param ConnectionInterface $con |
||
| 1562 | * @return boolean |
||
| 1563 | */ |
||
| 1564 | public function preInsert(ConnectionInterface $con = null) |
||
| 1568 | |||
| 1569 | /** |
||
| 1570 | * Code to be run after inserting to database |
||
| 1571 | * @param ConnectionInterface $con |
||
| 1572 | */ |
||
| 1573 | public function postInsert(ConnectionInterface $con = null) |
||
| 1577 | |||
| 1578 | /** |
||
| 1579 | * Code to be run before updating the object in database |
||
| 1580 | * @param ConnectionInterface $con |
||
| 1581 | * @return boolean |
||
| 1582 | */ |
||
| 1583 | public function preUpdate(ConnectionInterface $con = null) |
||
| 1587 | |||
| 1588 | /** |
||
| 1589 | * Code to be run after updating the object in database |
||
| 1590 | * @param ConnectionInterface $con |
||
| 1591 | */ |
||
| 1592 | public function postUpdate(ConnectionInterface $con = null) |
||
| 1596 | |||
| 1597 | /** |
||
| 1598 | * Code to be run before deleting the object in database |
||
| 1599 | * @param ConnectionInterface $con |
||
| 1600 | * @return boolean |
||
| 1601 | */ |
||
| 1602 | public function preDelete(ConnectionInterface $con = null) |
||
| 1606 | |||
| 1607 | /** |
||
| 1608 | * Code to be run after deleting the object in database |
||
| 1609 | * @param ConnectionInterface $con |
||
| 1610 | */ |
||
| 1611 | public function postDelete(ConnectionInterface $con = null) |
||
| 1615 | |||
| 1616 | |||
| 1617 | /** |
||
| 1618 | * Derived method to catches calls to undefined methods. |
||
| 1619 | * |
||
| 1620 | * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). |
||
| 1621 | * Allows to define default __call() behavior if you overwrite __call() |
||
| 1622 | * |
||
| 1623 | * @param string $name |
||
| 1624 | * @param mixed $params |
||
| 1625 | * |
||
| 1626 | * @return array|string |
||
| 1627 | */ |
||
| 1628 | View Code Duplication | public function __call($name, $params) |
|
| 1657 | |||
| 1658 | } |
||
| 1659 |
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.