Completed
Push — development ( 67765c...7029e6 )
by Andrij
18:12
created

Route::getSCategories()   C

Complexity

Conditions 16
Paths 12

Size

Total Lines 43
Code Lines 24

Duplication

Lines 43
Ratio 100 %

Importance

Changes 0
Metric Value
cc 16
eloc 24
nc 12
nop 2
dl 43
loc 43
rs 5.0151
c 0
b 0
f 0

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 core\models\Base;
4
5
use \Exception;
6
use \PDO;
7
use \SCategory;
8
use \SCategoryQuery;
9
use \SProducts;
10
use \SProductsQuery;
11
use Base\SCategory as BaseSCategory;
12
use Base\SProducts as BaseSProducts;
13
use CMSFactory\PropelBaseModelClass;
14
use Map\SCategoryTableMap;
15
use Map\SProductsTableMap;
16
use Propel\Runtime\Propel;
17
use Propel\Runtime\ActiveQuery\Criteria;
18
use Propel\Runtime\ActiveQuery\ModelCriteria;
19
use Propel\Runtime\ActiveRecord\ActiveRecordInterface;
20
use Propel\Runtime\Collection\Collection;
21
use Propel\Runtime\Collection\ObjectCollection;
22
use Propel\Runtime\Connection\ConnectionInterface;
23
use Propel\Runtime\Exception\BadMethodCallException;
24
use Propel\Runtime\Exception\LogicException;
25
use Propel\Runtime\Exception\PropelException;
26
use Propel\Runtime\Map\TableMap;
27
use Propel\Runtime\Parser\AbstractParser;
28
use core\models\Route as ChildRoute;
29
use core\models\RouteQuery as ChildRouteQuery;
30
use core\models\Map\RouteTableMap;
31
32
/**
33
 * Base class that represents a row from the 'route' table.
34
 *
35
 *
36
 *
37
 * @package    propel.generator.core.models.Base
38
 */
