Completed
Push — development ( 227e3a...98bb7e )
by Andrij
14:37
created

PageLink::hydrate()   F

Complexity

Conditions 15
Paths 19118

Size

Total Lines 35
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 15
eloc 21
c 1
b 0
f 0
nc 19118
nop 4
dl 0
loc 35
rs 2.7451

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace mod_link\models\Base;
4
5
use \Exception;
6
use \PDO;
7
use Base\PropelBaseModelClass;
8
use Propel\Runtime\Propel;
9
use Propel\Runtime\ActiveQuery\Criteria;
10
use Propel\Runtime\ActiveQuery\ModelCriteria;
11
use Propel\Runtime\ActiveRecord\ActiveRecordInterface;
12
use Propel\Runtime\Collection\Collection;
13
use Propel\Runtime\Collection\ObjectCollection;
14
use Propel\Runtime\Connection\ConnectionInterface;
15
use Propel\Runtime\Exception\BadMethodCallException;
16
use Propel\Runtime\Exception\LogicException;
17
use Propel\Runtime\Exception\PropelException;
18
use Propel\Runtime\Map\TableMap;
19
use Propel\Runtime\Parser\AbstractParser;
20
use mod_link\models\PageLink as ChildPageLink;
21
use mod_link\models\PageLinkProduct as ChildPageLinkProduct;
22
use mod_link\models\PageLinkProductQuery as ChildPageLinkProductQuery;
23
use mod_link\models\PageLinkQuery as ChildPageLinkQuery;
24
use mod_link\models\Map\PageLinkProductTableMap;
25
use mod_link\models\Map\PageLinkTableMap;
26
27
/**
28
 * Base class that represents a row from the 'page_link' table.
29
 *
30
 *
31
 *
32
 * @package    propel.generator.mod_link.models.Base
33
 */
34
abstract class PageLink extends PropelBaseModelClass implements ActiveRecordInterface
35
{
0 ignored issues
show
introduced by
Opening brace of a class must be on the same line as the definition
Loading history...
36
    /**
37
     * TableMap class name
38
     */
39
    const TABLE_MAP = '\\mod_link\\models\\Map\\PageLinkTableMap';
40
41
42
    /**
43
     * attribute to determine if this object has previously been saved.
44
     * @var boolean
45
     */
46
    protected $new = true;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before member var; 2 found
Loading history...
47
48
    /**
49
     * attribute to determine whether this object has been deleted.
50
     * @var boolean
51
     */
52
    protected $deleted = false;
53
54
    /**
55
     * The columns that have been modified in current object.
56
     * Tracking modified columns allows us to only update modified columns.
57
     * @var array
58
     */
59
    protected $modifiedColumns = array();
60
61
    /**
62
     * The (virtual) columns that are added at runtime
63
     * The formatters can add supplementary columns based on a resultset
64
     * @var array
65
     */
66
    protected $virtualColumns = array();
67
68
    /**
69
     * The value for the id field.
70
     *
71
     * @var        int
72
     */
73
    protected $id;
74
75
    /**
76
     * The value for the page_id field.
77
     *
78
     * @var        int
79
     */
80
    protected $page_id;
81
82
    /**
83
     * The value for the active_from field.
84
     *
85
     * @var        int
86
     */
87
    protected $active_from;
88
89
    /**
90
     * The value for the active_to field.
91
     *
92
     * @var        int
93
     */
94
    protected $active_to;
95
96
    /**
97
     * The value for the show_on field.
98
     *
99
     * @var        boolean
100
     */
101
    protected $show_on;
102
103
    /**
104
     * The value for the permanent field.
105
     *
106
     * @var        boolean
107
     */
108
    protected $permanent;
109
110
    /**
111
     * @var        ObjectCollection|ChildPageLinkProduct[] Collection to store aggregation of ChildPageLinkProduct objects.
112
     */
113
    protected $collPageLinkProducts;
114
    protected $collPageLinkProductsPartial;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before member var; 0 found
Loading history...
115
116
    /**
117
     * Flag to prevent endless save loop, if this object is referenced
118
     * by another object which falls in this transaction.
119
     *
120
     * @var boolean
121
     */
122
    protected $alreadyInSave = false;
123
124
    /**
125
     * An array of objects scheduled for deletion.
126
     * @var ObjectCollection|ChildPageLinkProduct[]
127
     */
128
    protected $pageLinkProductsScheduledForDeletion = null;
129
130
    /**
131
     * Initializes internal state of mod_link\models\Base\PageLink object.
132
     */
133
    public function __construct()
134
    {
135
    }
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()
143
    {
144
        return !!$this->modifiedColumns;
145
    }
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
0 ignored issues
show
introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
151
     * @return boolean True if $col has been modified.
152
     */
153
    public function isColumnModified($col)
154
    {
155
        return $this->modifiedColumns && isset($this->modifiedColumns[$col]);
156
    }
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()
163
    {
164
        return $this->modifiedColumns ? array_keys($this->modifiedColumns) : [];
165
    }
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()
175
    {
176
        return $this->new;
177
    }
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)
186
    {
187
        $this->new = (boolean) $b;
188
    }
189
190
    /**
191
     * Whether this object has been deleted.
192
     * @return boolean The deleted state of this object.
193
     */
194
    public function isDeleted()
195
    {
196
        return $this->deleted;
197
    }
198
199
    /**
200
     * Specify whether this object has been deleted.
201
     * @param  boolean $b The deleted state of this object.
202
     * @return void
0 ignored issues
show
introduced by
If there is no return value for a function, there must not be a @return tag.
Loading history...
203
     */
204
    public function setDeleted($b)
205
    {
206
        $this->deleted = (boolean) $b;
207
    }
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
0 ignored issues
show
introduced by
If there is no return value for a function, there must not be a @return tag.
Loading history...
213
     */
214 View Code Duplication
    public function resetModified($col = null)
215
    {
216
        if (null !== $col) {
217
            if (isset($this->modifiedColumns[$col])) {
218
                unset($this->modifiedColumns[$col]);
219
            }
220
        } else {
221
            $this->modifiedColumns = array();
222
        }
223
    }
224
225
    /**
226
     * Compares this with another <code>PageLink</code> instance.  If
227
     * <code>obj</code> is an instance of <code>PageLink</code>, delegates to
228
     * <code>equals(PageLink)</code>.  Otherwise, returns <code>false</code>.
229
     *
230
     * @param  mixed   $obj The object to compare to.
0 ignored issues
show
introduced by
Expected 1 spaces after parameter type; 3 found
Loading history...
231
     * @return boolean Whether equal to the object specified.
232
     */
233
    public function equals($obj)
234
    {
235
        if (!$obj instanceof static) {
236
            return false;
237
        }
238
239
        if ($this === $obj) {
240
            return true;
241
        }
242
243
        if (null === $this->getPrimaryKey() || null === $obj->getPrimaryKey()) {
244
            return false;
245
        }
246
247
        return $this->getPrimaryKey() === $obj->getPrimaryKey();
248
    }
249
250
    /**
251
     * Get the associative array of the virtual columns in this object
252
     *
253
     * @return array
254
     */
255
    public function getVirtualColumns()
256
    {
257
        return $this->virtualColumns;
258
    }
259
260
    /**
261
     * Checks the existence of a virtual column in this object
262
     *
263
     * @param  string  $name The virtual column name
0 ignored issues
show
introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
264
     * @return boolean
265
     */
266
    public function hasVirtualColumn($name)
267
    {
268
        return array_key_exists($name, $this->virtualColumns);
269
    }
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
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
278
     */
279
    public function getVirtualColumn($name)
280
    {
281
        if (!$this->hasVirtualColumn($name)) {
282
            throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
283
        }
284
285
        return $this->virtualColumns[$name];
286
    }
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
0 ignored issues
show
introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
293
     *
294
     * @return $this|PageLink The current object, for fluid interface
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
295
     */
296
    public function setVirtualColumn($name, $value)
297
    {
298
        $this->virtualColumns[$name] = $value;
299
300
        return $this;
301
    }
302
303
    /**
304
     * Logs a message using Propel::log().
305
     *
306
     * @param  string  $msg
0 ignored issues
show
introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
307
     * @param  int     $priority One of the Propel::LOG_* logging levels
0 ignored issues
show
introduced by
Expected 1 spaces after parameter type; 5 found
Loading history...
308
     * @return boolean
0 ignored issues
show
Documentation introduced by
Should the return type not be boolean|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
309
     */
310
    protected function log($msg, $priority = Propel::LOG_INFO)
311
    {
312
        return Propel::log(get_class($this) . ': ' . $msg, $priority);
313
    }
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')
0 ignored issues
show
introduced by
Expected 1 spaces after parameter type; 3 found
Loading history...
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)
328
    {
329
        if (!$parser instanceof AbstractParser) {
330
            $parser = AbstractParser::getParser($parser);
331
        }
332
333
        return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
0 ignored issues
show
Bug introduced by
It seems like $this->toArray(\Propel\R...Columns, array(), true) targeting mod_link\models\Base\PageLink::toArray() can also be of type string; however, Propel\Runtime\Parser\AbstractParser::fromArray() does only seem to accept array, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
334
    }
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()
341
    {
342
        $this->clearAllReferences();
343
344
        $cls = new \ReflectionClass($this);
345
        $propertyNames = [];
346
        $serializableProperties = array_diff($cls->getProperties(), $cls->getProperties(\ReflectionProperty::IS_STATIC));
347
348
        foreach($serializableProperties as $property) {
0 ignored issues
show
introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
349
            $propertyNames[] = $property->getName();
350
        }
351
352
        return $propertyNames;
353
    }
354
355
    /**
356
     * Get the [id] column value.
357
     *
358
     * @return int
359
     */
360
    public function getId()
361
    {
362
        return $this->id;
363
    }
364
365
    /**
366
     * Get the [page_id] column value.
367
     *
368
     * @return int
369
     */
370
    public function getPageId()
371
    {
372
        return $this->page_id;
373
    }
374
375
    /**
376
     * Get the [active_from] column value.
377
     *
378
     * @return int
379
     */
380
    public function getActiveFrom()
381
    {
382
        return $this->active_from;
383
    }
384
385
    /**
386
     * Get the [active_to] column value.
387
     *
388
     * @return int
389
     */
390
    public function getActiveTo()
391
    {
392
        return $this->active_to;
393
    }
394
395
    /**
396
     * Get the [show_on] column value.
397
     *
398
     * @return boolean
399
     */
400
    public function getShowOn()
401
    {
402
        return $this->show_on;
403
    }
404
405
    /**
406
     * Get the [show_on] column value.
407
     *
408
     * @return boolean
409
     */
410
    public function isShowOn()
411
    {
412
        return $this->getShowOn();
413
    }
414
415
    /**
416
     * Get the [permanent] column value.
417
     *
418
     * @return boolean
419
     */
420
    public function getPermanent()
421
    {
422
        return $this->permanent;
423
    }
424
425
    /**
426
     * Get the [permanent] column value.
427
     *
428
     * @return boolean
429
     */
430
    public function isPermanent()
431
    {
432
        return $this->getPermanent();
433
    }
434
435
    /**
436
     * Set the value of [id] column.
437
     *
438
     * @param int $v new value
439
     * @return $this|\mod_link\models\PageLink The current object (for fluent API support)
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
440
     */
441 View Code Duplication
    public function setId($v)
442
    {
443
        if ($v !== null) {
444
            $v = (int) $v;
445
        }
446
447
        if ($this->id !== $v) {
448
            $this->id = $v;
449
            $this->modifiedColumns[PageLinkTableMap::COL_ID] = true;
450
        }
451
452
        return $this;
453
    } // setId()
454
455
    /**
456
     * Set the value of [page_id] column.
457
     *
458
     * @param int $v new value
459
     * @return $this|\mod_link\models\PageLink The current object (for fluent API support)
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
460
     */
461
    public function setPageId($v)
462
    {
463
        if ($v !== null) {
464
            $v = (int) $v;
465
        }
466
467
        if ($this->page_id !== $v) {
468
            $this->page_id = $v;
469
            $this->modifiedColumns[PageLinkTableMap::COL_PAGE_ID] = true;
470
        }
471
472
        return $this;
473
    } // setPageId()
474
475
    /**
476
     * Set the value of [active_from] column.
477
     *
478
     * @param int $v new value
479
     * @return $this|\mod_link\models\PageLink The current object (for fluent API support)
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
480
     */
481
    public function setActiveFrom($v)
482
    {
483
        if ($v !== null) {
484
            $v = (int) $v;
485
        }
486
487
        if ($this->active_from !== $v) {
488
            $this->active_from = $v;
489
            $this->modifiedColumns[PageLinkTableMap::COL_ACTIVE_FROM] = true;
490
        }
491
492
        return $this;
493
    } // setActiveFrom()
494
495
    /**
496
     * Set the value of [active_to] column.
497
     *
498
     * @param int $v new value
499
     * @return $this|\mod_link\models\PageLink The current object (for fluent API support)
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
500
     */
501
    public function setActiveTo($v)
502
    {
503
        if ($v !== null) {
504
            $v = (int) $v;
505
        }
506
507
        if ($this->active_to !== $v) {
508
            $this->active_to = $v;
509
            $this->modifiedColumns[PageLinkTableMap::COL_ACTIVE_TO] = true;
510
        }
511
512
        return $this;
513
    } // setActiveTo()
514
515
    /**
516
     * Sets the value of the [show_on] column.
517
     * Non-boolean arguments are converted using the following rules:
518
     *   * 1, '1', 'true',  'on',  and 'yes' are converted to boolean true
519
     *   * 0, '0', 'false', 'off', and 'no'  are converted to boolean false
520
     * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
521
     *
522
     * @param  boolean|integer|string $v The new value
523
     * @return $this|\mod_link\models\PageLink The current object (for fluent API support)
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
524
     */
525 View Code Duplication
    public function setShowOn($v)
526
    {
527
        if ($v !== null) {
528
            if (is_string($v)) {
529
                $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
0 ignored issues
show
introduced by
If the line declaring an array spans longer than 80 characters, each element should be broken into its own line
Loading history...
530
            } else {
531
                $v = (boolean) $v;
532
            }
533
        }
534
535
        if ($this->show_on !== $v) {
536
            $this->show_on = $v;
537
            $this->modifiedColumns[PageLinkTableMap::COL_SHOW_ON] = true;
538
        }
539
540
        return $this;
541
    } // setShowOn()
542
543
    /**
544
     * Sets the value of the [permanent] column.
545
     * Non-boolean arguments are converted using the following rules:
546
     *   * 1, '1', 'true',  'on',  and 'yes' are converted to boolean true
547
     *   * 0, '0', 'false', 'off', and 'no'  are converted to boolean false
548
     * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
549
     *
550
     * @param  boolean|integer|string $v The new value
551
     * @return $this|\mod_link\models\PageLink The current object (for fluent API support)
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
552
     */
553 View Code Duplication
    public function setPermanent($v)
554
    {
555
        if ($v !== null) {
556
            if (is_string($v)) {
557
                $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
0 ignored issues
show
introduced by
If the line declaring an array spans longer than 80 characters, each element should be broken into its own line
Loading history...
558
            } else {
559
                $v = (boolean) $v;
560
            }
561
        }
562
563
        if ($this->permanent !== $v) {
564
            $this->permanent = $v;
565
            $this->modifiedColumns[PageLinkTableMap::COL_PERMANENT] = true;
566
        }
567
568
        return $this;
569
    } // setPermanent()
570
571
    /**
572
     * Indicates whether the columns in this object are only set to default values.
573
     *
574
     * This method can be used in conjunction with isModified() to indicate whether an object is both
575
     * modified _and_ has some values set which are non-default.
576
     *
577
     * @return boolean Whether the columns in this object are only been set with default values.
578
     */
579
    public function hasOnlyDefaultValues()
580
    {
581
        // otherwise, everything was equal, so return TRUE
582
        return true;
583
    } // hasOnlyDefaultValues()