39
abstract class Route extends PropelBaseModelClass implements ActiveRecordInterface
40
{
0 ignored issues
show
introduced by
Opening brace of a class must be on the same line as the definition
Loading history...
41
    /**
42
     * TableMap class name
43
     */
44
    const TABLE_MAP = '\\core\\models\\Map\\RouteTableMap';
45
46
47
    /**
48
     * attribute to determine if this object has previously been saved.
49
     * @var boolean
50
     */
51
    protected $new = true;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before member var; 2 found
Loading history...
52
53
    /**
54
     * attribute to determine whether this object has been deleted.
55
     * @var boolean
56
     */
57
    protected $deleted = false;
58
59
    /**
60
     * The columns that have been modified in current object.
61
     * Tracking modified columns allows us to only update modified columns.
62
     * @var array
63
     */
64
    protected $modifiedColumns = array();
65
66
    /**
67
     * The (virtual) columns that are added at runtime
68
     * The formatters can add supplementary columns based on a resultset
69
     * @var array
70
     */
71
    protected $virtualColumns = array();
72
73
    /**
74
     * The value for the id field.
75
     *
76
     * @var        int
77
     */
78
    protected $id;
79
80
    /**
81
     * The value for the entity_id field.
82
     *
83
     * @var        int
84
     */
85
    protected $entity_id;
86
87
    /**
88
     * The value for the type field.
89
     *
90
     * @var        string
91
     */
92
    protected $type;
93
94
    /**
95
     * The value for the parent_url field.
96
     *
97
     * Note: this column has a database default value of: ''
98
     * @var        string
99
     */
100
    protected $parent_url;
101
102
    /**
103
     * The value for the url field.
104
     *
105
     * @var        string
106
     */
107
    protected $url;
108
109
    /**
110
     * @var        ObjectCollection|SCategory[] Collection to store aggregation of SCategory objects.
111
     */
112
    protected $collSCategories;
113
    protected $collSCategoriesPartial;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before member var; 0 found
Loading history...
114
115
    /**
116
     * @var        ObjectCollection|SProducts[] Collection to store aggregation of SProducts objects.
117
     */
118
    protected $collSProductss;
119
    protected $collSProductssPartial;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before member var; 0 found
Loading history...
120
121
    /**
122
     * Flag to prevent endless save loop, if this object is referenced
123
     * by another object which falls in this transaction.
124
     *
125
     * @var boolean
126
     */
127
    protected $alreadyInSave = false;
128
129
    /**
130
     * An array of objects scheduled for deletion.
131
     * @var ObjectCollection|SCategory[]
132
     */
133
    protected $sCategoriesScheduledForDeletion = null;
134
135
    /**
136
     * An array of objects scheduled for deletion.
137
     * @var ObjectCollection|SProducts[]
138
     */
139
    protected $sProductssScheduledForDeletion = null;
140
141
    /**
142
     * Applies default values to this object.
143
     * This method should be called from the object's constructor (or
144
     * equivalent initialization method).
145
     * @see __construct()
146
     */
147
    public function applyDefaultValues()
148
    {
149
        $this->parent_url = '';
150
    }
151
152
    /**
153
     * Initializes internal state of core\models\Base\Route object.
154
     * @see applyDefaults()
155
     */
156
    public function __construct()
157
    {
158
        $this->applyDefaultValues();
159
    }
160
161
    /**
162
     * Returns whether the object has been modified.
163
     *
164
     * @return boolean True if the object has been modified.
165
     */
166
    public function isModified()
167
    {
168
        return !!$this->modifiedColumns;
169
    }
170
171
    /**
172
     * Has specified column been modified?
173
     *
174
     * @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...
175
     * @return boolean True if $col has been modified.
176
     */
177
    public function isColumnModified($col)
178
    {
179
        return $this->modifiedColumns && isset($this->modifiedColumns[$col]);
180
    }
181
182
    /**
183
     * Get the columns that have been modified in this object.
184
     * @return array A unique list of the modified column names for this object.
185
     */
186
    public function getModifiedColumns()
187
    {
188
        return $this->modifiedColumns ? array_keys($this->modifiedColumns) : [];
189
    }
190
191
    /**
192
     * Returns whether the object has ever been saved.  This will
193
     * be false, if the object was retrieved from storage or was created
194
     * and then saved.
195
     *
196
     * @return boolean true, if the object has never been persisted.
197
     */
198
    public function isNew()
199
    {
200
        return $this->new;
201
    }
202
203
    /**
204
     * Setter for the isNew attribute.  This method will be called
205
     * by Propel-generated children and objects.
206
     *
207
     * @param boolean $b the state of the object.
208
     */
209
    public function setNew($b)
210
    {
211
        $this->new = (boolean) $b;
212
    }
213
214
    /**
215
     * Whether this object has been deleted.
216
     * @return boolean The deleted state of this object.
217
     */
218
    public function isDeleted()
219
    {
220
        return $this->deleted;
221
    }
222
223
    /**
224
     * Specify whether this object has been deleted.
225
     * @param  boolean $b The deleted state of this object.
226
     * @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...
227
     */
228
    public function setDeleted($b)
229
    {
230
        $this->deleted = (boolean) $b;
231
    }
232
233
    /**
234
     * Sets the modified state for the object to be false.
235
     * @param  string $col If supplied, only the specified column is reset.
236
     * @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...
237
     */
238 View Code Duplication
    public function resetModified($col = null)
239
    {
240
        if (null !== $col) {
241
            if (isset($this->modifiedColumns[$col])) {
242
                unset($this->modifiedColumns[$col]);
243
            }
244
        } else {
245
            $this->modifiedColumns = array();
246
        }
247
    }
248
249
    /**
250
     * Compares this with another <code>Route</code> instance.  If
251
     * <code>obj</code> is an instance of <code>Route</code>, delegates to
252
     * <code>equals(Route)</code>.  Otherwise, returns <code>false</code>.
253
     *
254
     * @param  mixed   $obj The object to compare to.
0 ignored issues
show
introduced by
Expected 1 spaces after parameter type; 3 found
Loading history...
255
     * @return boolean Whether equal to the object specified.
256
     */
257
    public function equals($obj)
258
    {
259
        if (!$obj instanceof static) {
260
            return false;
261
        }
262
263
        if ($this === $obj) {
264
            return true;
265
        }
266
267
        if (null === $this->getPrimaryKey() || null === $obj->getPrimaryKey()) {
268
            return false;
269
        }
270
271
        return $this->getPrimaryKey() === $obj->getPrimaryKey();
272
    }
273
274
    /**
275
     * Get the associative array of the virtual columns in this object
276
     *
277
     * @return array
278
     */
279
    public function getVirtualColumns()
280
    {
281
        return $this->virtualColumns;
282
    }
283
284
    /**
285
     * Checks the existence of a virtual column in this object
286
     *
287
     * @param  string  $name The virtual column name
0 ignored issues
show
introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
288
     * @return boolean
289
     */
290
    public function hasVirtualColumn($name)
291
    {
292
        return array_key_exists($name, $this->virtualColumns);
293
    }
294
295
    /**
296
     * Get the value of a virtual column in this object
297
     *
298
     * @param  string $name The virtual column name
299
     * @return mixed
300
     *
301
     * @throws PropelException
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
302
     */
303
    public function getVirtualColumn($name)
304
    {
305
        if (!$this->hasVirtualColumn($name)) {
306
            throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
307
        }
308
309
        return $this->virtualColumns[$name];
310
    }
311
312
    /**
313
     * Set the value of a virtual column in this object
314
     *
315
     * @param string $name  The virtual column name
316
     * @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...
317
     *
318
     * @return $this|Route The current object, for fluid interface
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
319
     */
320
    public function setVirtualColumn($name, $value)
321
    {
322
        $this->virtualColumns[$name] = $value;
323
324
        return $this;
325
    }
326
327
    /**
328
     * Logs a message using Propel::log().
329
     *
330
     * @param  string  $msg
0 ignored issues
show
introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
331
     * @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...
332
     * @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...
333
     */
334
    protected function log($msg, $priority = Propel::LOG_INFO)
335
    {
336
        return Propel::log(get_class($this) . ': ' . $msg, $priority);
337
    }
338
339
    /**
340
     * Export the current object properties to a string, using a given parser format
341
     * <code>
342
     * $book = BookQuery::create()->findPk(9012);
343
     * echo $book->exportTo('JSON');
344
     *  => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
345
     * </code>
346
     *
347
     * @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...
348
     * @param  boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
349
     * @return string  The exported data
350
     */
351 View Code Duplication
    public function exportTo($parser, $includeLazyLoadColumns = true)
352
    {
353
        if (!$parser instanceof AbstractParser) {
354
            $parser = AbstractParser::getParser($parser);
355
        }
356
357
        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 core\models\Base\Route::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...
358
    }
359
360
    /**
361
     * Clean up internal collections prior to serializing
362
     * Avoids recursive loops that turn into segmentation faults when serializing
363
     */
364 View Code Duplication
    public function __sleep()
365
    {
366
        $this->clearAllReferences();
367
368
        $cls = new \ReflectionClass($this);
369
        $propertyNames = [];
370
        $serializableProperties = array_diff($cls->getProperties(), $cls->getProperties(\ReflectionProperty::IS_STATIC));
371
372
        foreach($serializableProperties as $property) {
0 ignored issues
show
introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
373
            $propertyNames[] = $property->getName();
374
        }
375
376
        return $propertyNames;
377
    }
378
379
    /**
380
     * Get the [id] column value.
381
     *
382
     * @return int
383
     */
384
    public function getId()
385
    {
386
        return $this->id;
387
    }
388
389
    /**
390
     * Get the [entity_id] column value.
391
     *
392
     * @return int
393
     */
394
    public function getEntityId()
395
    {
396
        return $this->entity_id;
397
    }
398
399
    /**
400
     * Get the [type] column value.
401
     *
402
     * @return string
403
     */
404
    public function getType()
405
    {
406
        return $this->type;
407
    }
408
409
    /**
410
     * Get the [parent_url] column value.
411
     *
412
     * @return string
413
     */
414
    public function getParentUrl()
415
    {
416
        return $this->parent_url;
417
    }
418
419
    /**
420
     * Get the [url] column value.
421
     *
422
     * @return string
423
     */
424
    public function getUrl()
425
    {
426
        return $this->url;
427
    }
428
429
    /**
430
     * Set the value of [id] column.
431
     *
432
     * @param int $v new value
433
     * @return $this|\core\models\Route The current object (for fluent API support)
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
434
     */
435 View Code Duplication
    public function setId($v)
436
    {
437
        if ($v !== null) {
438
            $v = (int) $v;
439
        }
440
441
        if ($this->id !== $v) {
442
            $this->id = $v;
443
            $this->modifiedColumns[RouteTableMap::COL_ID] = true;
444
        }
445
446
        return $this;
447
    } // setId()
448
449
    /**
450
     * Set the value of [entity_id] column.
451
     *
452
     * @param int $v new value
453
     * @return $this|\core\models\Route The current object (for fluent API support)
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
454
     */
455
    public function setEntityId($v)
456
    {
457
        if ($v !== null) {
458
            $v = (int) $v;
459
        }
460
461
        if ($this->entity_id !== $v) {
462
            $this->entity_id = $v;
463
            $this->modifiedColumns[RouteTableMap::COL_ENTITY_ID] = true;
464
        }
465
466
        return $this;
467
    } // setEntityId()
468
469
    /**
470
     * Set the value of [type] column.
471
     *
472
     * @param string $v new value
473
     * @return $this|\core\models\Route The current object (for fluent API support)
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
474
     */
475
    public function setType($v)
476
    {
477
        if ($v !== null) {
478
            $v = (string) $v;
479
        }
480
481
        if ($this->type !== $v) {
482
            $this->type = $v;
483
            $this->modifiedColumns[RouteTableMap::COL_TYPE] = true;
484
        }
485
486
        return $this;
487
    } // setType()
488
489
    /**
490
     * Set the value of [parent_url] column.
491
     *
492
     * @param string $v new value
493
     * @return $this|\core\models\Route The current object (for fluent API support)
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
494
     */
495
    public function setParentUrl($v)
496
    {
497
        if ($v !== null) {
498
            $v = (string) $v;
499
        }
500
501
        if ($this->parent_url !== $v) {
502
            $this->parent_url = $v;
503
            $this->modifiedColumns[RouteTableMap::COL_PARENT_URL] = true;
504
        }
505
506
        return $this;
507
    } // setParentUrl()
508
509
    /**
510
     * Set the value of [url] column.
511
     *
512
     * @param string $v new value
513
     * @return $this|\core\models\Route The current object (for fluent API support)
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
514
     */
515
    public function setUrl($v)
516
    {
517
        if ($v !== null) {
518
            $v = (string) $v;
519
        }
520
521
        if ($this->url !== $v) {
522
            $this->url = $v;
523
            $this->modifiedColumns[RouteTableMap::COL_URL] = true;
524
        }
525
526
        return $this;
527
    } // setUrl()
528
529
    /**
530
     * Indicates whether the columns in this object are only set to default values.
531
     *
532
     * This method can be used in conjunction with isModified() to indicate whether an object is both
533
     * modified _and_ has some values set which are non-default.
534
     *
535
     * @return boolean Whether the columns in this object are only been set with default values.
536
     */
537
    public function hasOnlyDefaultValues()
538
    {
539
            if ($this->parent_url !== '') {
0 ignored issues
show
Unused Code introduced by
This if statement, and the following return statement can be replaced with return !($this->parent_url !== '');.
Loading history...
540
                return false;
541
            }
542
543
        // otherwise, everything was equal, so return TRUE
544
        return true;
545
    } // hasOnlyDefaultValues()
546
547
    /**
548
     * Hydrates (populates) the object variables with values from the database resultset.
549
     *
550
     * An offset (0-based "start column") is specified so that objects can be hydrated
551
     * with a subset of the columns in the resultset rows.  This is needed, for example,
552
     * for results of JOIN queries where the resultset row includes columns from two or
553
     * more tables.
554
     *
555
     * @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...
556
     * @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...
557
     * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
558
     * @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...
559
                                  One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME
560
     *                            TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
561
     *
562
     * @return int             next starting column
563
     * @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...
564
     */
565
    public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
566
    {
567
        try {
568
569
            $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : RouteTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
570
            $this->id = (null !== $col) ? (int) $col : null;
571
572
            $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : RouteTableMap::translateFieldName('EntityId', TableMap::TYPE_PHPNAME, $indexType)];
573
            $this->entity_id = (null !== $col) ? (int) $col : null;
574
575
            $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : RouteTableMap::translateFieldName('Type', TableMap::TYPE_PHPNAME, $indexType)];
576
            $this->type = (null !== $col) ? (string) $col : null;
577
578
            $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : RouteTableMap::translateFieldName('ParentUrl', TableMap::TYPE_PHPNAME, $indexType)];
579
            $this->parent_url = (null !== $col) ? (string) $col : null;
580
581
            $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : RouteTableMap::translateFieldName('Url', TableMap::TYPE_PHPNAME, $indexType)];
582
            $this->url = (null !== $col) ? (string) $col : null;
583
            $this->resetModified();
584
585
            $this->setNew(false);
586
587
            if ($rehydrate) {
588
                $this->ensureConsistency();
589
            }
590
591
            return $startcol + 5; // 5 = RouteTableMap::NUM_HYDRATE_COLUMNS.