584
585
    /**
586
     * Hydrates (populates) the object variables with values from the database resultset.
587
     *
588
     * An offset (0-based "start column") is specified so that objects can be hydrated
589
     * with a subset of the columns in the resultset rows.  This is needed, for example,
590
     * for results of JOIN queries where the resultset row includes columns from two or
591
     * more tables.
592
     *
593
     * @param array   $row       The row returned by DataFetcher->fetch().
0 ignored issues
show
introduced by
Expected 1 spaces after parameter type; 3 found
Loading history...
594
     * @param int     $startcol  0-based offset column which indicates which restultset column to start with.
0 ignored issues
show
introduced by
Expected 1 spaces after parameter type; 5 found
Loading history...
595
     * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
596
     * @param string  $indexType The index type of $row. Mostly DataFetcher->getIndexType().
0 ignored issues
show
introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
597
                                  One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME
598
     *                            TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
599
     *
600
     * @return int             next starting column
601
     * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
602
     */
603
    public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
604
    {
605
        try {
606
607
            $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : PageLinkTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
608
            $this->id = (null !== $col) ? (int) $col : null;
609
610
            $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : PageLinkTableMap::translateFieldName('PageId', TableMap::TYPE_PHPNAME, $indexType)];
611
            $this->page_id = (null !== $col) ? (int) $col : null;
612
613
            $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : PageLinkTableMap::translateFieldName('ActiveFrom', TableMap::TYPE_PHPNAME, $indexType)];
614
            $this->active_from = (null !== $col) ? (int) $col : null;
615
616
            $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : PageLinkTableMap::translateFieldName('ActiveTo', TableMap::TYPE_PHPNAME, $indexType)];
617
            $this->active_to = (null !== $col) ? (int) $col : null;
618
619
            $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : PageLinkTableMap::translateFieldName('ShowOn', TableMap::TYPE_PHPNAME, $indexType)];
620
            $this->show_on = (null !== $col) ? (boolean) $col : null;
621
622
            $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : PageLinkTableMap::translateFieldName('Permanent', TableMap::TYPE_PHPNAME, $indexType)];
623
            $this->permanent = (null !== $col) ? (boolean) $col : null;
624
            $this->resetModified();
625
626
            $this->setNew(false);
627
628
            if ($rehydrate) {
629
                $this->ensureConsistency();
630
            }
631
632
            return $startcol + 6; // 6 = PageLinkTableMap::NUM_HYDRATE_COLUMNS.
633
634
        } catch (Exception $e) {
635
            throw new PropelException(sprintf('Error populating %s object', '\\mod_link\\models\\PageLink'), 0, $e);
636
        }
637
    }
638
639
    /**
640
     * Checks and repairs the internal consistency of the object.
641
     *
642
     * This method is executed after an already-instantiated object is re-hydrated
643
     * from the database.  It exists to check any foreign keys to make sure that
644
     * the objects related to the current object are correct based on foreign key.
645
     *
646
     * You can override this method in the stub class, but you should always invoke
647
     * the base method from the overridden method (i.e. parent::ensureConsistency()),
648
     * in case your model changes.
649
     *
650
     * @throws PropelException
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
651
     */
652
    public function ensureConsistency()
653
    {
654
    } // ensureConsistency
655
656
    /**
657
     * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
658
     *
659
     * This will only work if the object has been saved and has a valid primary key set.
660
     *
661
     * @param      boolean $deep (optional) Whether to also de-associated any related objects.
662
     * @param      ConnectionInterface $con (optional) The ConnectionInterface connection to use.
663
     * @return void
0 ignored issues
show
introduced by
If there is no return value for a function, there must not be a @return tag.
Loading history...
664
     * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
665
     */
666
    public function reload($deep = false, ConnectionInterface $con = null)
667
    {
668
        if ($this->isDeleted()) {
669
            throw new PropelException("Cannot reload a deleted object.");
670
        }
671
672
        if ($this->isNew()) {
673
            throw new PropelException("Cannot reload an unsaved object.");
674
        }
675
676
        if ($con === null) {
677
            $con = Propel::getServiceContainer()->getReadConnection(PageLinkTableMap::DATABASE_NAME);
678
        }
679
680
        // We don't need to alter the object instance pool; we're just modifying this instance
681
        // already in the pool.
682
683
        $dataFetcher = ChildPageLinkQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class Propel\Runtime\ActiveQuery\BaseModelCriteria as the method find() does only exist in the following sub-classes of Propel\Runtime\ActiveQuery\BaseModelCriteria: Propel\Runtime\ActiveQuery\ModelCriteria, mod_link\models\Base\PageLinkProductQuery, mod_link\models\Base\PageLinkProductsQuery, mod_link\models\Base\PageLinkQuery, mod_link\models\PageLinkProductQuery, mod_link\models\PageLinkQuery, xbanners\models\BannerImageI18nQuery, xbanners\models\BannerImageQuery, xbanners\models\BannersI18nQuery, xbanners\models\BannersQuery, xbanners\models\Base\BannerImageI18nQuery, xbanners\models\Base\BannerImageQuery, xbanners\models\Base\BannersI18nQuery, xbanners\models\Base\BannersQuery. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
684
        $row = $dataFetcher->fetch();
685
        $dataFetcher->close();
686
        if (!$row) {
687
            throw new PropelException('Cannot find matching row in the database to reload object values.');
688
        }
689
        $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
690
691
        if ($deep) {  // also de-associate any related objects?
0 ignored issues
show
introduced by
There should be no white space after an opening "{"
Loading history...
692
693
            $this->collPageLinkProducts = null;
694
695
        } // if (deep)
696
    }
697
698
    /**
699
     * Removes this object from datastore and sets delete attribute.
700
     *
701
     * @param      ConnectionInterface $con
702
     * @return void
0 ignored issues
show
introduced by
If there is no return value for a function, there must not be a @return tag.
Loading history...
703
     * @throws PropelException
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
704
     * @see PageLink::setDeleted()
705
     * @see PageLink::isDeleted()
706
     */
707 View Code Duplication
    public function delete(ConnectionInterface $con = null)
708
    {
709
        if ($this->isDeleted()) {
710
            throw new PropelException("This object has already been deleted.");
711
        }
712
713
        if ($con === null) {
714
            $con = Propel::getServiceContainer()->getWriteConnection(PageLinkTableMap::DATABASE_NAME);
715
        }
716
717
        $con->transaction(function () use ($con) {
718
            $deleteQuery = ChildPageLinkQuery::create()
719
                ->filterByPrimaryKey($this->getPrimaryKey());
720
            $ret = $this->preDelete($con);
721
            if ($ret) {
722
                $deleteQuery->delete($con);
723
                $this->postDelete($con);
724
                $this->setDeleted(true);
725
            }
726
        });
727
    }
728
729
    /**
730
     * Persists this object to the database.
731
     *
732
     * If the object is new, it inserts it; otherwise an update is performed.
733
     * All modified related objects will also be persisted in the doSave()
734
     * method.  This method wraps all precipitate database operations in a
735
     * single transaction.
736
     *
737
     * @param      ConnectionInterface $con
738
     * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
739
     * @throws PropelException
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
740
     * @see doSave()
741
     */
742 View Code Duplication
    public function save(ConnectionInterface $con = null)
743
    {
744
        if ($this->isDeleted()) {
745
            throw new PropelException("You cannot save an object that has been deleted.");
746
        }
747
748
        if ($con === null) {
749
            $con = Propel::getServiceContainer()->getWriteConnection(PageLinkTableMap::DATABASE_NAME);
750
        }
751
752
        return $con->transaction(function () use ($con) {
753
            $ret = $this->preSave($con);
754
            $isInsert = $this->isNew();
755
            if ($isInsert) {
756
                $ret = $ret && $this->preInsert($con);
757
            } else {
758
                $ret = $ret && $this->preUpdate($con);
759
            }
760
            if ($ret) {
761
                $affectedRows = $this->doSave($con);
762
                if ($isInsert) {
763
                    $this->postInsert($con);
764
                } else {
765
                    $this->postUpdate($con);
766
                }
767
                $this->postSave($con);
768
                PageLinkTableMap::addInstanceToPool($this);
769
            } else {
770
                $affectedRows = 0;
771
            }
772
773
            return $affectedRows;
774
        });
775
    }
776
777
    /**
778
     * Performs the work of inserting or updating the row in the database.
779
     *
780
     * If the object is new, it inserts it; otherwise an update is performed.
781
     * All related objects are also updated in this method.
782
     *
783
     * @param      ConnectionInterface $con
784
     * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
785
     * @throws PropelException
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
786
     * @see save()
787
     */
788
    protected function doSave(ConnectionInterface $con)
789
    {
790
        $affectedRows = 0; // initialize var to track total num of affected rows
791
        if (!$this->alreadyInSave) {
792
            $this->alreadyInSave = true;
793
794
            if ($this->isNew() || $this->isModified()) {
795
                // persist changes
796
                if ($this->isNew()) {
797
                    $this->doInsert($con);
798
                    $affectedRows += 1;
799
                } else {
800
                    $affectedRows += $this->doUpdate($con);
801
                }
802
                $this->resetModified();
803
            }
804
805
            if ($this->pageLinkProductsScheduledForDeletion !== null) {
806
                if (!$this->pageLinkProductsScheduledForDeletion->isEmpty()) {
807
                    \mod_link\models\PageLinkProductQuery::create()
808
                        ->filterByPrimaryKeys($this->pageLinkProductsScheduledForDeletion->getPrimaryKeys(false))
809
                        ->delete($con);
810
                    $this->pageLinkProductsScheduledForDeletion = null;
811
                }
812
            }
813
814 View Code Duplication
            if ($this->collPageLinkProducts !== null) {
815
                foreach ($this->collPageLinkProducts as $referrerFK) {
816
                    if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
817
                        $affectedRows += $referrerFK->save($con);
818
                    }
819
                }
820
            }
821
822
            $this->alreadyInSave = false;
823
824
        }
825
826
        return $affectedRows;
827
    } // doSave()
828
829
    /**
830
     * Insert the row in the database.
831
     *
832
     * @param      ConnectionInterface $con
833
     *
834
     * @throws PropelException
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
835
     * @see doSave()
836
     */
837 View Code Duplication
    protected function doInsert(ConnectionInterface $con)
838
    {
839
        $modifiedColumns = array();
840
        $index = 0;
841
842
        $this->modifiedColumns[PageLinkTableMap::COL_ID] = true;
843
        if (null !== $this->id) {
844
            throw new PropelException('Cannot insert a value for auto-increment primary key (' . PageLinkTableMap::COL_ID . ')');
845
        }
846
847
         // check the columns in natural order for more readable SQL queries
848
        if ($this->isColumnModified(PageLinkTableMap::COL_ID)) {
849
            $modifiedColumns[':p' . $index++]  = 'id';
850
        }
851
        if ($this->isColumnModified(PageLinkTableMap::COL_PAGE_ID)) {
852
            $modifiedColumns[':p' . $index++]  = 'page_id';
853
        }
854
        if ($this->isColumnModified(PageLinkTableMap::COL_ACTIVE_FROM)) {
855
            $modifiedColumns[':p' . $index++]  = 'active_from';
856
        }
857
        if ($this->isColumnModified(PageLinkTableMap::COL_ACTIVE_TO)) {
858
            $modifiedColumns[':p' . $index++]  = 'active_to';
859
        }
860
        if ($this->isColumnModified(PageLinkTableMap::COL_SHOW_ON)) {
861
            $modifiedColumns[':p' . $index++]  = 'show_on';
862
        }
863
        if ($this->isColumnModified(PageLinkTableMap::COL_PERMANENT)) {
864
            $modifiedColumns[':p' . $index++]  = 'permanent';
865
        }
866
867
        $sql = sprintf(
868
            'INSERT INTO page_link (%s) VALUES (%s)',
869
            implode(', ', $modifiedColumns),
870
            implode(', ', array_keys($modifiedColumns))
871
        );
872
873
        try {
874
            $stmt = $con->prepare($sql);
875
            foreach ($modifiedColumns as $identifier => $columnName) {
876
                switch ($columnName) {
877
                    case 'id':
878
                        $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
879
                        break;
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
880
                    case 'page_id':
881
                        $stmt->bindValue($identifier, $this->page_id, PDO::PARAM_INT);
882
                        break;
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
883
                    case 'active_from':
884
                        $stmt->bindValue($identifier, $this->active_from, PDO::PARAM_INT);
885
                        break;
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
886
                    case 'active_to':
887
                        $stmt->bindValue($identifier, $this->active_to, PDO::PARAM_INT);
888
                        break;
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
889
                    case 'show_on':
890
                        $stmt->bindValue($identifier, (int) $this->show_on, PDO::PARAM_INT);
891
                        break;
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
892
                    case 'permanent':
893
                        $stmt->bindValue($identifier, (int) $this->permanent, PDO::PARAM_INT);
894
                        break;
895
                }
896
            }
897
            $stmt->execute();
898
        } catch (Exception $e) {
899
            Propel::log($e->getMessage(), Propel::LOG_ERR);
900
            throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
901
        }
902
903
        try {
904
            $pk = $con->lastInsertId();
905
        } catch (Exception $e) {
906
            throw new PropelException('Unable to get autoincrement id.', 0, $e);
907
        }
908
        $this->setId($pk);
909
910
        $this->setNew(false);
911
    }
912
913
    /**
914
     * Update the row in the database.
915
     *
916
     * @param      ConnectionInterface $con
917
     *
918
     * @return Integer Number of updated rows
919
     * @see doSave()
920
     */
921
    protected function doUpdate(ConnectionInterface $con)
922
    {
923
        $selectCriteria = $this->buildPkeyCriteria();
924
        $valuesCriteria = $this->buildCriteria();
925
926
        return $selectCriteria->doUpdate($valuesCriteria, $con);
0 ignored issues
show
Documentation introduced by
$valuesCriteria is of type object<Propel\Runtime\ActiveQuery\Criteria>, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
927
    }
928
929
    /**
930
     * Retrieves a field from the object by name passed in as a string.
931
     *
932
     * @param      string $name name
933
     * @param      string $type The type of fieldname the $name is of:
934
     *                     one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME
935
     *                     TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
936
     *                     Defaults to TableMap::TYPE_PHPNAME.
937
     * @return mixed Value of field.
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use integer|null|boolean.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
938
     */
939
    public function getByName($name, $type = TableMap::TYPE_PHPNAME)
940
    {
941
        $pos = PageLinkTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
942
        $field = $this->getByPosition($pos);
943
944
        return $field;
945
    }
946
947
    /**
948
     * Retrieves a field from the object by Position as specified in the xml schema.
949
     * Zero-based.
950
     *
951
     * @param      int $pos position in xml schema
952
     * @return mixed Value of field at $pos
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use integer|null|boolean.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
953
     */
954
    public function getByPosition($pos)
955
    {
956
        switch ($pos) {
957
            case 0:
958
                return $this->getId();
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
959
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
960
            case 1:
961
                return $this->getPageId();
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
962
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
963
            case 2:
964
                return $this->getActiveFrom();
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
965
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
966
            case 3:
967
                return $this->getActiveTo();
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
968
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
969
            case 4:
970
                return $this->getShowOn();
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
971
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
972
            case 5:
973
                return $this->getPermanent();
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
974
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
975
            default:
976
                return null;
977
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
978
        } // switch()
979
    }
980
981
    /**
982
     * Exports the object as an array.
983
     *
984
     * You can specify the key type of the array by passing one of the class
985
     * type constants.
986
     *
987
     * @param     string  $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME,
0 ignored issues
show
introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
988
     *                    TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
989
     *                    Defaults to TableMap::TYPE_PHPNAME.
990
     * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
991
     * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
992
     * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
993
     *
994
     * @return array an associative array containing the field names (as keys) and field values
0 ignored issues
show
Documentation introduced by
Should the return type not be string|array?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
995
     */
996 View Code Duplication
    public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