592
593
        } catch (Exception $e) {
594
            throw new PropelException(sprintf('Error populating %s object', '\\core\\models\\Route'), 0, $e);
595
        }
596
    }
597
598
    /**
599
     * Checks and repairs the internal consistency of the object.
600
     *
601
     * This method is executed after an already-instantiated object is re-hydrated
602
     * from the database.  It exists to check any foreign keys to make sure that
603
     * the objects related to the current object are correct based on foreign key.
604
     *
605
     * You can override this method in the stub class, but you should always invoke
606
     * the base method from the overridden method (i.e. parent::ensureConsistency()),
607
     * in case your model changes.
608
     *
609
     * @throws PropelException
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
610
     */
611
    public function ensureConsistency()
612
    {
613
    } // ensureConsistency
614
615
    /**
616
     * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
617
     *
618
     * This will only work if the object has been saved and has a valid primary key set.
619
     *
620
     * @param      boolean $deep (optional) Whether to also de-associated any related objects.
621
     * @param      ConnectionInterface $con (optional) The ConnectionInterface connection to use.
622
     * @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...
623
     * @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...
624
     */
625
    public function reload($deep = false, ConnectionInterface $con = null)
626
    {
627
        if ($this->isDeleted()) {
628
            throw new PropelException("Cannot reload a deleted object.");
629
        }
630
631
        if ($this->isNew()) {
632
            throw new PropelException("Cannot reload an unsaved object.");
633
        }
634
635
        if ($con === null) {
636
            $con = Propel::getServiceContainer()->getReadConnection(RouteTableMap::DATABASE_NAME);
637
        }
638
639
        // We don't need to alter the object instance pool; we're just modifying this instance
640
        // already in the pool.
641
642
        $dataFetcher = ChildRouteQuery::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, core\models\Base\RouteQuery, core\models\RouteQuery, 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...
643
        $row = $dataFetcher->fetch();
644
        $dataFetcher->close();
645
        if (!$row) {
646
            throw new PropelException('Cannot find matching row in the database to reload object values.');
647
        }
648
        $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
649
650
        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...
651
652
            $this->collSCategories = null;
653
654
            $this->collSProductss = null;
655
656
        } // if (deep)
657
    }
658
659
    /**
660
     * Removes this object from datastore and sets delete attribute.
661
     *
662
     * @param      ConnectionInterface $con
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
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
665
     * @see Route::setDeleted()
666
     * @see Route::isDeleted()
667
     */
668 View Code Duplication
    public function delete(ConnectionInterface $con = null)
669
    {
670
        if ($this->isDeleted()) {
671
            throw new PropelException("This object has already been deleted.");
672
        }
673
674
        if ($con === null) {
675
            $con = Propel::getServiceContainer()->getWriteConnection(RouteTableMap::DATABASE_NAME);
676
        }
677
678
        $con->transaction(function () use ($con) {
679
            $deleteQuery = ChildRouteQuery::create()
680
                ->filterByPrimaryKey($this->getPrimaryKey());
681
            $ret = $this->preDelete($con);
682
            if ($ret) {
683
                $deleteQuery->delete($con);
684
                $this->postDelete($con);
685
                $this->setDeleted(true);
686
            }
687
        });
688
    }
689
690
    /**
691
     * Persists this object to the database.
692
     *
693
     * If the object is new, it inserts it; otherwise an update is performed.
694
     * All modified related objects will also be persisted in the doSave()
695
     * method.  This method wraps all precipitate database operations in a
696
     * single transaction.
697
     *
698
     * @param      ConnectionInterface $con
699
     * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
700
     * @throws PropelException
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
701
     * @see doSave()
702
     */
703 View Code Duplication
    public function save(ConnectionInterface $con = null)
704
    {
705
        if ($this->isDeleted()) {
706
            throw new PropelException("You cannot save an object that has been deleted.");
707
        }
708
709
        if ($con === null) {
710
            $con = Propel::getServiceContainer()->getWriteConnection(RouteTableMap::DATABASE_NAME);
711
        }
712
713
        return $con->transaction(function () use ($con) {
714
            $ret = $this->preSave($con);
715
            $isInsert = $this->isNew();
716
            if ($isInsert) {
717
                $ret = $ret && $this->preInsert($con);
718
            } else {
719
                $ret = $ret && $this->preUpdate($con);
720
            }
721
            if ($ret) {
722
                $affectedRows = $this->doSave($con);
723
                if ($isInsert) {
724
                    $this->postInsert($con);
725
                } else {
726
                    $this->postUpdate($con);
727
                }
728
                $this->postSave($con);
729
                RouteTableMap::addInstanceToPool($this);
730
            } else {
731
                $affectedRows = 0;
732
            }
733
734
            return $affectedRows;
735
        });
736
    }
737
738
    /**
739
     * Performs the work of inserting or updating the row in the database.
740
     *
741
     * If the object is new, it inserts it; otherwise an update is performed.
742
     * All related objects are also updated in this method.
743
     *
744
     * @param      ConnectionInterface $con
745
     * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
746
     * @throws PropelException
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
747
     * @see save()
748
     */
749 View Code Duplication
    protected function doSave(ConnectionInterface $con)
750
    {
751
        $affectedRows = 0; // initialize var to track total num of affected rows
752
        if (!$this->alreadyInSave) {
753
            $this->alreadyInSave = true;
754
755
            if ($this->isNew() || $this->isModified()) {
756
                // persist changes
757
                if ($this->isNew()) {
758
                    $this->doInsert($con);
759
                    $affectedRows += 1;
760
                } else {
761
                    $affectedRows += $this->doUpdate($con);
762
                }
763
                $this->resetModified();
764
            }
765
766
            if ($this->sCategoriesScheduledForDeletion !== null) {
767
                if (!$this->sCategoriesScheduledForDeletion->isEmpty()) {
768
                    \SCategoryQuery::create()
769
                        ->filterByPrimaryKeys($this->sCategoriesScheduledForDeletion->getPrimaryKeys(false))
770
                        ->delete($con);
771
                    $this->sCategoriesScheduledForDeletion = null;
772
                }
773
            }
774
775
            if ($this->collSCategories !== null) {
776
                foreach ($this->collSCategories as $referrerFK) {
777
                    if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
778
                        $affectedRows += $referrerFK->save($con);
779
                    }
780
                }
781
            }
782
783
            if ($this->sProductssScheduledForDeletion !== null) {
784
                if (!$this->sProductssScheduledForDeletion->isEmpty()) {
785
                    \SProductsQuery::create()
786
                        ->filterByPrimaryKeys($this->sProductssScheduledForDeletion->getPrimaryKeys(false))
787
                        ->delete($con);
788
                    $this->sProductssScheduledForDeletion = null;
789
                }
790
            }
791
792
            if ($this->collSProductss !== null) {
793
                foreach ($this->collSProductss as $referrerFK) {
794
                    if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
795
                        $affectedRows += $referrerFK->save($con);
796
                    }
797
                }
798
            }
799
800
            $this->alreadyInSave = false;
801
802
        }
803
804
        return $affectedRows;
805
    } // doSave()
806
807
    /**
808
     * Insert the row in the database.
809
     *
810
     * @param      ConnectionInterface $con
811
     *
812
     * @throws PropelException
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
813
     * @see doSave()
814
     */
815
    protected function doInsert(ConnectionInterface $con)
816
    {
817
        $modifiedColumns = array();
818
        $index = 0;
819
820
        $this->modifiedColumns[RouteTableMap::COL_ID] = true;
821
        if (null !== $this->id) {
822
            throw new PropelException('Cannot insert a value for auto-increment primary key (' . RouteTableMap::COL_ID . ')');
823
        }
824
825
         // check the columns in natural order for more readable SQL queries
826
        if ($this->isColumnModified(RouteTableMap::COL_ID)) {
827
            $modifiedColumns[':p' . $index++]  = 'id';
828
        }
829
        if ($this->isColumnModified(RouteTableMap::COL_ENTITY_ID)) {
830
            $modifiedColumns[':p' . $index++]  = 'entity_id';
831
        }
832
        if ($this->isColumnModified(RouteTableMap::COL_TYPE)) {
833
            $modifiedColumns[':p' . $index++]  = 'type';
834
        }
835
        if ($this->isColumnModified(RouteTableMap::COL_PARENT_URL)) {
836
            $modifiedColumns[':p' . $index++]  = 'parent_url';
837
        }
838
        if ($this->isColumnModified(RouteTableMap::COL_URL)) {
839
            $modifiedColumns[':p' . $index++]  = 'url';
840
        }
841
842
        $sql = sprintf(
843
            'INSERT INTO route (%s) VALUES (%s)',
844
            implode(', ', $modifiedColumns),
845
            implode(', ', array_keys($modifiedColumns))
846
        );
847
848
        try {
849
            $stmt = $con->prepare($sql);
850
            foreach ($modifiedColumns as $identifier => $columnName) {
851
                switch ($columnName) {
852
                    case 'id':
853
                        $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
854
                        break;
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
855
                    case 'entity_id':
856
                        $stmt->bindValue($identifier, $this->entity_id, PDO::PARAM_INT);
857
                        break;
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
858
                    case 'type':
859
                        $stmt->bindValue($identifier, $this->type, PDO::PARAM_STR);
860
                        break;
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
861
                    case 'parent_url':
862
                        $stmt->bindValue($identifier, $this->parent_url, PDO::PARAM_STR);
863
                        break;
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
864
                    case 'url':
865
                        $stmt->bindValue($identifier, $this->url, PDO::PARAM_STR);
866
                        break;
867
                }
868
            }
869
            $stmt->execute();
870
        } catch (Exception $e) {
871
            Propel::log($e->getMessage(), Propel::LOG_ERR);
872
            throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
873
        }
874
875
        try {
876
            $pk = $con->lastInsertId();
877
        } catch (Exception $e) {
878
            throw new PropelException('Unable to get autoincrement id.', 0, $e);
879
        }
880
        $this->setId($pk);
881
882
        $this->setNew(false);
883
    }