997
    {
998
999
        if (isset($alreadyDumpedObjects['PageLink'][$this->hashCode()])) {
1000
            return '*RECURSION*';
1001
        }
1002
        $alreadyDumpedObjects['PageLink'][$this->hashCode()] = true;
1003
        $keys = PageLinkTableMap::getFieldNames($keyType);
1004
        $result = array(
1005
            $keys[0] => $this->getId(),
1006
            $keys[1] => $this->getPageId(),
1007
            $keys[2] => $this->getActiveFrom(),
1008
            $keys[3] => $this->getActiveTo(),
1009
            $keys[4] => $this->getShowOn(),
1010
            $keys[5] => $this->getPermanent(),
1011
        );
1012
        $virtualColumns = $this->virtualColumns;
1013
        foreach ($virtualColumns as $key => $virtualColumn) {
1014
            $result[$key] = $virtualColumn;
1015
        }
1016
1017
        if ($includeForeignObjects) {
1018
            if (null !== $this->collPageLinkProducts) {
1019
1020
                switch ($keyType) {
1021
                    case TableMap::TYPE_CAMELNAME:
1022
                        $key = 'pageLinkProducts';
1023
                        break;
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
1024
                    case TableMap::TYPE_FIELDNAME:
1025
                        $key = 'page_link_products';
1026
                        break;
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
1027
                    default:
1028
                        $key = 'PageLinkProducts';
1029
                }
1030
1031
                $result[$key] = $this->collPageLinkProducts->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1032
            }
1033
        }
1034
1035
        return $result;
1036
    }
1037
1038
    /**
1039
     * Sets a field from the object by name passed in as a string.
1040
     *
1041
     * @param  string $name
1042
     * @param  mixed  $value field value
0 ignored issues
show
introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
1043
     * @param  string $type The type of fieldname the $name is of:
1044
     *                one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME
1045
     *                TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
1046
     *                Defaults to TableMap::TYPE_PHPNAME.
1047
     * @return $this|\mod_link\models\PageLink
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
1048
     */
1049
    public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
1050
    {
1051
        $pos = PageLinkTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
1052
1053
        return $this->setByPosition($pos, $value);
1054
    }
1055
1056
    /**
1057
     * Sets a field from the object by Position as specified in the xml schema.
1058
     * Zero-based.
1059
     *
1060
     * @param  int $pos position in xml schema
1061
     * @param  mixed $value field value
1062
     * @return $this|\mod_link\models\PageLink
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
1063
     */
1064
    public function setByPosition($pos, $value)
1065
    {
1066
        switch ($pos) {
1067
            case 0:
1068
                $this->setId($value);
1069
                break;
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
1070
            case 1:
1071
                $this->setPageId($value);
1072
                break;
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
1073
            case 2:
1074
                $this->setActiveFrom($value);
1075
                break;
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
1076
            case 3:
1077
                $this->setActiveTo($value);
1078
                break;
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
1079
            case 4:
1080
                $this->setShowOn($value);
1081
                break;
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
1082
            case 5:
1083
                $this->setPermanent($value);
1084
                break;
1085
        } // switch()
1086
1087
        return $this;
1088
    }
1089
1090
    /**
1091
     * Populates the object using an array.
1092
     *
1093
     * This is particularly useful when populating an object from one of the
1094
     * request arrays (e.g. $_POST).  This method goes through the column
1095
     * names, checking to see whether a matching key exists in populated
1096
     * array. If so the setByName() method is called for that column.
1097
     *
1098
     * You can specify the key type of the array by additionally passing one
1099
     * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME,
1100
     * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
1101
     * The default key type is the column's TableMap::TYPE_PHPNAME.
1102
     *
1103
     * @param      array  $arr     An array to populate the object from.
0 ignored issues
show
introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
1104
     * @param      string $keyType The type of keys the array uses.
1105
     * @return void
0 ignored issues
show
introduced by
If there is no return value for a function, there must not be a @return tag.
Loading history...
1106
     */
1107 View Code Duplication
    public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME)
1108
    {
1109
        $keys = PageLinkTableMap::getFieldNames($keyType);
1110
1111
        if (array_key_exists($keys[0], $arr)) {
1112
            $this->setId($arr[$keys[0]]);
1113
        }
1114
        if (array_key_exists($keys[1], $arr)) {
1115
            $this->setPageId($arr[$keys[1]]);
1116
        }
1117
        if (array_key_exists($keys[2], $arr)) {
1118
            $this->setActiveFrom($arr[$keys[2]]);
1119
        }
1120
        if (array_key_exists($keys[3], $arr)) {
1121
            $this->setActiveTo($arr[$keys[3]]);
1122
        }
1123
        if (array_key_exists($keys[4], $arr)) {
1124
            $this->setShowOn($arr[$keys[4]]);
1125
        }
1126
        if (array_key_exists($keys[5], $arr)) {
1127
            $this->setPermanent($arr[$keys[5]]);
1128
        }
1129
    }
1130
1131
     /**
1132
     * Populate the current object from a string, using a given parser format
0 ignored issues
show
Coding Style introduced by
Expected 6 space(s) before asterisk; 5 found
Loading history...
1133
     * <code>
0 ignored issues
show
Coding Style introduced by
Expected 6 space(s) before asterisk; 5 found
Loading history...
1134
     * $book = new Book();
0 ignored issues
show
Coding Style introduced by
Expected 6 space(s) before asterisk; 5 found
Loading history...
1135
     * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
0 ignored issues
show
Coding Style introduced by
Expected 6 space(s) before asterisk; 5 found
Loading history...
1136
     * </code>
0 ignored issues
show
Coding Style introduced by
Expected 6 space(s) before asterisk; 5 found
Loading history...
1137
     *
0 ignored issues
show
Coding Style introduced by
Expected 6 space(s) before asterisk; 5 found
Loading history...
1138
     * You can specify the key type of the array by additionally passing one
0 ignored issues
show
Coding Style introduced by
Expected 6 space(s) before asterisk; 5 found
Loading history...
1139
     * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME,
0 ignored issues
show
Coding Style introduced by
Expected 6 space(s) before asterisk; 5 found
Loading history...
1140
     * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
0 ignored issues
show
Coding Style introduced by
Expected 6 space(s) before asterisk; 5 found
Loading history...
1141
     * The default key type is the column's TableMap::TYPE_PHPNAME.
0 ignored issues
show
Coding Style introduced by
Expected 6 space(s) before asterisk; 5 found
Loading history...
1142
     *
0 ignored issues
show
Coding Style introduced by
Expected 6 space(s) before asterisk; 5 found
Loading history...
1143
     * @param mixed $parser A AbstractParser instance,
0 ignored issues
show
Coding Style introduced by
Expected 6 space(s) before asterisk; 5 found
Loading history...
1144
     *                       or a format name ('XML', 'YAML', 'JSON', 'CSV')
0 ignored issues
show
Coding Style introduced by
Expected 6 space(s) before asterisk; 5 found
Loading history...
introduced by
Parameter comment must end with a full stop
Loading history...
1145
     * @param string $data The source data to import from
0 ignored issues
show
Coding Style introduced by
Expected 6 space(s) before asterisk; 5 found
Loading history...
1146
     * @param string $keyType The type of keys the array uses.
0 ignored issues
show
Coding Style introduced by
Expected 6 space(s) before asterisk; 5 found
Loading history...
1147
     *
0 ignored issues
show
Coding Style introduced by
Expected 6 space(s) before asterisk; 5 found
Loading history...
1148
     * @return $this|\mod_link\models\PageLink The current object, for fluid interface
0 ignored issues
show
Coding Style introduced by
Expected 6 space(s) before asterisk; 5 found
Loading history...
introduced by
@return data type must not contain "$"
Loading history...
1149
     */
0 ignored issues
show
Coding Style introduced by
Expected 6 space(s) before asterisk; 5 found
Loading history...
1150 View Code Duplication
    public function importFrom($parser, $data, $keyType = TableMap::TYPE_PHPNAME)
1151
    {
1152
        if (!$parser instanceof AbstractParser) {
1153
            $parser = AbstractParser::getParser($parser);
1154
        }
1155
1156
        $this->fromArray($parser->toArray($data), $keyType);
1157
1158
        return $this;
1159
    }
1160
1161
    /**
1162
     * Build a Criteria object containing the values of all modified columns in this object.
1163
     *
1164
     * @return Criteria The Criteria object containing all modified values.
1165
     */
1166
    public function buildCriteria()
1167
    {
1168
        $criteria = new Criteria(PageLinkTableMap::DATABASE_NAME);
1169
1170
        if ($this->isColumnModified(PageLinkTableMap::COL_ID)) {
1171
            $criteria->add(PageLinkTableMap::COL_ID, $this->id);
1172
        }
1173
        if ($this->isColumnModified(PageLinkTableMap::COL_PAGE_ID)) {
1174
            $criteria->add(PageLinkTableMap::COL_PAGE_ID, $this->page_id);
1175
        }
1176
        if ($this->isColumnModified(PageLinkTableMap::COL_ACTIVE_FROM)) {
1177
            $criteria->add(PageLinkTableMap::COL_ACTIVE_FROM, $this->active_from);
1178
        }
1179
        if ($this->isColumnModified(PageLinkTableMap::COL_ACTIVE_TO)) {
1180
            $criteria->add(PageLinkTableMap::COL_ACTIVE_TO, $this->active_to);
1181
        }
1182
        if ($this->isColumnModified(PageLinkTableMap::COL_SHOW_ON)) {
1183
            $criteria->add(PageLinkTableMap::COL_SHOW_ON, $this->show_on);
1184
        }
1185
        if ($this->isColumnModified(PageLinkTableMap::COL_PERMANENT)) {
1186
            $criteria->add(PageLinkTableMap::COL_PERMANENT, $this->permanent);
1187
        }
1188
1189
        return $criteria;
1190
    }
1191
1192
    /**
1193
     * Builds a Criteria object containing the primary key for this object.
1194
     *
1195
     * Unlike buildCriteria() this method includes the primary key values regardless
1196
     * of whether or not they have been modified.
1197
     *
1198
     * @throws LogicException if no primary key is defined
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
1199
     *
1200
     * @return Criteria The Criteria object containing value(s) for primary key(s).
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use ChildPageLinkQuery.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
1201
     */
1202
    public function buildPkeyCriteria()
1203
    {
1204
        $criteria = ChildPageLinkQuery::create();
1205
        $criteria->add(PageLinkTableMap::COL_ID, $this->id);
1206
1207
        return $criteria;
1208
    }
1209
1210
    /**
1211
     * If the primary key is not null, return the hashcode of the
1212
     * primary key. Otherwise, return the hash code of the object.
1213
     *
1214
     * @return int Hashcode
0 ignored issues
show
Documentation introduced by
Should the return type not be integer|string?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
1215
     */
1216 View Code Duplication
    public function hashCode()
1217
    {
1218
        $validPk = null !== $this->getId();
1219
1220
        $validPrimaryKeyFKs = 0;
1221
        $primaryKeyFKs = [];
1222
1223
        if ($validPk) {
1224
            return crc32(json_encode($this->getPrimaryKey(), JSON_UNESCAPED_UNICODE));
1225
        } elseif ($validPrimaryKeyFKs) {
1226
            return crc32(json_encode($primaryKeyFKs, JSON_UNESCAPED_UNICODE));
1227
        }
1228
1229
        return spl_object_hash($this);
1230
    }
1231
1232
    /**
1233
     * Returns the primary key for this object (row).
1234
     * @return int
1235
     */
1236
    public function getPrimaryKey()
1237
    {
1238
        return $this->getId();
1239
    }
1240
1241
    /**
1242
     * Generic method to set the primary key (id column).
1243
     *
1244
     * @param       int $key Primary key.
1245
     * @return void
0 ignored issues
show
introduced by
If there is no return value for a function, there must not be a @return tag.
Loading history...
1246
     */
1247
    public function setPrimaryKey($key)
1248
    {
1249
        $this->setId($key);
1250
    }
1251
1252
    /**
1253
     * Returns true if the primary key for this object is null.
1254
     * @return boolean
1255
     */
1256
    public function isPrimaryKeyNull()
1257
    {
1258
        return null === $this->getId();
1259
    }
1260
1261
    /**
1262
     * Sets contents of passed object to values from current object.
1263
     *
1264
     * If desired, this method can also make copies of all associated (fkey referrers)
1265
     * objects.
1266
     *
1267
     * @param      object $copyObj An object of \mod_link\models\PageLink (or compatible) type.
1268
     * @param      boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1269
     * @param      boolean $makeNew Whether to reset autoincrement PKs and make the object new.
1270
     * @throws PropelException
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
1271
     */
1272
    public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
1273
    {
1274
        $copyObj->setPageId($this->getPageId());
1275
        $copyObj->setActiveFrom($this->getActiveFrom());
1276
        $copyObj->setActiveTo($this->getActiveTo());
1277
        $copyObj->setShowOn($this->getShowOn());
1278
        $copyObj->setPermanent($this->getPermanent());
1279
1280
        if ($deepCopy) {
1281
            // important: temporarily setNew(false) because this affects the behavior of
1282
            // the getter/setter methods for fkey referrer objects.
1283
            $copyObj->setNew(false);
1284
1285
            foreach ($this->getPageLinkProducts() as $relObj) {
1286
                if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
0 ignored issues
show
introduced by
There should be no white space after an opening "{"
Loading history...
1287
                    $copyObj->addPageLinkProduct($relObj->copy($deepCopy));
1288
                }
1289
            }
1290
1291
        } // if ($deepCopy)
1292
1293
        if ($makeNew) {
1294
            $copyObj->setNew(true);
1295
            $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
1296
        }
1297
    }
1298
1299
    /**
1300
     * Makes a copy of this object that will be inserted as a new row in table when saved.
1301
     * It creates a new object filling in the simple attributes, but skipping any primary
1302
     * keys that are defined for the table.
1303
     *
1304
     * If desired, this method can also make copies of all associated (fkey referrers)
1305
     * objects.
1306
     *
1307
     * @param  boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1308
     * @return \mod_link\models\PageLink Clone of current object.
1309
     * @throws PropelException
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
1310
     */
1311
    public function copy($deepCopy = false)