884
885
    /**
886
     * Update the row in the database.
887
     *
888
     * @param      ConnectionInterface $con
889
     *
890
     * @return Integer Number of updated rows
891
     * @see doSave()
892
     */
893
    protected function doUpdate(ConnectionInterface $con)
894
    {
895
        $selectCriteria = $this->buildPkeyCriteria();
896
        $valuesCriteria = $this->buildCriteria();
897
898
        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...
899
    }
900
901
    /**
902
     * Retrieves a field from the object by name passed in as a string.
903
     *
904
     * @param      string $name name
905
     * @param      string $type The type of fieldname the $name is of:
906
     *                     one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME
907
     *                     TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
908
     *                     Defaults to TableMap::TYPE_PHPNAME.
909
     * @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|string.

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...
910
     */
911
    public function getByName($name, $type = TableMap::TYPE_PHPNAME)
912
    {
913
        $pos = RouteTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
914
        $field = $this->getByPosition($pos);
915
916
        return $field;
917
    }
918
919
    /**
920
     * Retrieves a field from the object by Position as specified in the xml schema.
921
     * Zero-based.
922
     *
923
     * @param      int $pos position in xml schema
924
     * @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|string.

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...
925
     */
926
    public function getByPosition($pos)
927
    {
928
        switch ($pos) {
929
            case 0:
930
                return $this->getId();
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
931
                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...
932
            case 1:
933
                return $this->getEntityId();
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
934
                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...
935
            case 2:
936
                return $this->getType();
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
937
                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...
938
            case 3:
939
                return $this->getParentUrl();
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
940
                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...
941
            case 4:
942
                return $this->getUrl();
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
943
                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...
944
            default:
945
                return null;
946
                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...
947
        } // switch()
948
    }
949
950
    /**
951
     * Exports the object as an array.
952
     *
953
     * You can specify the key type of the array by passing one of the class
954
     * type constants.
955
     *
956
     * @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...
957
     *                    TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
958
     *                    Defaults to TableMap::TYPE_PHPNAME.
959
     * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
960
     * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
961
     * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
962
     *
963
     * @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...
964
     */
965 View Code Duplication
    public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
966
    {
967
968
        if (isset($alreadyDumpedObjects['Route'][$this->hashCode()])) {
969
            return '*RECURSION*';
970
        }
971
        $alreadyDumpedObjects['Route'][$this->hashCode()] = true;
972
        $keys = RouteTableMap::getFieldNames($keyType);
973
        $result = array(
974
            $keys[0] => $this->getId(),
975
            $keys[1] => $this->getEntityId(),
976
            $keys[2] => $this->getType(),
977
            $keys[3] => $this->getParentUrl(),
978
            $keys[4] => $this->getUrl(),
979
        );
980
        $virtualColumns = $this->virtualColumns;
981
        foreach ($virtualColumns as $key => $virtualColumn) {
982
            $result[$key] = $virtualColumn;
983
        }
984
985
        if ($includeForeignObjects) {
986
            if (null !== $this->collSCategories) {
987
988
                switch ($keyType) {
989
                    case TableMap::TYPE_CAMELNAME:
990
                        $key = 'sCategories';
991
                        break;
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
992
                    case TableMap::TYPE_FIELDNAME:
993
                        $key = 'shop_categories';
994
                        break;
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
995
                    default:
996
                        $key = 'SCategories';
997
                }
998
999
                $result[$key] = $this->collSCategories->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1000
            }
1001
            if (null !== $this->collSProductss) {
1002
1003
                switch ($keyType) {
1004
                    case TableMap::TYPE_CAMELNAME:
1005
                        $key = 'sProductss';
1006
                        break;
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
1007
                    case TableMap::TYPE_FIELDNAME:
1008
                        $key = 'shop_productss';
1009
                        break;
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
1010
                    default:
1011
                        $key = 'SProductss';
1012
                }
1013
1014
                $result[$key] = $this->collSProductss->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1015
            }
1016
        }
1017
1018
        return $result;
1019
    }
1020
1021
    /**
1022
     * Sets a field from the object by name passed in as a string.
1023
     *
1024
     * @param  string $name
1025
     * @param  mixed  $value field value
0 ignored issues
show
introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
1026
     * @param  string $type The type of fieldname the $name is of:
1027
     *                one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME
1028
     *                TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
1029
     *                Defaults to TableMap::TYPE_PHPNAME.
1030
     * @return $this|\core\models\Route
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
1031
     */
1032
    public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
1033
    {
1034
        $pos = RouteTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
1035
1036
        return $this->setByPosition($pos, $value);
1037
    }
1038
1039
    /**
1040
     * Sets a field from the object by Position as specified in the xml schema.
1041
     * Zero-based.
1042
     *
1043
     * @param  int $pos position in xml schema
1044
     * @param  mixed $value field value
1045
     * @return $this|\core\models\Route
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
1046
     */
1047
    public function setByPosition($pos, $value)
1048
    {
1049
        switch ($pos) {
1050
            case 0:
1051
                $this->setId($value);
1052
                break;
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
1053
            case 1:
1054
                $this->setEntityId($value);
1055
                break;
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
1056
            case 2:
1057
                $this->setType($value);
1058
                break;
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
1059
            case 3:
1060
                $this->setParentUrl($value);
1061
                break;
0 ignored issues
show
Coding Style introduced by
Case breaking statements must be followed by a single blank line
Loading history...
1062
            case 4:
1063
                $this->setUrl($value);
1064
                break;
1065
        } // switch()
1066
1067
        return $this;
1068
    }
1069
1070
    /**
1071
     * Populates the object using an array.
1072
     *
1073
     * This is particularly useful when populating an object from one of the
1074
     * request arrays (e.g. $_POST).  This method goes through the column
1075
     * names, checking to see whether a matching key exists in populated
1076
     * array. If so the setByName() method is called for that column.
1077
     *
1078
     * You can specify the key type of the array by additionally passing one
1079
     * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME,
1080
     * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
1081
     * The default key type is the column's TableMap::TYPE_PHPNAME.
1082
     *
1083
     * @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...
1084
     * @param      string $keyType The type of keys the array uses.
1085
     * @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...
1086
     */
1087
    public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME)
1088
    {
1089
        $keys = RouteTableMap::getFieldNames($keyType);
1090
1091
        if (array_key_exists($keys[0], $arr)) {
1092
            $this->setId($arr[$keys[0]]);
1093
        }
1094
        if (array_key_exists($keys[1], $arr)) {
1095
            $this->setEntityId($arr[$keys[1]]);
1096
        }
1097
        if (array_key_exists($keys[2], $arr)) {
1098
            $this->setType($arr[$keys[2]]);
1099
        }
1100
        if (array_key_exists($keys[3], $arr)) {
1101
            $this->setParentUrl($arr[$keys[3]]);
1102
        }
1103
        if (array_key_exists($keys[4], $arr)) {
1104
            $this->setUrl($arr[$keys[4]]);
1105
        }
1106
    }
1107
1108
     /**
1109
     * 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...
1110
     * <code>
0 ignored issues
show
Coding Style introduced by
Expected 6 space(s) before asterisk; 5 found
Loading history...
1111
     * $book = new Book();
0 ignored issues
show
Coding Style introduced by
Expected 6 space(s) before asterisk; 5 found
Loading history...
1112
     * $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...
1113
     * </code>
0 ignored issues
show
Coding Style introduced by
Expected 6 space(s) before asterisk; 5 found
Loading history...
1114
     *
0 ignored issues
show
Coding Style introduced by
Expected 6 space(s) before asterisk; 5 found
Loading history...
1115
     * 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...
1116
     * 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...
1117
     * 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...
1118
     * 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...
1119
     *
0 ignored issues
show
Coding Style introduced by
Expected 6 space(s) before asterisk; 5 found
Loading history...
1120
     * @param mixed $parser A AbstractParser instance,
0 ignored issues
show
Coding Style introduced by
Expected 6 space(s) before asterisk; 5 found
Loading history...
1121
     *                       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...
1122
     * @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...
1123
     * @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...
1124
     *
0 ignored issues
show
Coding Style introduced by
Expected 6 space(s) before asterisk; 5 found
Loading history...
1125
     * @return $this|\core\models\Route 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...
1126
     */
0 ignored issues
show
Coding Style introduced by
Expected 6 space(s) before asterisk; 5 found
Loading history...
1127 View Code Duplication
    public function importFrom($parser, $data, $keyType = TableMap::TYPE_PHPNAME)
1128
    {
1129
        if (!$parser instanceof AbstractParser) {
1130
            $parser = AbstractParser::getParser($parser);
1131
        }
1132
1133
        $this->fromArray($parser->toArray($data), $keyType);
1134
1135
        return $this;
1136
    }
1137
1138
    /**
1139
     * Build a Criteria object containing the values of all modified columns in this object.
1140
     *
1141
     * @return Criteria The Criteria object containing all modified values.
1142
     */
1143
    public function buildCriteria()
1144
    {
1145
        $criteria = new Criteria(RouteTableMap::DATABASE_NAME);
1146
1147
        if ($this->isColumnModified(RouteTableMap::COL_ID)) {
1148
            $criteria->add(RouteTableMap::COL_ID, $this->id);
1149
        }
1150
        if ($this->isColumnModified(RouteTableMap::COL_ENTITY_ID)) {
1151
            $criteria->add(RouteTableMap::COL_ENTITY_ID, $this->entity_id);
1152
        }
1153
        if ($this->isColumnModified(RouteTableMap::COL_TYPE)) {
1154
            $criteria->add(RouteTableMap::COL_TYPE, $this->type);
1155
        }
1156
        if ($this->isColumnModified(RouteTableMap::COL_PARENT_URL)) {
1157
            $criteria->add(RouteTableMap::COL_PARENT_URL, $this->parent_url);
1158
        }
1159
        if ($this->isColumnModified(RouteTableMap::COL_URL)) {
1160
            $criteria->add(RouteTableMap::COL_URL, $this->url);
1161
        }
1162
1163
        return $criteria;
1164
    }
1165
1166
    /**
1167
     * Builds a Criteria object containing the primary key for this object.
1168
     *
1169
     * Unlike buildCriteria() this method includes the primary key values regardless
1170
     * of whether or not they have been modified.
1171
     *
1172
     * @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...
1173
     *
1174
     * @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 ChildRouteQuery.

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...
1175
     */
1176
    public function buildPkeyCriteria()
1177
    {
1178
        $criteria = ChildRouteQuery::create();
1179
        $criteria->add(RouteTableMap::COL_ID, $this->id);
1180
1181
        return $criteria;
1182
    }
1183
1184
    /**
1185
     * If the primary key is not null, return the hashcode of the
1186
     * primary key. Otherwise, return the hash code of the object.
1187
     *
1188
     * @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...
1189
     */
1190 View Code Duplication
    public function hashCode()
1191
    {
1192
        $validPk = null !== $this->getId();
1193
1194
        $validPrimaryKeyFKs = 0;
1195
        $primaryKeyFKs = [];
1196
1197
        if ($validPk) {
1198
            return crc32(json_encode($this->getPrimaryKey(), JSON_UNESCAPED_UNICODE));
1199
        } elseif ($validPrimaryKeyFKs) {
1200
            return crc32(json_encode($primaryKeyFKs, JSON_UNESCAPED_UNICODE));
1201
        }
1202
1203
        return spl_object_hash($this);
1204
    }
1205
1206
    /**
1207
     * Returns the primary key for this object (row).
1208
     * @return int
1209
     */
1210
    public function getPrimaryKey()
1211
    {
1212
        return $this->getId();
1213
    }
1214
1215
    /**
1216
     * Generic method to set the primary key (id column).
1217
     *
1218
     * @param       int $key Primary key.
1219
     * @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...
1220
     */
1221
    public function setPrimaryKey($key)
1222
    {
1223
        $this->setId($key);
1224
    }
1225
1226
    /**
1227
     * Returns true if the primary key for this object is null.
1228
     * @return boolean
1229
     */
1230
    public function isPrimaryKeyNull()
1231
    {
1232
        return null === $this->getId();
1233
    }
1234
1235
    /**
1236
     * Sets contents of passed object to values from current object.
1237
     *
1238
     * If desired, this method can also make copies of all associated (fkey referrers)
1239
     * objects.
1240
     *
1241
     * @param      object $copyObj An object of \core\models\Route (or compatible) type.
1242
     * @param      boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1243
     * @param      boolean $makeNew Whether to reset autoincrement PKs and make the object new.
1244
     * @throws PropelException
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
1245
     */
1246
    public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
1247
    {
1248
        $copyObj->setEntityId($this->getEntityId());
1249
        $copyObj->setType($this->getType());
1250
        $copyObj->setParentUrl($this->getParentUrl());
1251
        $copyObj->setUrl($this->getUrl());
1252
1253
        if ($deepCopy) {
1254
            // important: temporarily setNew(false) because this affects the behavior of
1255
            // the getter/setter methods for fkey referrer objects.
1256
            $copyObj->setNew(false);
1257
1258
            foreach ($this->getSCategories() as $relObj) {
1259
                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...
1260
                    $copyObj->addSCategory($relObj->copy($deepCopy));
1261
                }
1262
            }
1263
1264
            foreach ($this->getSProductss() as $relObj) {
1265
                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...
1266
                    $copyObj->addSProducts($relObj->copy($deepCopy));
1267
                }
1268
            }
1269
1270
        } // if ($deepCopy)
1271
1272
        if ($makeNew) {
1273
            $copyObj->setNew(true);
1274
            $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
1275
        }
1276
    }
1277
1278
    /**
1279
     * Makes a copy of this object that will be inserted as a new row in table when saved.
1280
     * It creates a new object filling in the simple attributes, but skipping any primary
1281
     * keys that are defined for the table.
1282
     *
1283
     * If desired, this method can also make copies of all associated (fkey referrers)
1284
     * objects.
1285
     *
1286
     * @param  boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1287
     * @return \core\models\Route Clone of current object.
1288
     * @throws PropelException
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
1289
     */
1290
    public function copy($deepCopy = false)