1312
    {
1313
        // we use get_class(), because this might be a subclass
1314
        $clazz = get_class($this);
1315
        $copyObj = new $clazz();
1316
        $this->copyInto($copyObj, $deepCopy);
1317
1318
        return $copyObj;
1319
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line after function; 2 found
Loading history...
1320
1321
1322
    /**
1323
     * Initializes a collection based on the name of a relation.
1324
     * Avoids crafting an 'init[$relationName]s' method name
1325
     * that wouldn't work when StandardEnglishPluralizer is used.
1326
     *
1327
     * @param      string $relationName The name of the relation to initialize
1328
     * @return void
0 ignored issues
show
introduced by
If there is no return value for a function, there must not be a @return tag.
Loading history...
1329
     */
1330
    public function initRelation($relationName)
1331
    {
1332
        if ('PageLinkProduct' == $relationName) {
1333
            return $this->initPageLinkProducts();
1334
        }
1335
    }
1336
1337
    /**
1338
     * Clears out the collPageLinkProducts collection
1339
     *
1340
     * This does not modify the database; however, it will remove any associated objects, causing
1341
     * them to be refetched by subsequent calls to accessor method.
1342
     *
1343
     * @return void
0 ignored issues
show
introduced by
If there is no return value for a function, there must not be a @return tag.
Loading history...
1344
     * @see        addPageLinkProducts()
1345
     */
1346
    public function clearPageLinkProducts()
1347
    {
1348
        $this->collPageLinkProducts = null; // important to set this to NULL since that means it is uninitialized
1349
    }
1350
1351
    /**
1352
     * Reset is the collPageLinkProducts collection loaded partially.
1353
     */
1354
    public function resetPartialPageLinkProducts($v = true)
1355
    {
1356
        $this->collPageLinkProductsPartial = $v;
1357
    }
1358
1359
    /**
1360
     * Initializes the collPageLinkProducts collection.
1361
     *
1362
     * By default this just sets the collPageLinkProducts collection to an empty array (like clearcollPageLinkProducts());
1363
     * however, you may wish to override this method in your stub class to provide setting appropriate
1364
     * to your application -- for example, setting the initial array to the values stored in database.
1365
     *
1366
     * @param      boolean $overrideExisting If set to true, the method call initializes
1367
     *                                        the collection even if it is not empty
0 ignored issues
show
introduced by
Parameter comment must start with a capital letter
Loading history...
introduced by
Parameter comment must end with a full stop
Loading history...
1368
     *
1369
     * @return void
0 ignored issues
show
introduced by
If there is no return value for a function, there must not be a @return tag.
Loading history...
1370
     */
1371 View Code Duplication
    public function initPageLinkProducts($overrideExisting = true)
1372
    {
1373
        if (null !== $this->collPageLinkProducts && !$overrideExisting) {
1374
            return;
1375
        }
1376
1377
        $collectionClassName = PageLinkProductTableMap::getTableMap()->getCollectionClassName();
1378
1379
        $this->collPageLinkProducts = new $collectionClassName;
0 ignored issues
show
Coding Style introduced by
Instantiating objects should always be done with parentheses.

The object instantiation should always have parentheses even if no arguments are passed:

new DateTime; // Bad
new DateTime(); // Good
Loading history...
1380
        $this->collPageLinkProducts->setModel('\mod_link\models\PageLinkProduct');
1381
    }
1382
1383
    /**
1384
     * Gets an array of ChildPageLinkProduct objects which contain a foreign key that references this object.
1385
     *
1386
     * If the $criteria is not null, it is used to always fetch the results from the database.
1387
     * Otherwise the results are fetched from the database the first time, then cached.
1388
     * Next time the same method is called without $criteria, the cached collection is returned.
1389
     * If this ChildPageLink is new, it will return
1390
     * an empty collection or the current collection; the criteria is ignored on a new object.
1391
     *
1392
     * @param      Criteria $criteria optional Criteria object to narrow the query
1393
     * @param      ConnectionInterface $con optional connection object
1394
     * @return ObjectCollection|ChildPageLinkProduct[] List of ChildPageLinkProduct objects
1395
     * @throws PropelException
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
1396
     */
1397 View Code Duplication
    public function getPageLinkProducts(Criteria $criteria = null, ConnectionInterface $con = null)
1398
    {
1399
        $partial = $this->collPageLinkProductsPartial && !$this->isNew();
1400
        if (null === $this->collPageLinkProducts || null !== $criteria  || $partial) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space before logical operator; 2 found
Loading history...
1401
            if ($this->isNew() && null === $this->collPageLinkProducts) {
1402
                // return empty collection
1403
                $this->initPageLinkProducts();
1404
            } else {
1405
                $collPageLinkProducts = ChildPageLinkProductQuery::create(null, $criteria)
1406
                    ->filterByPageLink($this)
1407
                    ->find($con);
0 ignored issues
show
Bug introduced by
It seems like $con defined by parameter $con on line 1397 can be null; however, mod_link\models\Base\PageLinkProductQuery::find() does not accept null, maybe add an additional type check?

It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null.

We recommend to add an additional type check (or disallow null for the parameter):

function notNullable(stdClass $x) { }

// Unsafe
function withoutCheck(stdClass $x = null) {
    notNullable($x);
}

// Safe - Alternative 1: Adding Additional Type-Check
function withCheck(stdClass $x = null) {
    if ($x instanceof stdClass) {
        notNullable($x);
    }
}

// Safe - Alternative 2: Changing Parameter
function withNonNullableParam(stdClass $x) {
    notNullable($x);
}
Loading history...
1408
1409
                if (null !== $criteria) {
1410
                    if (false !== $this->collPageLinkProductsPartial && count($collPageLinkProducts)) {
1411
                        $this->initPageLinkProducts(false);
1412
1413
                        foreach ($collPageLinkProducts as $obj) {
1414
                            if (false == $this->collPageLinkProducts->contains($obj)) {
1415
                                $this->collPageLinkProducts->append($obj);
1416
                            }
1417
                        }
1418
1419
                        $this->collPageLinkProductsPartial = true;
1420
                    }
1421
1422
                    return $collPageLinkProducts;
1423
                }
1424
1425
                if ($partial && $this->collPageLinkProducts) {
1426
                    foreach ($this->collPageLinkProducts as $obj) {
1427
                        if ($obj->isNew()) {
1428
                            $collPageLinkProducts[] = $obj;
1429
                        }
1430
                    }
1431
                }
1432
1433
                $this->collPageLinkProducts = $collPageLinkProducts;
1434
                $this->collPageLinkProductsPartial = false;
1435
            }
1436
        }
1437
1438
        return $this->collPageLinkProducts;
1439
    }
1440
1441
    /**
1442
     * Sets a collection of ChildPageLinkProduct objects related by a one-to-many relationship
1443
     * to the current object.
1444
     * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
1445
     * and new objects from the given Propel collection.
1446
     *
1447
     * @param      Collection $pageLinkProducts A Propel collection.
1448
     * @param      ConnectionInterface $con Optional connection object
1449
     * @return $this|ChildPageLink The current object (for fluent API support)
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
1450
     */
1451
    public function setPageLinkProducts(Collection $pageLinkProducts, ConnectionInterface $con = null)
1452
    {
1453
        /** @var ChildPageLinkProduct[] $pageLinkProductsToDelete */
1454
        $pageLinkProductsToDelete = $this->getPageLinkProducts(new Criteria(), $con)->diff($pageLinkProducts);
1455
0 ignored issues
show
Coding Style introduced by
Functions must not contain multiple empty lines in a row; found 2 empty lines
Loading history...
1456
1457
        //since at least one column in the foreign key is at the same time a PK
1458
        //we can not just set a PK to NULL in the lines below. We have to store
1459
        //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
1460
        $this->pageLinkProductsScheduledForDeletion = clone $pageLinkProductsToDelete;
1461
1462
        foreach ($pageLinkProductsToDelete as $pageLinkProductRemoved) {
1463
            $pageLinkProductRemoved->setPageLink(null);
1464
        }
1465
1466
        $this->collPageLinkProducts = null;
1467
        foreach ($pageLinkProducts as $pageLinkProduct) {
1468
            $this->addPageLinkProduct($pageLinkProduct);
1469
        }
1470
1471
        $this->collPageLinkProducts = $pageLinkProducts;
0 ignored issues
show
Documentation Bug introduced by
It seems like $pageLinkProducts of type object<Propel\Runtime\Collection\Collection> is incompatible with the declared type object<Propel\Runtime\Co...odels\PageLinkProduct>> of property $collPageLinkProducts.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1472
        $this->collPageLinkProductsPartial = false;
1473
1474
        return $this;
1475
    }
1476
1477
    /**
1478
     * Returns the number of related PageLinkProduct objects.
1479
     *
1480
     * @param      Criteria $criteria
1481
     * @param      boolean $distinct
1482
     * @param      ConnectionInterface $con
1483
     * @return int             Count of related PageLinkProduct objects.
1484
     * @throws PropelException
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
1485
     */