1291
    {
1292
        // we use get_class(), because this might be a subclass
1293
        $clazz = get_class($this);
1294
        $copyObj = new $clazz();
1295
        $this->copyInto($copyObj, $deepCopy);
1296
1297
        return $copyObj;
1298
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line after function; 2 found
Loading history...
1299
1300
1301
    /**
1302
     * Initializes a collection based on the name of a relation.
1303
     * Avoids crafting an 'init[$relationName]s' method name
1304
     * that wouldn't work when StandardEnglishPluralizer is used.
1305
     *
1306
     * @param      string $relationName The name of the relation to initialize
1307
     * @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...
1308
     */
1309
    public function initRelation($relationName)
1310
    {
1311
        if ('SCategory' == $relationName) {
1312
            return $this->initSCategories();
1313
        }
1314
        if ('SProducts' == $relationName) {
1315
            return $this->initSProductss();
1316
        }
1317
    }
1318
1319
    /**
1320
     * Clears out the collSCategories collection
1321
     *
1322
     * This does not modify the database; however, it will remove any associated objects, causing
1323
     * them to be refetched by subsequent calls to accessor method.
1324
     *
1325
     * @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...
1326
     * @see        addSCategories()
1327
     */
1328
    public function clearSCategories()
1329
    {
1330
        $this->collSCategories = null; // important to set this to NULL since that means it is uninitialized
1331
    }
1332
1333
    /**
1334
     * Reset is the collSCategories collection loaded partially.
1335
     */
1336
    public function resetPartialSCategories($v = true)
1337
    {
1338
        $this->collSCategoriesPartial = $v;
1339
    }
1340
1341
    /**
1342
     * Initializes the collSCategories collection.
1343
     *
1344
     * By default this just sets the collSCategories collection to an empty array (like clearcollSCategories());
1345
     * however, you may wish to override this method in your stub class to provide setting appropriate
1346
     * to your application -- for example, setting the initial array to the values stored in database.
1347
     *
1348
     * @param      boolean $overrideExisting If set to true, the method call initializes
1349
     *                                        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...
1350
     *
1351
     * @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...
1352
     */
1353 View Code Duplication
    public function initSCategories($overrideExisting = true)
1354
    {
1355
        if (null !== $this->collSCategories && !$overrideExisting) {
1356
            return;
1357
        }
1358
1359
        $collectionClassName = SCategoryTableMap::getTableMap()->getCollectionClassName();
1360
1361
        $this->collSCategories = 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...
1362
        $this->collSCategories->setModel('\SCategory');
1363
    }
1364
1365
    /**
1366
     * Gets an array of SCategory objects which contain a foreign key that references this object.
1367
     *
1368
     * If the $criteria is not null, it is used to always fetch the results from the database.
1369
     * Otherwise the results are fetched from the database the first time, then cached.
1370
     * Next time the same method is called without $criteria, the cached collection is returned.
1371
     * If this ChildRoute is new, it will return
1372
     * an empty collection or the current collection; the criteria is ignored on a new object.
1373
     *
1374
     * @param      Criteria $criteria optional Criteria object to narrow the query
1375
     * @param      ConnectionInterface $con optional connection object
1376
     * @return ObjectCollection|SCategory[] List of SCategory objects
1377
     * @throws PropelException
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
1378
     */
1379 View Code Duplication
    public function getSCategories(Criteria $criteria = null, ConnectionInterface $con = null)
1380
    {
1381
        $partial = $this->collSCategoriesPartial && !$this->isNew();
1382
        if (null === $this->collSCategories || null !== $criteria  || $partial) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space before logical operator; 2 found
Loading history...
1383
            if ($this->isNew() && null === $this->collSCategories) {
1384
                // return empty collection
1385
                $this->initSCategories();
1386
            } else {
1387
                $collSCategories = SCategoryQuery::create(null, $criteria)
1388
                    ->filterByRoute($this)
1389
                    ->find($con);
1390
1391
                if (null !== $criteria) {
1392
                    if (false !== $this->collSCategoriesPartial && count($collSCategories)) {
1393
                        $this->initSCategories(false);
1394
1395
                        foreach ($collSCategories as $obj) {
1396
                            if (false == $this->collSCategories->contains($obj)) {
1397
                                $this->collSCategories->append($obj);
1398
                            }
1399
                        }
1400
1401
                        $this->collSCategoriesPartial = true;
1402
                    }
1403
1404
                    return $collSCategories;
1405
                }
1406
1407
                if ($partial && $this->collSCategories) {
1408
                    foreach ($this->collSCategories as $obj) {
1409
                        if ($obj->isNew()) {
1410
                            $collSCategories[] = $obj;
1411
                        }
1412
                    }
1413
                }
1414
1415
                $this->collSCategories = $collSCategories;
1416
                $this->collSCategoriesPartial = false;
1417
            }
1418
        }
1419
1420
        return $this->collSCategories;
1421
    }
1422
1423
    /**
1424
     * Sets a collection of SCategory objects related by a one-to-many relationship
1425
     * to the current object.
1426
     * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
1427
     * and new objects from the given Propel collection.
1428
     *
1429
     * @param      Collection $sCategories A Propel collection.
1430
     * @param      ConnectionInterface $con Optional connection object
1431
     * @return $this|ChildRoute The current object (for fluent API support)
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
1432
     */
1433 View Code Duplication
    public function setSCategories(Collection $sCategories, ConnectionInterface $con = null)
1434
    {
1435
        /** @var SCategory[] $sCategoriesToDelete */
1436
        $sCategoriesToDelete = $this->getSCategories(new Criteria(), $con)->diff($sCategories);
1437
0 ignored issues
show
Coding Style introduced by
Functions must not contain multiple empty lines in a row; found 2 empty lines
Loading history...
1438
1439
        $this->sCategoriesScheduledForDeletion = $sCategoriesToDelete;
1440
1441
        foreach ($sCategoriesToDelete as $sCategoryRemoved) {
1442
            $sCategoryRemoved->setRoute(null);
1443
        }
1444
1445
        $this->collSCategories = null;
1446
        foreach ($sCategories as $sCategory) {
1447
            $this->addSCategory($sCategory);
1448
        }
1449
1450
        $this->collSCategories = $sCategories;
0 ignored issues
show
Documentation Bug introduced by
It seems like $sCategories of type object<Propel\Runtime\Collection\Collection> is incompatible with the declared type object<Propel\Runtime\Co...eger,object<SCategory>> of property $collSCategories.

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...
1451
        $this->collSCategoriesPartial = false;
1452
1453
        return $this;
1454
    }
1455
1456
    /**
1457
     * Returns the number of related BaseSCategory objects.
1458
     *
1459
     * @param      Criteria $criteria
1460
     * @param      boolean $distinct
1461
     * @param      ConnectionInterface $con
1462
     * @return int             Count of related BaseSCategory objects.
1463
     * @throws PropelException
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
1464
     */
1465
    public function countSCategories(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
1466
    {
1467
        $partial = $this->collSCategoriesPartial && !$this->isNew();
1468 View Code Duplication
        if (null === $this->collSCategories || null !== $criteria || $partial) {
1469
            if ($this->isNew() && null === $this->collSCategories) {
1470
                return 0;
1471
            }
1472
1473
            if ($partial && !$criteria) {
1474
                return count($this->getSCategories());
1475
            }
1476
1477
            $query = SCategoryQuery::create(null, $criteria);
1478
            if ($distinct) {
1479
                $query->distinct();
1480
            }
1481
1482
            return $query
1483
                ->filterByRoute($this)
1484
                ->count($con);
1485
        }
1486
1487
        return count($this->collSCategories);
1488
    }
1489
1490
    /**
1491
     * Method called to associate a SCategory object to this object
1492
     * through the SCategory foreign key attribute.
1493
     *
1494
     * @param  SCategory $l SCategory
1495
     * @return $this|\core\models\Route The current object (for fluent API support)
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
1496
     */
1497
    public function addSCategory(SCategory $l)
1498
    {
1499
        if ($this->collSCategories === null) {
1500
            $this->initSCategories();
1501
            $this->collSCategoriesPartial = true;
1502
        }
1503
1504
        if (!$this->collSCategories->contains($l)) {
1505
            $this->doAddSCategory($l);
1506
1507
            if ($this->sCategoriesScheduledForDeletion and $this->sCategoriesScheduledForDeletion->contains($l)) {
1508
                $this->sCategoriesScheduledForDeletion->remove($this->sCategoriesScheduledForDeletion->search($l));
1509
            }
1510
        }
1511
1512
        return $this;
1513
    }
1514
1515
    /**
1516
     * @param SCategory $sCategory The SCategory object to add.
1517
     */
1518
    protected function doAddSCategory(SCategory $sCategory)
1519
    {
1520
        $this->collSCategories[]= $sCategory;
0 ignored issues
show
introduced by
Expected 1 space before "="; 0 found
Loading history...
1521
        $sCategory->setRoute($this);
1522
    }
1523
1524
    /**
1525
     * @param  SCategory $sCategory The SCategory object to remove.
1526
     * @return $this|ChildRoute The current object (for fluent API support)
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
1527
     */
1528 View Code Duplication
    public function removeSCategory(SCategory $sCategory)
1529
    {
1530
        if ($this->getSCategories()->contains($sCategory)) {
1531
            $pos = $this->collSCategories->search($sCategory);
1532
            $this->collSCategories->remove($pos);
1533
            if (null === $this->sCategoriesScheduledForDeletion) {
1534
                $this->sCategoriesScheduledForDeletion = clone $this->collSCategories;
1535
                $this->sCategoriesScheduledForDeletion->clear();
1536
            }
1537
            $this->sCategoriesScheduledForDeletion[]= $sCategory;
0 ignored issues
show
introduced by
Expected 1 space before "="; 0 found
Loading history...
1538
            $sCategory->setRoute(null);
1539
        }
1540
1541
        return $this;
1542
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line after function; 2 found
Loading history...
1543
1544
1545
    /**
1546
     * If this collection has already been initialized with
1547
     * an identical criteria, it returns the collection.
1548
     * Otherwise if this Route is new, it will return
1549
     * an empty collection; or if this Route has previously
1550
     * been saved, it will retrieve related SCategories from storage.
1551
     *
1552
     * This method is protected by default in order to keep the public
1553
     * api reasonable.  You can provide public methods for those you
1554
     * actually need in Route.
1555
     *
1556
     * @param      Criteria $criteria optional Criteria object to narrow the query
1557
     * @param      ConnectionInterface $con optional connection object
1558
     * @param      string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
1559
     * @return ObjectCollection|SCategory[] List of SCategory objects
1560
     */
1561 View Code Duplication
    public function getSCategoriesJoinSCategory(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN)
1562
    {
1563
        $query = SCategoryQuery::create(null, $criteria);
1564
        $query->joinWith('SCategory', $joinBehavior);
1565
1566
        return $this->getSCategories($query, $con);
1567
    }
1568
1569
    /**
1570
     * Clears out the collSProductss collection
1571
     *
1572
     * This does not modify the database; however, it will remove any associated objects, causing
1573
     * them to be refetched by subsequent calls to accessor method.
1574
     *
1575
     * @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...
1576
     * @see        addSProductss()
1577
     */
1578
    public function clearSProductss()
1579
    {
1580
        $this->collSProductss = null; // important to set this to NULL since that means it is uninitialized
1581
    }
1582
1583
    /**
1584
     * Reset is the collSProductss collection loaded partially.
1585
     */
1586
    public function resetPartialSProductss($v = true)
1587
    {
1588
        $this->collSProductssPartial = $v;
1589
    }
1590
1591
    /**
1592
     * Initializes the collSProductss collection.
1593
     *
1594
     * By default this just sets the collSProductss collection to an empty array (like clearcollSProductss());
1595
     * however, you may wish to override this method in your stub class to provide setting appropriate
1596
     * to your application -- for example, setting the initial array to the values stored in database.
1597
     *
1598
     * @param      boolean $overrideExisting If set to true, the method call initializes
1599
     *                                        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...
1600
     *
1601
     * @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...
1602
     */
1603 View Code Duplication
    public function initSProductss($overrideExisting = true)
1604
    {
1605
        if (null !== $this->collSProductss && !$overrideExisting) {
1606
            return;
1607
        }
1608
1609
        $collectionClassName = SProductsTableMap::getTableMap()->getCollectionClassName();
1610
1611
        $this->collSProductss = 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...
1612
        $this->collSProductss->setModel('\SProducts');
1613
    }
1614
1615
    /**
1616
     * Gets an array of SProducts objects which contain a foreign key that references this object.
1617
     *
1618
     * If the $criteria is not null, it is used to always fetch the results from the database.
1619
     * Otherwise the results are fetched from the database the first time, then cached.
1620
     * Next time the same method is called without $criteria, the cached collection is returned.
1621
     * If this ChildRoute is new, it will return
1622
     * an empty collection or the current collection; the criteria is ignored on a new object.
1623
     *
1624
     * @param      Criteria $criteria optional Criteria object to narrow the query
1625
     * @param      ConnectionInterface $con optional connection object
1626
     * @return ObjectCollection|SProducts[] List of SProducts objects
1627
     * @throws PropelException
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
1628
     */
1629 View Code Duplication
    public function getSProductss(Criteria $criteria = null, ConnectionInterface $con = null)
1630
    {
1631
        $partial = $this->collSProductssPartial && !$this->isNew();
1632
        if (null === $this->collSProductss || null !== $criteria  || $partial) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space before logical operator; 2 found
Loading history...
1633
            if ($this->isNew() && null === $this->collSProductss) {
1634
                // return empty collection
1635
                $this->initSProductss();
1636
            } else {
1637
                $collSProductss = SProductsQuery::create(null, $criteria)
1638
                    ->filterByRoute($this)
1639
                    ->find($con);
1640
1641
                if (null !== $criteria) {
1642
                    if (false !== $this->collSProductssPartial && count($collSProductss)) {
1643
                        $this->initSProductss(false);
1644
1645
                        foreach ($collSProductss as $obj) {
1646
                            if (false == $this->collSProductss->contains($obj)) {
1647
                                $this->collSProductss->append($obj);
1648
                            }
1649
                        }
1650
1651
                        $this->collSProductssPartial = true;
1652
                    }
1653
1654
                    return $collSProductss;
1655
                }
1656
1657
                if ($partial && $this->collSProductss) {
1658
                    foreach ($this->collSProductss as $obj) {
1659
                        if ($obj->isNew()) {
1660
                            $collSProductss[] = $obj;
1661
                        }
1662
                    }
1663
                }
1664
1665
                $this->collSProductss = $collSProductss;
1666
                $this->collSProductssPartial = false;
1667
            }
1668
        }
1669
1670
        return $this->collSProductss;
1671
    }
1672
1673
    /**
1674
     * Sets a collection of SProducts objects related by a one-to-many relationship
1675
     * to the current object.
1676
     * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
1677
     * and new objects from the given Propel collection.
1678
     *
1679
     * @param      Collection $sProductss A Propel collection.
1680
     * @param      ConnectionInterface $con Optional connection object
1681
     * @return $this|ChildRoute The current object (for fluent API support)
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
1682
     */
1683 View Code Duplication
    public function setSProductss(Collection $sProductss, ConnectionInterface $con = null)
1684
    {
1685
        /** @var SProducts[] $sProductssToDelete */
1686
        $sProductssToDelete = $this->getSProductss(new Criteria(), $con)->diff($sProductss);
1687
0 ignored issues
show
Coding Style introduced by
Functions must not contain multiple empty lines in a row; found 2 empty lines
Loading history...
1688
1689
        $this->sProductssScheduledForDeletion = $sProductssToDelete;
1690
1691
        foreach ($sProductssToDelete as $sProductsRemoved) {
1692
            $sProductsRemoved->setRoute(null);
1693
        }
1694
1695
        $this->collSProductss = null;
1696
        foreach ($sProductss as $sProducts) {
1697
            $this->addSProducts($sProducts);
1698
        }
1699
1700
        $this->collSProductss = $sProductss;
0 ignored issues
show
Documentation Bug introduced by
It seems like $sProductss of type object<Propel\Runtime\Collection\Collection> is incompatible with the declared type object<Propel\Runtime\Co...eger,object<SProducts>> of property $collSProductss.

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...
1701
        $this->collSProductssPartial = false;
1702
1703
        return $this;
1704
    }
1705
1706
    /**
1707
     * Returns the number of related BaseSProducts objects.
1708
     *
1709
     * @param      Criteria $criteria
1710
     * @param      boolean $distinct
1711
     * @param      ConnectionInterface $con
1712
     * @return int             Count of related BaseSProducts objects.
1713
     * @throws PropelException
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
1714
     */
1715
    public function countSProductss(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
1716
    {
1717
        $partial = $this->collSProductssPartial && !$this->isNew();
1718 View Code Duplication
        if (null === $this->collSProductss || null !== $criteria || $partial) {
1719
            if ($this->isNew() && null === $this->collSProductss) {
1720
                return 0;
1721
            }
1722
1723
            if ($partial && !$criteria) {
1724
                return count($this->getSProductss());
1725
            }
1726
1727
            $query = SProductsQuery::create(null, $criteria);
1728
            if ($distinct) {
1729
                $query->distinct();
1730
            }
1731
1732
            return $query
1733
                ->filterByRoute($this)
1734
                ->count($con);
1735
        }
1736
1737
        return count($this->collSProductss);
1738
    }
1739
1740
    /**
1741
     * Method called to associate a SProducts object to this object
1742
     * through the SProducts foreign key attribute.
1743
     *
1744
     * @param  SProducts $l SProducts
1745
     * @return $this|\core\models\Route The current object (for fluent API support)
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
1746
     */
1747
    public function addSProducts(SProducts $l)
1748
    {
1749
        if ($this->collSProductss === null) {
1750
            $this->initSProductss();
1751
            $this->collSProductssPartial = true;
1752
        }
1753
1754
        if (!$this->collSProductss->contains($l)) {
1755
            $this->doAddSProducts($l);
1756
1757
            if ($this->sProductssScheduledForDeletion and $this->sProductssScheduledForDeletion->contains($l)) {
1758
                $this->sProductssScheduledForDeletion->remove($this->sProductssScheduledForDeletion->search($l));
1759
            }
1760
        }
1761
1762
        return $this;
1763
    }
1764
1765
    /**
1766
     * @param SProducts $sProducts The SProducts object to add.
1767
     */
1768
    protected function doAddSProducts(SProducts $sProducts)
1769
    {
1770
        $this->collSProductss[]= $sProducts;
0 ignored issues
show
introduced by
Expected 1 space before "="; 0 found
Loading history...
1771
        $sProducts->setRoute($this);
1772
    }
1773
1774
    /**
1775
     * @param  SProducts $sProducts The SProducts object to remove.
1776
     * @return $this|ChildRoute The current object (for fluent API support)
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
1777
     */
1778 View Code Duplication
    public function removeSProducts(SProducts $sProducts)
1779
    {
1780
        if ($this->getSProductss()->contains($sProducts)) {
1781
            $pos = $this->collSProductss->search($sProducts);
1782
            $this->collSProductss->remove($pos);
1783
            if (null === $this->sProductssScheduledForDeletion) {
1784
                $this->sProductssScheduledForDeletion = clone $this->collSProductss;
1785
                $this->sProductssScheduledForDeletion->clear();
1786
            }
1787
            $this->sProductssScheduledForDeletion[]= $sProducts;
0 ignored issues
show
introduced by
Expected 1 space before "="; 0 found
Loading history...
1788
            $sProducts->setRoute(null);
1789
        }
1790
1791
        return $this;
1792
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line after function; 2 found
Loading history...
1793
1794
1795
    /**
1796
     * If this collection has already been initialized with
1797
     * an identical criteria, it returns the collection.
1798
     * Otherwise if this Route is new, it will return
1799
     * an empty collection; or if this Route has previously
1800
     * been saved, it will retrieve related SProductss from storage.
1801
     *
1802
     * This method is protected by default in order to keep the public
1803
     * api reasonable.  You can provide public methods for those you
1804
     * actually need in Route.
1805
     *
1806
     * @param      Criteria $criteria optional Criteria object to narrow the query
1807
     * @param      ConnectionInterface $con optional connection object
1808
     * @param      string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
1809
     * @return ObjectCollection|SProducts[] List of SProducts objects
1810
     */
1811 View Code Duplication
    public function getSProductssJoinBrand(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN)
1812
    {
1813
        $query = SProductsQuery::create(null, $criteria);
1814
        $query->joinWith('Brand', $joinBehavior);
1815
1816
        return $this->getSProductss($query, $con);
1817
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line after function; 2 found
Loading history...
1818
1819
1820
    /**
1821
     * If this collection has already been initialized with
1822
     * an identical criteria, it returns the collection.
1823
     * Otherwise if this Route is new, it will return
1824
     * an empty collection; or if this Route has previously
1825
     * been saved, it will retrieve related SProductss from storage.
1826
     *
1827
     * This method is protected by default in order to keep the public
1828
     * api reasonable.  You can provide public methods for those you
1829
     * actually need in Route.
1830
     *
1831
     * @param      Criteria $criteria optional Criteria object to narrow the query
1832
     * @param      ConnectionInterface $con optional connection object
1833
     * @param      string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
1834
     * @return ObjectCollection|SProducts[] List of SProducts objects
1835
     */
1836 View Code Duplication
    public function getSProductssJoinMainCategory(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN)
1837
    {
1838
        $query = SProductsQuery::create(null, $criteria);
1839
        $query->joinWith('MainCategory', $joinBehavior);
1840
1841
        return $this->getSProductss($query, $con);
1842
    }
1843
1844
    /**
1845
     * Clears the current object, sets all attributes to their default values and removes
1846
     * outgoing references as well as back-references (from other objects to this one. Results probably in a database
1847
     * change of those foreign objects when you call `save` there).
1848
     */
1849 View Code Duplication
    public function clear()
1850
    {
1851
        $this->id = null;
1852
        $this->entity_id = null;
1853
        $this->type = null;
1854
        $this->parent_url = null;
1855
        $this->url = null;
1856
        $this->alreadyInSave = false;
1857
        $this->clearAllReferences();
1858
        $this->applyDefaultValues();
1859
        $this->resetModified();
1860
        $this->setNew(true);
1861
        $this->setDeleted(false);
1862
    }
1863
1864
    /**
1865
     * Resets all references and back-references to other model objects or collections of model objects.
1866
     *
1867
     * This method is used to reset all php object references (not the actual reference in the database).
1868
     * Necessary for object serialisation.
1869
     *
1870
     * @param      boolean $deep Whether to also clear the references on all referrer objects.
1871
     */
1872
    public function clearAllReferences($deep = false)
1873
    {
1874
        if ($deep) {
1875
            if ($this->collSCategories) {
1876
                foreach ($this->collSCategories as $o) {
1877
                    $o->clearAllReferences($deep);
1878
                }
1879
            }
1880
            if ($this->collSProductss) {
1881
                foreach ($this->collSProductss as $o) {
1882
                    $o->clearAllReferences($deep);
1883
                }
1884
            }
1885
        } // if ($deep)
1886
1887
        $this->collSCategories = null;
1888
        $this->collSProductss = null;
1889
    }
1890
1891
    /**
1892
     * Return the string representation of this object
1893
     *
1894
     * @return string
1895
     */
1896
    public function __toString()
1897
    {
1898
        return (string) $this->exportTo(RouteTableMap::DEFAULT_STRING_FORMAT);
1899
    }
1900
1901
    /**
1902
     * Code to be run before persisting the object
1903
     * @param  ConnectionInterface $con
1904
     * @return boolean
1905
     */
1906
    public function preSave(ConnectionInterface $con = null)
1907
    {
1908
        if (is_callable('parent::preSave')) {
1909
            return parent::preSave($con);
1910
        }
1911
        return true;
1912
    }
1913
1914
    /**
1915
     * Code to be run after persisting the object
1916
     * @param ConnectionInterface $con
1917
     */
1918
    public function postSave(ConnectionInterface $con = null)
1919
    {
1920
        if (is_callable('parent::postSave')) {
1921
            parent::postSave($con);
1922
        }
1923
    }
1924
1925
    /**
1926
     * Code to be run before inserting to database
1927
     * @param  ConnectionInterface $con
1928
     * @return boolean
1929
     */
1930
    public function preInsert(ConnectionInterface $con = null)
1931
    {
1932
        if (is_callable('parent::preInsert')) {
1933
            return parent::preInsert($con);
1934
        }
1935
        return true;
1936
    }
1937
1938
    /**
1939
     * Code to be run after inserting to database
1940
     * @param ConnectionInterface $con
1941
     */
1942
    public function postInsert(ConnectionInterface $con = null)
1943
    {
1944
        if (is_callable('parent::postInsert')) {
1945
            parent::postInsert($con);
1946
        }
1947
    }
1948
1949
    /**
1950
     * Code to be run before updating the object in database
1951
     * @param  ConnectionInterface $con
1952
     * @return boolean
1953
     */
1954
    public function preUpdate(ConnectionInterface $con = null)
1955
    {
1956
        if (is_callable('parent::preUpdate')) {
1957
            return parent::preUpdate($con);
1958
        }
1959
        return true;
1960
    }
1961
1962
    /**
1963
     * Code to be run after updating the object in database
1964
     * @param ConnectionInterface $con
1965
     */
1966
    public function postUpdate(ConnectionInterface $con = null)
1967
    {
1968
        if (is_callable('parent::postUpdate')) {
1969
            parent::postUpdate($con);
1970
        }
1971
    }
1972
1973
    /**
1974
     * Code to be run before deleting the object in database
1975
     * @param  ConnectionInterface $con
1976
     * @return boolean
1977
     */
1978
    public function preDelete(ConnectionInterface $con = null)
1979
    {
1980
        if (is_callable('parent::preDelete')) {
1981
            return parent::preDelete($con);
1982
        }
1983
        return true;
1984
    }
1985
1986
    /**
1987
     * Code to be run after deleting the object in database
1988
     * @param ConnectionInterface $con
1989
     */
1990
    public function postDelete(ConnectionInterface $con = null)
1991
    {
1992
        if (is_callable('parent::postDelete')) {
1993
            parent::postDelete($con);
1994
        }
1995
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line after function; 2 found
Loading history...
1996
1997
1998
    /**
1999
     * Derived method to catches calls to undefined methods.
2000
     *
2001
     * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
2002
     * Allows to define default __call() behavior if you overwrite __call()
2003
     *
2004
     * @param string $name
2005
     * @param mixed  $params
0 ignored issues
show
introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
2006
     *
2007
     * @return array|string
2008
     */
2009 View Code Duplication
    public function __call($name, $params)
2010
    {
2011
        if (0 === strpos($name, 'get')) {
2012
            $virtualColumn = substr($name, 3);
2013
            if ($this->hasVirtualColumn($virtualColumn)) {
2014
                return $this->getVirtualColumn($virtualColumn);
2015
            }
2016
2017
            $virtualColumn = lcfirst($virtualColumn);
2018
            if ($this->hasVirtualColumn($virtualColumn)) {
2019
                return $this->getVirtualColumn($virtualColumn);
2020
            }
2021
        }
2022
2023
        if (0 === strpos($name, 'from')) {
2024
            $format = substr($name, 4);
2025
2026
            return $this->importFrom($format, reset($params));
2027
        }
2028
2029
        if (0 === strpos($name, 'to')) {
2030
            $format = substr($name, 2);
2031
            $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
2032
2033
            return $this->exportTo($format, $includeLazyLoadColumns);
2034
        }
2035
2036
        throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
2037
    }
2038
2039
}
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...
2040