1486
    public function countPageLinkProducts(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
1487
    {
1488
        $partial = $this->collPageLinkProductsPartial && !$this->isNew();
1489
        if (null === $this->collPageLinkProducts || null !== $criteria || $partial) {
1490
            if ($this->isNew() && null === $this->collPageLinkProducts) {
1491
                return 0;
1492
            }
1493
1494
            if ($partial && !$criteria) {
1495
                return count($this->getPageLinkProducts());
1496
            }
1497
1498
            $query = ChildPageLinkProductQuery::create(null, $criteria);
1499
            if ($distinct) {
1500
                $query->distinct();
1501
            }
1502
1503
            return $query
1504
                ->filterByPageLink($this)
1505
                ->count($con);
1506
        }
1507
1508
        return count($this->collPageLinkProducts);
1509
    }
1510
1511
    /**
1512
     * Method called to associate a ChildPageLinkProduct object to this object
1513
     * through the ChildPageLinkProduct foreign key attribute.
1514
     *
1515
     * @param  ChildPageLinkProduct $l ChildPageLinkProduct
1516
     * @return $this|\mod_link\models\PageLink The current object (for fluent API support)
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
1517
     */
1518
    public function addPageLinkProduct(ChildPageLinkProduct $l)
1519
    {
1520
        if ($this->collPageLinkProducts === null) {
1521
            $this->initPageLinkProducts();
1522
            $this->collPageLinkProductsPartial = true;
1523
        }
1524
1525
        if (!$this->collPageLinkProducts->contains($l)) {
1526
            $this->doAddPageLinkProduct($l);
1527
1528
            if ($this->pageLinkProductsScheduledForDeletion and $this->pageLinkProductsScheduledForDeletion->contains($l)) {
1529
                $this->pageLinkProductsScheduledForDeletion->remove($this->pageLinkProductsScheduledForDeletion->search($l));
1530
            }
1531
        }
1532
1533
        return $this;
1534
    }
1535
1536
    /**
1537
     * @param ChildPageLinkProduct $pageLinkProduct The ChildPageLinkProduct object to add.
1538
     */
1539
    protected function doAddPageLinkProduct(ChildPageLinkProduct $pageLinkProduct)
1540
    {
1541
        $this->collPageLinkProducts[]= $pageLinkProduct;
0 ignored issues
show
introduced by
Expected 1 space before "="; 0 found
Loading history...
1542
        $pageLinkProduct->setPageLink($this);
1543
    }
1544
1545
    /**
1546
     * @param  ChildPageLinkProduct $pageLinkProduct The ChildPageLinkProduct object to remove.
1547
     * @return $this|ChildPageLink The current object (for fluent API support)
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
1548
     */
1549
    public function removePageLinkProduct(ChildPageLinkProduct $pageLinkProduct)
1550
    {
1551
        if ($this->getPageLinkProducts()->contains($pageLinkProduct)) {
1552
            $pos = $this->collPageLinkProducts->search($pageLinkProduct);
1553
            $this->collPageLinkProducts->remove($pos);
1554
            if (null === $this->pageLinkProductsScheduledForDeletion) {
1555
                $this->pageLinkProductsScheduledForDeletion = clone $this->collPageLinkProducts;
1556
                $this->pageLinkProductsScheduledForDeletion->clear();
1557
            }
1558
            $this->pageLinkProductsScheduledForDeletion[]= clone $pageLinkProduct;
0 ignored issues
show
introduced by
Expected 1 space before "="; 0 found
Loading history...
1559
            $pageLinkProduct->setPageLink(null);
1560
        }
1561
1562
        return $this;
1563
    }
1564
1565
    /**
1566
     * Clears the current object, sets all attributes to their default values and removes
1567
     * outgoing references as well as back-references (from other objects to this one. Results probably in a database
1568
     * change of those foreign objects when you call `save` there).
1569
     */
1570 View Code Duplication
    public function clear()
1571
    {
1572
        $this->id = null;
1573
        $this->page_id = null;
1574
        $this->active_from = null;
1575
        $this->active_to = null;
1576
        $this->show_on = null;
1577
        $this->permanent = null;
1578
        $this->alreadyInSave = false;
1579
        $this->clearAllReferences();
1580
        $this->resetModified();
1581
        $this->setNew(true);
1582
        $this->setDeleted(false);
1583
    }
1584
1585
    /**
1586
     * Resets all references and back-references to other model objects or collections of model objects.
1587
     *
1588
     * This method is used to reset all php object references (not the actual reference in the database).
1589
     * Necessary for object serialisation.
1590
     *
1591
     * @param      boolean $deep Whether to also clear the references on all referrer objects.
1592
     */
1593
    public function clearAllReferences($deep = false)
1594
    {
1595
        if ($deep) {
1596
            if ($this->collPageLinkProducts) {
1597
                foreach ($this->collPageLinkProducts as $o) {
1598
                    $o->clearAllReferences($deep);
1599
                }
1600
            }
1601
        } // if ($deep)
1602
1603
        $this->collPageLinkProducts = null;
1604
    }
1605
1606
    /**
1607
     * Return the string representation of this object
1608
     *
1609
     * @return string
1610
     */
1611
    public function __toString()
1612
    {
1613
        return (string) $this->exportTo(PageLinkTableMap::DEFAULT_STRING_FORMAT);
1614
    }
1615
1616
    /**
1617
     * Code to be run before persisting the object
1618
     * @param  ConnectionInterface $con
1619
     * @return boolean
1620
     */
1621
    public function preSave(ConnectionInterface $con = null)
1622
    {
1623
        if (is_callable('parent::preSave')) {
1624
            return parent::preSave($con);
1625
        }
1626
        return true;
1627
    }
1628
1629
    /**
1630
     * Code to be run after persisting the object
1631
     * @param ConnectionInterface $con
1632
     */
1633
    public function postSave(ConnectionInterface $con = null)
1634
    {
1635
        if (is_callable('parent::postSave')) {
1636
            parent::postSave($con);
1637
        }
1638
    }
1639
1640
    /**
1641
     * Code to be run before inserting to database
1642
     * @param  ConnectionInterface $con
1643
     * @return boolean
1644
     */
1645
    public function preInsert(ConnectionInterface $con = null)
1646
    {
1647
        if (is_callable('parent::preInsert')) {
1648
            return parent::preInsert($con);
1649
        }
1650
        return true;
1651
    }
1652
1653
    /**
1654
     * Code to be run after inserting to database
1655
     * @param ConnectionInterface $con
1656
     */
1657
    public function postInsert(ConnectionInterface $con = null)
1658
    {
1659
        if (is_callable('parent::postInsert')) {
1660
            parent::postInsert($con);
1661
        }
1662
    }
1663
1664
    /**
1665
     * Code to be run before updating the object in database
1666
     * @param  ConnectionInterface $con
1667
     * @return boolean
1668
     */
1669
    public function preUpdate(ConnectionInterface $con = null)
1670
    {
1671
        if (is_callable('parent::preUpdate')) {
1672
            return parent::preUpdate($con);
1673
        }
1674
        return true;
1675
    }
1676
1677
    /**
1678
     * Code to be run after updating the object in database
1679
     * @param ConnectionInterface $con
1680
     */
1681
    public function postUpdate(ConnectionInterface $con = null)
1682
    {
1683
        if (is_callable('parent::postUpdate')) {
1684
            parent::postUpdate($con);
1685
        }
1686
    }
1687
1688
    /**
1689
     * Code to be run before deleting the object in database
1690
     * @param  ConnectionInterface $con
1691
     * @return boolean
1692
     */
1693
    public function preDelete(ConnectionInterface $con = null)
1694
    {
1695
        if (is_callable('parent::preDelete')) {
1696
            return parent::preDelete($con);
1697
        }
1698
        return true;
1699
    }
1700
1701
    /**
1702
     * Code to be run after deleting the object in database
1703
     * @param ConnectionInterface $con
1704
     */
1705
    public function postDelete(ConnectionInterface $con = null)
1706
    {
1707
        if (is_callable('parent::postDelete')) {
1708
            parent::postDelete($con);
1709
        }
1710
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line after function; 2 found
Loading history...
1711
1712
1713
    /**
1714
     * Derived method to catches calls to undefined methods.
1715
     *
1716
     * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
1717
     * Allows to define default __call() behavior if you overwrite __call()
1718
     *
1719
     * @param string $name
1720
     * @param mixed  $params
0 ignored issues
show
introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
1721
     *
1722
     * @return array|string
1723
     */
1724 View Code Duplication
    public function __call($name, $params)
1725
    {
1726
        if (0 === strpos($name, 'get')) {
1727
            $virtualColumn = substr($name, 3);
1728
            if ($this->hasVirtualColumn($virtualColumn)) {
1729
                return $this->getVirtualColumn($virtualColumn);
1730
            }
1731
1732
            $virtualColumn = lcfirst($virtualColumn);
1733
            if ($this->hasVirtualColumn($virtualColumn)) {
1734
                return $this->getVirtualColumn($virtualColumn);
1735
            }
1736
        }
1737
1738
        if (0 === strpos($name, 'from')) {
1739
            $format = substr($name, 4);
1740
1741
            return $this->importFrom($format, reset($params));
1742
        }
1743
1744
        if (0 === strpos($name, 'to')) {
1745
            $format = substr($name, 2);
1746
            $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
1747
1748
            return $this->exportTo($format, $includeLazyLoadColumns);
1749
        }
1750
1751
        throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
1752
    }
1753
1754
}
0 ignored issues
show
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
1755