Completed
Push — development ( 006c45...63d178 )
by Andrij
19:41 queued 09:38
created

modules/xbanners/models/Base/BannerImage.php (2 issues)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace xbanners\models\Base;
4
5
use \Exception;
6
use \PDO;
7
use Propel\Runtime\Propel;
8
use Propel\Runtime\ActiveQuery\Criteria;
9
use Propel\Runtime\ActiveQuery\ModelCriteria;
10
use Propel\Runtime\ActiveRecord\ActiveRecordInterface;
11
use Propel\Runtime\Collection\Collection;
12
use Propel\Runtime\Collection\ObjectCollection;
13
use Propel\Runtime\Connection\ConnectionInterface;
14
use Propel\Runtime\Exception\BadMethodCallException;
15
use Propel\Runtime\Exception\LogicException;
16
use Propel\Runtime\Exception\PropelException;
17
use Propel\Runtime\Map\TableMap;
18
use Propel\Runtime\Parser\AbstractParser;
19
use xbanners\models\BannerImage as ChildBannerImage;
20
use xbanners\models\BannerImageI18n as ChildBannerImageI18n;
21
use xbanners\models\BannerImageI18nQuery as ChildBannerImageI18nQuery;
22
use xbanners\models\BannerImageQuery as ChildBannerImageQuery;
23
use xbanners\models\Banners as ChildBanners;
24
use xbanners\models\BannersQuery as ChildBannersQuery;
25
use xbanners\models\Map\BannerImageI18nTableMap;
26
use xbanners\models\Map\BannerImageTableMap;
27
28
/**
29
 * Base class that represents a row from the 'banner_image' table.
30
 *
31
 *
32
 *
33
 * @package    propel.generator.xbanners.models.Base
34
 */
35
abstract class BannerImage implements ActiveRecordInterface
36
{
37
    /**
38
     * TableMap class name
39
     */
40
    const TABLE_MAP = '\\xbanners\\models\\Map\\BannerImageTableMap';
41
42
43
    /**
44
     * attribute to determine if this object has previously been saved.
45
     * @var boolean
46
     */
47
    protected $new = true;
48
49
    /**
50
     * attribute to determine whether this object has been deleted.
51
     * @var boolean
52
     */
53
    protected $deleted = false;
54
55
    /**
56
     * The columns that have been modified in current object.
57
     * Tracking modified columns allows us to only update modified columns.
58
     * @var array
59
     */
60
    protected $modifiedColumns = array();
61
62
    /**
63
     * The (virtual) columns that are added at runtime
64
     * The formatters can add supplementary columns based on a resultset
65
     * @var array
66
     */
67
    protected $virtualColumns = array();
68
69
    /**
70
     * The value for the id field.
71
     *
72
     * @var        int
73
     */
74
    protected $id;
75
76
    /**
77
     * The value for the banner_id field.
78
     *
79
     * @var        int
80
     */
81
    protected $banner_id;
82
83
    /**
84
     * The value for the target field.
85
     *
86
     * @var        int
87
     */
88
    protected $target;
89
90
    /**
91
     * The value for the url field.
92
     *
93
     * @var        string
94
     */
95
    protected $url;
96
97
    /**
98
     * The value for the allowed_page field.
99
     *
100
     * @var        int
101
     */
102
    protected $allowed_page;
103
104
    /**
105
     * The value for the position field.
106
     *
107
     * @var        int
108
     */
109
    protected $position;
110
111
    /**
112
     * The value for the active_from field.
113
     *
114
     * @var        int
115
     */
116
    protected $active_from;
117
118
    /**
119
     * The value for the active_to field.
120
     *
121
     * @var        int
122
     */
123
    protected $active_to;
124
125
    /**
126
     * The value for the active field.
127
     *
128
     * @var        int
129
     */
130
    protected $active;
131
132
    /**
133
     * The value for the permanent field.
134
     *
135
     * @var        int
136
     */
137
    protected $permanent;
138
139
    /**
140
     * @var        ChildBanners
141
     */
142
    protected $aBanners;
143
144
    /**
145
     * @var        ObjectCollection|ChildBannerImageI18n[] Collection to store aggregation of ChildBannerImageI18n objects.
146
     */
147
    protected $collBannerImageI18ns;
148
    protected $collBannerImageI18nsPartial;
149
150
    /**
151
     * Flag to prevent endless save loop, if this object is referenced
152
     * by another object which falls in this transaction.
153
     *
154
     * @var boolean
155
     */
156
    protected $alreadyInSave = false;
157
158
    // i18n behavior
159
160
    /**
161
     * Current locale
162
     * @var        string
163
     */
164
    protected $currentLocale = 'ru';
165
166
    /**
167
     * Current translation objects
168
     * @var        array[ChildBannerImageI18n]
169
     */
170
    protected $currentTranslations;
171
172
    /**
173
     * An array of objects scheduled for deletion.
174
     * @var ObjectCollection|ChildBannerImageI18n[]
175
     */
176
    protected $bannerImageI18nsScheduledForDeletion = null;
177
178
    /**
179
     * Initializes internal state of xbanners\models\Base\BannerImage object.
180
     */
181
    public function __construct()
182
    {
183
    }
184
185
    /**
186
     * Returns whether the object has been modified.
187
     *
188
     * @return boolean True if the object has been modified.
189
     */
190
    public function isModified()
191
    {
192
        return !!$this->modifiedColumns;
193
    }
194
195
    /**
196
     * Has specified column been modified?
197
     *
198
     * @param  string  $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID
199
     * @return boolean True if $col has been modified.
200
     */
201
    public function isColumnModified($col)
202
    {
203
        return $this->modifiedColumns && isset($this->modifiedColumns[$col]);
204
    }
205
206
    /**
207
     * Get the columns that have been modified in this object.
208
     * @return array A unique list of the modified column names for this object.
209
     */
210
    public function getModifiedColumns()
211
    {
212
        return $this->modifiedColumns ? array_keys($this->modifiedColumns) : [];
213
    }
214
215
    /**
216
     * Returns whether the object has ever been saved.  This will
217
     * be false, if the object was retrieved from storage or was created
218
     * and then saved.
219
     *
220
     * @return boolean true, if the object has never been persisted.
221
     */
222
    public function isNew()
223
    {
224
        return $this->new;
225
    }
226
227
    /**
228
     * Setter for the isNew attribute.  This method will be called
229
     * by Propel-generated children and objects.
230
     *
231
     * @param boolean $b the state of the object.
232
     */
233
    public function setNew($b)
234
    {
235
        $this->new = (boolean) $b;
236
    }
237
238
    /**
239
     * Whether this object has been deleted.
240
     * @return boolean The deleted state of this object.
241
     */
242
    public function isDeleted()
243
    {
244
        return $this->deleted;
245
    }
246
247
    /**
248
     * Specify whether this object has been deleted.
249
     * @param  boolean $b The deleted state of this object.
250
     * @return void
251
     */
252
    public function setDeleted($b)
253
    {
254
        $this->deleted = (boolean) $b;
255
    }
256
257
    /**
258
     * Sets the modified state for the object to be false.
259
     * @param  string $col If supplied, only the specified column is reset.
260
     * @return void
261
     */
262 View Code Duplication
    public function resetModified($col = null)
263
    {
264
        if (null !== $col) {
265
            if (isset($this->modifiedColumns[$col])) {
266
                unset($this->modifiedColumns[$col]);
267
            }
268
        } else {
269
            $this->modifiedColumns = array();
270
        }
271
    }
272
273
    /**
274
     * Compares this with another <code>BannerImage</code> instance.  If
275
     * <code>obj</code> is an instance of <code>BannerImage</code>, delegates to
276
     * <code>equals(BannerImage)</code>.  Otherwise, returns <code>false</code>.
277
     *
278
     * @param  mixed   $obj The object to compare to.
279
     * @return boolean Whether equal to the object specified.
280
     */
281 View Code Duplication
    public function equals($obj)
282
    {
283
        if (!$obj instanceof static) {
284
            return false;
285
        }
286
287
        if ($this === $obj) {
288
            return true;
289
        }
290
291
        if (null === $this->getPrimaryKey() || null === $obj->getPrimaryKey()) {
292
            return false;
293
        }
294
295
        return $this->getPrimaryKey() === $obj->getPrimaryKey();
296
    }
297
298
    /**
299
     * Get the associative array of the virtual columns in this object
300
     *
301
     * @return array
302
     */
303
    public function getVirtualColumns()
304
    {
305
        return $this->virtualColumns;
306
    }
307
308
    /**
309
     * Checks the existence of a virtual column in this object
310
     *
311
     * @param  string  $name The virtual column name
312
     * @return boolean
313
     */
314
    public function hasVirtualColumn($name)
315
    {
316
        return array_key_exists($name, $this->virtualColumns);
317
    }
318
319
    /**
320
     * Get the value of a virtual column in this object
321
     *
322
     * @param  string $name The virtual column name
323
     * @return mixed
324
     *
325
     * @throws PropelException
326
     */
327 View Code Duplication
    public function getVirtualColumn($name)
328
    {
329
        if (!$this->hasVirtualColumn($name)) {
330
            throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name));
331
        }
332
333
        return $this->virtualColumns[$name];
334
    }
335
336
    /**
337
     * Set the value of a virtual column in this object
338
     *
339
     * @param string $name  The virtual column name
340
     * @param mixed  $value The value to give to the virtual column
341
     *
342
     * @return $this|BannerImage The current object, for fluid interface
343
     */
344
    public function setVirtualColumn($name, $value)
345
    {
346
        $this->virtualColumns[$name] = $value;
347
348
        return $this;
349
    }
350
351
    /**
352
     * Logs a message using Propel::log().
353
     *
354
     * @param  string  $msg
355
     * @param  int     $priority One of the Propel::LOG_* logging levels
356
     * @return boolean
357
     */
358
    protected function log($msg, $priority = Propel::LOG_INFO)
359
    {
360
        return Propel::log(get_class($this) . ': ' . $msg, $priority);
361
    }
362
363
    /**
364
     * Export the current object properties to a string, using a given parser format
365
     * <code>
366
     * $book = BookQuery::create()->findPk(9012);
367
     * echo $book->exportTo('JSON');
368
     *  => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
369
     * </code>
370
     *
371
     * @param  mixed   $parser                 A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV')
372
     * @param  boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE.
373
     * @return string  The exported data
374
     */
375 View Code Duplication
    public function exportTo($parser, $includeLazyLoadColumns = true)
376
    {
377
        if (!$parser instanceof AbstractParser) {
0 ignored issues
show
The class Propel\Runtime\Parser\AbstractParser does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
378
            $parser = AbstractParser::getParser($parser);
379
        }
380
381
        return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true));
382
    }
383
384
    /**
385
     * Clean up internal collections prior to serializing
386
     * Avoids recursive loops that turn into segmentation faults when serializing
387
     */
388 View Code Duplication
    public function __sleep()
389
    {
390
        $this->clearAllReferences();
391
392
        $cls = new \ReflectionClass($this);
393
        $propertyNames = [];
394
        $serializableProperties = array_diff($cls->getProperties(), $cls->getProperties(\ReflectionProperty::IS_STATIC));
395
396
        foreach($serializableProperties as $property) {
397
            $propertyNames[] = $property->getName();
398
        }
399
400
        return $propertyNames;
401
    }
402
403
    /**
404
     * Get the [id] column value.
405
     *
406
     * @return int
407
     */
408
    public function getId()
409
    {
410
        return $this->id;
411
    }
412
413
    /**
414
     * Get the [banner_id] column value.
415
     *
416
     * @return int
417
     */
418
    public function getBannerId()
419
    {
420
        return $this->banner_id;
421
    }
422
423
    /**
424
     * Get the [target] column value.
425
     *
426
     * @return int
427
     */
428
    public function getTarget()
429
    {
430
        return $this->target;
431
    }
432
433
    /**
434
     * Get the [url] column value.
435
     *
436
     * @return string
437
     */
438
    public function getUrl()
439
    {
440
        return $this->url;
441
    }
442
443
    /**
444
     * Get the [allowed_page] column value.
445
     *
446
     * @return int
447
     */
448
    public function getAllowedPage()
449
    {
450
        return $this->allowed_page;
451
    }
452
453
    /**
454
     * Get the [position] column value.
455
     *
456
     * @return int
457
     */
458
    public function getPosition()
459
    {
460
        return $this->position;
461
    }
462
463
    /**
464
     * Get the [active_from] column value.
465
     *
466
     * @return int
467
     */
468
    public function getActiveFrom()
469
    {
470
        return $this->active_from;
471
    }
472
473
    /**
474
     * Get the [active_to] column value.
475
     *
476
     * @return int
477
     */
478
    public function getActiveTo()
479
    {
480
        return $this->active_to;
481
    }
482
483
    /**
484
     * Get the [active] column value.
485
     *
486
     * @return int
487
     */
488
    public function getActive()
489
    {
490
        return $this->active;
491
    }
492
493
    /**
494
     * Get the [permanent] column value.
495
     *
496
     * @return int
497
     */
498
    public function getPermanent()
499
    {
500
        return $this->permanent;
501
    }
502
503
    /**
504
     * Set the value of [id] column.
505
     *
506
     * @param int $v new value
507
     * @return $this|\xbanners\models\BannerImage The current object (for fluent API support)
508
     */
509
    public function setId($v)
510
    {
511
        if ($v !== null) {
512
            $v = (int) $v;
513
        }
514
515
        if ($this->id !== $v) {
516
            $this->id = $v;
517
            $this->modifiedColumns[BannerImageTableMap::COL_ID] = true;
518
        }
519
520
        return $this;
521
    } // setId()
522
523
    /**
524
     * Set the value of [banner_id] column.
525
     *
526
     * @param int $v new value
527
     * @return $this|\xbanners\models\BannerImage The current object (for fluent API support)
528
     */
529 View Code Duplication
    public function setBannerId($v)
530
    {
531
        if ($v !== null) {
532
            $v = (int) $v;
533
        }
534
535
        if ($this->banner_id !== $v) {
536
            $this->banner_id = $v;
537
            $this->modifiedColumns[BannerImageTableMap::COL_BANNER_ID] = true;
538
        }
539
540
        if ($this->aBanners !== null && $this->aBanners->getId() !== $v) {
541
            $this->aBanners = null;
542
        }
543
544
        return $this;
545
    } // setBannerId()
546
547
    /**
548
     * Set the value of [target] column.
549
     *
550
     * @param int $v new value
551
     * @return $this|\xbanners\models\BannerImage The current object (for fluent API support)
552
     */
553
    public function setTarget($v)
554
    {
555
        if ($v !== null) {
556
            $v = (int) $v;
557
        }
558
559
        if ($this->target !== $v) {
560
            $this->target = $v;
561
            $this->modifiedColumns[BannerImageTableMap::COL_TARGET] = true;
562
        }
563
564
        return $this;
565
    } // setTarget()
566
567
    /**
568
     * Set the value of [url] column.
569
     *
570
     * @param string $v new value
571
     * @return $this|\xbanners\models\BannerImage The current object (for fluent API support)
572
     */
573
    public function setUrl($v)
574
    {
575
        if ($v !== null) {
576
            $v = (string) $v;
577
        }
578
579
        if ($this->url !== $v) {
580
            $this->url = $v;
581
            $this->modifiedColumns[BannerImageTableMap::COL_URL] = true;
582
        }
583
584
        return $this;
585
    } // setUrl()
586
587
    /**
588
     * Set the value of [allowed_page] column.
589
     *
590
     * @param int $v new value
591
     * @return $this|\xbanners\models\BannerImage The current object (for fluent API support)
592
     */
593
    public function setAllowedPage($v)
594
    {
595
        if ($v !== null) {
596
            $v = (int) $v;
597
        }
598
599
        if ($this->allowed_page !== $v) {
600
            $this->allowed_page = $v;
601
            $this->modifiedColumns[BannerImageTableMap::COL_ALLOWED_PAGE] = true;
602
        }
603
604
        return $this;
605
    } // setAllowedPage()
606
607
    /**
608
     * Set the value of [position] column.
609
     *
610
     * @param int $v new value
611
     * @return $this|\xbanners\models\BannerImage The current object (for fluent API support)
612
     */
613
    public function setPosition($v)
614
    {
615
        if ($v !== null) {
616
            $v = (int) $v;
617
        }
618
619
        if ($this->position !== $v) {
620
            $this->position = $v;
621
            $this->modifiedColumns[BannerImageTableMap::COL_POSITION] = true;
622
        }
623
624
        return $this;
625
    } // setPosition()
626
627
    /**
628
     * Set the value of [active_from] column.
629
     *
630
     * @param int $v new value
631
     * @return $this|\xbanners\models\BannerImage The current object (for fluent API support)
632
     */
633
    public function setActiveFrom($v)
634
    {
635
        if ($v !== null) {
636
            $v = (int) $v;
637
        }
638
639
        if ($this->active_from !== $v) {
640
            $this->active_from = $v;
641
            $this->modifiedColumns[BannerImageTableMap::COL_ACTIVE_FROM] = true;
642
        }
643
644
        return $this;
645
    } // setActiveFrom()
646
647
    /**
648
     * Set the value of [active_to] column.
649
     *
650
     * @param int $v new value
651
     * @return $this|\xbanners\models\BannerImage The current object (for fluent API support)
652
     */
653
    public function setActiveTo($v)
654
    {
655
        if ($v !== null) {
656
            $v = (int) $v;
657
        }
658
659
        if ($this->active_to !== $v) {
660
            $this->active_to = $v;
661
            $this->modifiedColumns[BannerImageTableMap::COL_ACTIVE_TO] = true;
662
        }
663
664
        return $this;
665
    } // setActiveTo()
666
667
    /**
668
     * Set the value of [active] column.
669
     *
670
     * @param int $v new value
671
     * @return $this|\xbanners\models\BannerImage The current object (for fluent API support)
672
     */
673
    public function setActive($v)
674
    {
675
        if ($v !== null) {
676
            $v = (int) $v;
677
        }
678
679
        if ($this->active !== $v) {
680
            $this->active = $v;
681
            $this->modifiedColumns[BannerImageTableMap::COL_ACTIVE] = true;
682
        }
683
684
        return $this;
685
    } // setActive()
686
687
    /**
688
     * Set the value of [permanent] column.
689
     *
690
     * @param int $v new value
691
     * @return $this|\xbanners\models\BannerImage The current object (for fluent API support)
692
     */
693
    public function setPermanent($v)
694
    {
695
        if ($v !== null) {
696
            $v = (int) $v;
697
        }
698
699
        if ($this->permanent !== $v) {
700
            $this->permanent = $v;
701
            $this->modifiedColumns[BannerImageTableMap::COL_PERMANENT] = true;
702
        }
703
704
        return $this;
705
    } // setPermanent()
706
707
    /**
708
     * Indicates whether the columns in this object are only set to default values.
709
     *
710
     * This method can be used in conjunction with isModified() to indicate whether an object is both
711
     * modified _and_ has some values set which are non-default.
712
     *
713
     * @return boolean Whether the columns in this object are only been set with default values.
714
     */
715
    public function hasOnlyDefaultValues()
716
    {
717
        // otherwise, everything was equal, so return TRUE
718
        return true;
719
    } // hasOnlyDefaultValues()
720
721
    /**
722
     * Hydrates (populates) the object variables with values from the database resultset.
723
     *
724
     * An offset (0-based "start column") is specified so that objects can be hydrated
725
     * with a subset of the columns in the resultset rows.  This is needed, for example,
726
     * for results of JOIN queries where the resultset row includes columns from two or
727
     * more tables.
728
     *
729
     * @param array   $row       The row returned by DataFetcher->fetch().
730
     * @param int     $startcol  0-based offset column which indicates which restultset column to start with.
731
     * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
732
     * @param string  $indexType The index type of $row. Mostly DataFetcher->getIndexType().
733
                                  One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME
734
     *                            TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
735
     *
736
     * @return int             next starting column
737
     * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
738
     */
739
    public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
740
    {
741
        try {
742
743
            $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : BannerImageTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)];
744
            $this->id = (null !== $col) ? (int) $col : null;
745
746
            $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : BannerImageTableMap::translateFieldName('BannerId', TableMap::TYPE_PHPNAME, $indexType)];
747
            $this->banner_id = (null !== $col) ? (int) $col : null;
748
749
            $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : BannerImageTableMap::translateFieldName('Target', TableMap::TYPE_PHPNAME, $indexType)];
750
            $this->target = (null !== $col) ? (int) $col : null;
751
752
            $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : BannerImageTableMap::translateFieldName('Url', TableMap::TYPE_PHPNAME, $indexType)];
753
            $this->url = (null !== $col) ? (string) $col : null;
754
755
            $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : BannerImageTableMap::translateFieldName('AllowedPage', TableMap::TYPE_PHPNAME, $indexType)];
756
            $this->allowed_page = (null !== $col) ? (int) $col : null;
757
758
            $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : BannerImageTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)];
759
            $this->position = (null !== $col) ? (int) $col : null;
760
761
            $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : BannerImageTableMap::translateFieldName('ActiveFrom', TableMap::TYPE_PHPNAME, $indexType)];
762
            $this->active_from = (null !== $col) ? (int) $col : null;
763
764
            $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : BannerImageTableMap::translateFieldName('ActiveTo', TableMap::TYPE_PHPNAME, $indexType)];
765
            $this->active_to = (null !== $col) ? (int) $col : null;
766
767
            $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : BannerImageTableMap::translateFieldName('Active', TableMap::TYPE_PHPNAME, $indexType)];
768
            $this->active = (null !== $col) ? (int) $col : null;
769
770
            $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : BannerImageTableMap::translateFieldName('Permanent', TableMap::TYPE_PHPNAME, $indexType)];
771
            $this->permanent = (null !== $col) ? (int) $col : null;
772
            $this->resetModified();
773
774
            $this->setNew(false);
775
776
            if ($rehydrate) {
777
                $this->ensureConsistency();
778
            }
779
780
            return $startcol + 10; // 10 = BannerImageTableMap::NUM_HYDRATE_COLUMNS.
781
782
        } catch (Exception $e) {
783
            throw new PropelException(sprintf('Error populating %s object', '\\xbanners\\models\\BannerImage'), 0, $e);
784
        }
785
    }
786
787
    /**
788
     * Checks and repairs the internal consistency of the object.
789
     *
790
     * This method is executed after an already-instantiated object is re-hydrated
791
     * from the database.  It exists to check any foreign keys to make sure that
792
     * the objects related to the current object are correct based on foreign key.
793
     *
794
     * You can override this method in the stub class, but you should always invoke
795
     * the base method from the overridden method (i.e. parent::ensureConsistency()),
796
     * in case your model changes.
797
     *
798
     * @throws PropelException
799
     */
800
    public function ensureConsistency()
801
    {
802
        if ($this->aBanners !== null && $this->banner_id !== $this->aBanners->getId()) {
803
            $this->aBanners = null;
804
        }
805
    } // ensureConsistency
806
807
    /**
808
     * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
809
     *
810
     * This will only work if the object has been saved and has a valid primary key set.
811
     *
812
     * @param      boolean $deep (optional) Whether to also de-associated any related objects.
813
     * @param      ConnectionInterface $con (optional) The ConnectionInterface connection to use.
814
     * @return void
815
     * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
816
     */
817 View Code Duplication
    public function reload($deep = false, ConnectionInterface $con = null)
818
    {
819
        if ($this->isDeleted()) {
820
            throw new PropelException("Cannot reload a deleted object.");
821
        }
822
823
        if ($this->isNew()) {
824
            throw new PropelException("Cannot reload an unsaved object.");
825
        }
826
827
        if ($con === null) {
828
            $con = Propel::getServiceContainer()->getReadConnection(BannerImageTableMap::DATABASE_NAME);
829
        }
830
831
        // We don't need to alter the object instance pool; we're just modifying this instance
832
        // already in the pool.
833
834
        $dataFetcher = ChildBannerImageQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con);
835
        $row = $dataFetcher->fetch();
836
        $dataFetcher->close();
837
        if (!$row) {
838
            throw new PropelException('Cannot find matching row in the database to reload object values.');
839
        }
840
        $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate
841
842
        if ($deep) {  // also de-associate any related objects?
843
844
            $this->aBanners = null;
845
            $this->collBannerImageI18ns = null;
846
847
        } // if (deep)
848
    }
849
850
    /**
851
     * Removes this object from datastore and sets delete attribute.
852
     *
853
     * @param      ConnectionInterface $con
854
     * @return void
855
     * @throws PropelException
856
     * @see BannerImage::setDeleted()
857
     * @see BannerImage::isDeleted()
858
     */
859 View Code Duplication
    public function delete(ConnectionInterface $con = null)
860
    {
861
        if ($this->isDeleted()) {
862
            throw new PropelException("This object has already been deleted.");
863
        }
864
865
        if ($con === null) {
866
            $con = Propel::getServiceContainer()->getWriteConnection(BannerImageTableMap::DATABASE_NAME);
867
        }
868
869
        $con->transaction(function () use ($con) {
870
            $deleteQuery = ChildBannerImageQuery::create()
871
                ->filterByPrimaryKey($this->getPrimaryKey());
872
            $ret = $this->preDelete($con);
873
            if ($ret) {
874
                $deleteQuery->delete($con);
875
                $this->postDelete($con);
876
                $this->setDeleted(true);
877
            }
878
        });
879
    }
880
881
    /**
882
     * Persists this object to the database.
883
     *
884
     * If the object is new, it inserts it; otherwise an update is performed.
885
     * All modified related objects will also be persisted in the doSave()
886
     * method.  This method wraps all precipitate database operations in a
887
     * single transaction.
888
     *
889
     * @param      ConnectionInterface $con
890
     * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
891
     * @throws PropelException
892
     * @see doSave()
893
     */
894 View Code Duplication
    public function save(ConnectionInterface $con = null)
895
    {
896
        if ($this->isDeleted()) {
897
            throw new PropelException("You cannot save an object that has been deleted.");
898
        }
899
900
        if ($con === null) {
901
            $con = Propel::getServiceContainer()->getWriteConnection(BannerImageTableMap::DATABASE_NAME);
902
        }
903
904
        return $con->transaction(function () use ($con) {
905
            $ret = $this->preSave($con);
906
            $isInsert = $this->isNew();
907
            if ($isInsert) {
908
                $ret = $ret && $this->preInsert($con);
909
            } else {
910
                $ret = $ret && $this->preUpdate($con);
911
            }
912
            if ($ret) {
913
                $affectedRows = $this->doSave($con);
914
                if ($isInsert) {
915
                    $this->postInsert($con);
916
                } else {
917
                    $this->postUpdate($con);
918
                }
919
                $this->postSave($con);
920
                BannerImageTableMap::addInstanceToPool($this);
921
            } else {
922
                $affectedRows = 0;
923
            }
924
925
            return $affectedRows;
926
        });
927
    }
928
929
    /**
930
     * Performs the work of inserting or updating the row in the database.
931
     *
932
     * If the object is new, it inserts it; otherwise an update is performed.
933
     * All related objects are also updated in this method.
934
     *
935
     * @param      ConnectionInterface $con
936
     * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
937
     * @throws PropelException
938
     * @see save()
939
     */
940
    protected function doSave(ConnectionInterface $con)
941
    {
942
        $affectedRows = 0; // initialize var to track total num of affected rows
943
        if (!$this->alreadyInSave) {
944
            $this->alreadyInSave = true;
945
946
            // We call the save method on the following object(s) if they
947
            // were passed to this object by their corresponding set
948
            // method.  This object relates to these object(s) by a
949
            // foreign key reference.
950
951
            if ($this->aBanners !== null) {
952
                if ($this->aBanners->isModified() || $this->aBanners->isNew()) {
953
                    $affectedRows += $this->aBanners->save($con);
954
                }
955
                $this->setBanners($this->aBanners);
956
            }
957
958
            if ($this->isNew() || $this->isModified()) {
959
                // persist changes
960
                if ($this->isNew()) {
961
                    $this->doInsert($con);
962
                    $affectedRows += 1;
963
                } else {
964
                    $affectedRows += $this->doUpdate($con);
965
                }
966
                $this->resetModified();
967
            }
968
969
            if ($this->bannerImageI18nsScheduledForDeletion !== null) {
970
                if (!$this->bannerImageI18nsScheduledForDeletion->isEmpty()) {
971
                    \xbanners\models\BannerImageI18nQuery::create()
972
                        ->filterByPrimaryKeys($this->bannerImageI18nsScheduledForDeletion->getPrimaryKeys(false))
973
                        ->delete($con);
974
                    $this->bannerImageI18nsScheduledForDeletion = null;
975
                }
976
            }
977
978 View Code Duplication
            if ($this->collBannerImageI18ns !== null) {
979
                foreach ($this->collBannerImageI18ns as $referrerFK) {
980
                    if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
981
                        $affectedRows += $referrerFK->save($con);
982
                    }
983
                }
984
            }
985
986
            $this->alreadyInSave = false;
987
988
        }
989
990
        return $affectedRows;
991
    } // doSave()
992
993
    /**
994
     * Insert the row in the database.
995
     *
996
     * @param      ConnectionInterface $con
997
     *
998
     * @throws PropelException
999
     * @see doSave()
1000
     */
1001
    protected function doInsert(ConnectionInterface $con)
1002
    {
1003
        $modifiedColumns = array();
1004
        $index = 0;
1005
1006
        $this->modifiedColumns[BannerImageTableMap::COL_ID] = true;
1007
        if (null !== $this->id) {
1008
            throw new PropelException('Cannot insert a value for auto-increment primary key (' . BannerImageTableMap::COL_ID . ')');
1009
        }
1010
1011
         // check the columns in natural order for more readable SQL queries
1012
        if ($this->isColumnModified(BannerImageTableMap::COL_ID)) {
1013
            $modifiedColumns[':p' . $index++]  = 'id';
1014
        }
1015
        if ($this->isColumnModified(BannerImageTableMap::COL_BANNER_ID)) {
1016
            $modifiedColumns[':p' . $index++]  = 'banner_id';
1017
        }
1018
        if ($this->isColumnModified(BannerImageTableMap::COL_TARGET)) {
1019
            $modifiedColumns[':p' . $index++]  = 'target';
1020
        }
1021
        if ($this->isColumnModified(BannerImageTableMap::COL_URL)) {
1022
            $modifiedColumns[':p' . $index++]  = 'url';
1023
        }
1024
        if ($this->isColumnModified(BannerImageTableMap::COL_ALLOWED_PAGE)) {
1025
            $modifiedColumns[':p' . $index++]  = 'allowed_page';
1026
        }
1027
        if ($this->isColumnModified(BannerImageTableMap::COL_POSITION)) {
1028
            $modifiedColumns[':p' . $index++]  = 'position';
1029
        }
1030
        if ($this->isColumnModified(BannerImageTableMap::COL_ACTIVE_FROM)) {
1031
            $modifiedColumns[':p' . $index++]  = 'active_from';
1032
        }
1033
        if ($this->isColumnModified(BannerImageTableMap::COL_ACTIVE_TO)) {
1034
            $modifiedColumns[':p' . $index++]  = 'active_to';
1035
        }
1036
        if ($this->isColumnModified(BannerImageTableMap::COL_ACTIVE)) {
1037
            $modifiedColumns[':p' . $index++]  = 'active';
1038
        }
1039
        if ($this->isColumnModified(BannerImageTableMap::COL_PERMANENT)) {
1040
            $modifiedColumns[':p' . $index++]  = 'permanent';
1041
        }
1042
1043
        $sql = sprintf(
1044
            'INSERT INTO banner_image (%s) VALUES (%s)',
1045
            implode(', ', $modifiedColumns),
1046
            implode(', ', array_keys($modifiedColumns))
1047
        );
1048
1049
        try {
1050
            $stmt = $con->prepare($sql);
1051
            foreach ($modifiedColumns as $identifier => $columnName) {
1052
                switch ($columnName) {
1053
                    case 'id':
1054
                        $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
1055
                        break;
1056
                    case 'banner_id':
1057
                        $stmt->bindValue($identifier, $this->banner_id, PDO::PARAM_INT);
1058
                        break;
1059
                    case 'target':
1060
                        $stmt->bindValue($identifier, $this->target, PDO::PARAM_INT);
1061
                        break;
1062
                    case 'url':
1063
                        $stmt->bindValue($identifier, $this->url, PDO::PARAM_STR);
1064
                        break;
1065
                    case 'allowed_page':
1066
                        $stmt->bindValue($identifier, $this->allowed_page, PDO::PARAM_INT);
1067
                        break;
1068
                    case 'position':
1069
                        $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT);
1070
                        break;
1071
                    case 'active_from':
1072
                        $stmt->bindValue($identifier, $this->active_from, PDO::PARAM_INT);
1073
                        break;
1074
                    case 'active_to':
1075
                        $stmt->bindValue($identifier, $this->active_to, PDO::PARAM_INT);
1076
                        break;
1077
                    case 'active':
1078
                        $stmt->bindValue($identifier, $this->active, PDO::PARAM_INT);
1079
                        break;
1080
                    case 'permanent':
1081
                        $stmt->bindValue($identifier, $this->permanent, PDO::PARAM_INT);
1082
                        break;
1083
                }
1084
            }
1085
            $stmt->execute();
1086
        } catch (Exception $e) {
1087
            Propel::log($e->getMessage(), Propel::LOG_ERR);
1088
            throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
1089
        }
1090
1091
        try {
1092
            $pk = $con->lastInsertId();
1093
        } catch (Exception $e) {
1094
            throw new PropelException('Unable to get autoincrement id.', 0, $e);
1095
        }
1096
        $this->setId($pk);
1097
1098
        $this->setNew(false);
1099
    }
1100
1101
    /**
1102
     * Update the row in the database.
1103
     *
1104
     * @param      ConnectionInterface $con
1105
     *
1106
     * @return Integer Number of updated rows
1107
     * @see doSave()
1108
     */
1109
    protected function doUpdate(ConnectionInterface $con)
1110
    {
1111
        $selectCriteria = $this->buildPkeyCriteria();
1112
        $valuesCriteria = $this->buildCriteria();
1113
1114
        return $selectCriteria->doUpdate($valuesCriteria, $con);
1115
    }
1116
1117
    /**
1118
     * Retrieves a field from the object by name passed in as a string.
1119
     *
1120
     * @param      string $name name
1121
     * @param      string $type The type of fieldname the $name is of:
1122
     *                     one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME
1123
     *                     TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
1124
     *                     Defaults to TableMap::TYPE_PHPNAME.
1125
     * @return mixed Value of field.
1126
     */
1127 View Code Duplication
    public function getByName($name, $type = TableMap::TYPE_PHPNAME)
1128
    {
1129
        $pos = BannerImageTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
1130
        $field = $this->getByPosition($pos);
1131
1132
        return $field;
1133
    }
1134
1135
    /**
1136
     * Retrieves a field from the object by Position as specified in the xml schema.
1137
     * Zero-based.
1138
     *
1139
     * @param      int $pos position in xml schema
1140
     * @return mixed Value of field at $pos
1141
     */
1142
    public function getByPosition($pos)
1143
    {
1144
        switch ($pos) {
1145
            case 0:
1146
                return $this->getId();
1147
                break;
1148
            case 1:
1149
                return $this->getBannerId();
1150
                break;
1151
            case 2:
1152
                return $this->getTarget();
1153
                break;
1154
            case 3:
1155
                return $this->getUrl();
1156
                break;
1157
            case 4:
1158
                return $this->getAllowedPage();
1159
                break;
1160
            case 5:
1161
                return $this->getPosition();
1162
                break;
1163
            case 6:
1164
                return $this->getActiveFrom();
1165
                break;
1166
            case 7:
1167
                return $this->getActiveTo();
1168
                break;
1169
            case 8:
1170
                return $this->getActive();
1171
                break;
1172
            case 9:
1173
                return $this->getPermanent();
1174
                break;
1175
            default:
1176
                return null;
1177
                break;
1178
        } // switch()
1179
    }
1180
1181
    /**
1182
     * Exports the object as an array.
1183
     *
1184
     * You can specify the key type of the array by passing one of the class
1185
     * type constants.
1186
     *
1187
     * @param     string  $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME,
1188
     *                    TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
1189
     *                    Defaults to TableMap::TYPE_PHPNAME.
1190
     * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
1191
     * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
1192
     * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
1193
     *
1194
     * @return array an associative array containing the field names (as keys) and field values
1195
     */
1196
    public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
1197
    {
1198
1199
        if (isset($alreadyDumpedObjects['BannerImage'][$this->hashCode()])) {
1200
            return '*RECURSION*';
1201
        }
1202
        $alreadyDumpedObjects['BannerImage'][$this->hashCode()] = true;
1203
        $keys = BannerImageTableMap::getFieldNames($keyType);
1204
        $result = array(
1205
            $keys[0] => $this->getId(),
1206
            $keys[1] => $this->getBannerId(),
1207
            $keys[2] => $this->getTarget(),
1208
            $keys[3] => $this->getUrl(),
1209
            $keys[4] => $this->getAllowedPage(),
1210
            $keys[5] => $this->getPosition(),
1211
            $keys[6] => $this->getActiveFrom(),
1212
            $keys[7] => $this->getActiveTo(),
1213
            $keys[8] => $this->getActive(),
1214
            $keys[9] => $this->getPermanent(),
1215
        );
1216
        $virtualColumns = $this->virtualColumns;
1217
        foreach ($virtualColumns as $key => $virtualColumn) {
1218
            $result[$key] = $virtualColumn;
1219
        }
1220
1221
        if ($includeForeignObjects) {
1222
            if (null !== $this->aBanners) {
1223
1224
                switch ($keyType) {
1225
                    case TableMap::TYPE_CAMELNAME:
1226
                        $key = 'banners';
1227
                        break;
1228
                    case TableMap::TYPE_FIELDNAME:
1229
                        $key = 'banners';
1230
                        break;
1231
                    default:
1232
                        $key = 'Banners';
1233
                }
1234
1235
                $result[$key] = $this->aBanners->toArray($keyType, $includeLazyLoadColumns,  $alreadyDumpedObjects, true);
1236
            }
1237
            if (null !== $this->collBannerImageI18ns) {
1238
1239
                switch ($keyType) {
1240
                    case TableMap::TYPE_CAMELNAME:
1241
                        $key = 'bannerImageI18ns';
1242
                        break;
1243
                    case TableMap::TYPE_FIELDNAME:
1244
                        $key = 'banner_image_i18ns';
1245
                        break;
1246
                    default:
1247
                        $key = 'BannerImageI18ns';
1248
                }
1249
1250
                $result[$key] = $this->collBannerImageI18ns->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1251
            }
1252
        }
1253
1254
        return $result;
1255
    }
1256
1257
    /**
1258
     * Sets a field from the object by name passed in as a string.
1259
     *
1260
     * @param  string $name
1261
     * @param  mixed  $value field value
1262
     * @param  string $type The type of fieldname the $name is of:
1263
     *                one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME
1264
     *                TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
1265
     *                Defaults to TableMap::TYPE_PHPNAME.
1266
     * @return $this|\xbanners\models\BannerImage
1267
     */
1268
    public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME)
1269
    {
1270
        $pos = BannerImageTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM);
1271
1272
        return $this->setByPosition($pos, $value);
1273
    }
1274
1275
    /**
1276
     * Sets a field from the object by Position as specified in the xml schema.
1277
     * Zero-based.
1278
     *
1279
     * @param  int $pos position in xml schema
1280
     * @param  mixed $value field value
1281
     * @return $this|\xbanners\models\BannerImage
1282
     */
1283
    public function setByPosition($pos, $value)
1284
    {
1285
        switch ($pos) {
1286
            case 0:
1287
                $this->setId($value);
1288
                break;
1289
            case 1:
1290
                $this->setBannerId($value);
1291
                break;
1292
            case 2:
1293
                $this->setTarget($value);
1294
                break;
1295
            case 3:
1296
                $this->setUrl($value);
1297
                break;
1298
            case 4:
1299
                $this->setAllowedPage($value);
1300
                break;
1301
            case 5:
1302
                $this->setPosition($value);
1303
                break;
1304
            case 6:
1305
                $this->setActiveFrom($value);
1306
                break;
1307
            case 7:
1308
                $this->setActiveTo($value);
1309
                break;
1310
            case 8:
1311
                $this->setActive($value);
1312
                break;
1313
            case 9:
1314
                $this->setPermanent($value);
1315
                break;
1316
        } // switch()
1317
1318
        return $this;
1319
    }
1320
1321
    /**
1322
     * Populates the object using an array.
1323
     *
1324
     * This is particularly useful when populating an object from one of the
1325
     * request arrays (e.g. $_POST).  This method goes through the column
1326
     * names, checking to see whether a matching key exists in populated
1327
     * array. If so the setByName() method is called for that column.
1328
     *
1329
     * You can specify the key type of the array by additionally passing one
1330
     * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME,
1331
     * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
1332
     * The default key type is the column's TableMap::TYPE_PHPNAME.
1333
     *
1334
     * @param      array  $arr     An array to populate the object from.
1335
     * @param      string $keyType The type of keys the array uses.
1336
     * @return void
1337
     */
1338
    public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME)
1339
    {
1340
        $keys = BannerImageTableMap::getFieldNames($keyType);
1341
1342
        if (array_key_exists($keys[0], $arr)) {
1343
            $this->setId($arr[$keys[0]]);
1344
        }
1345
        if (array_key_exists($keys[1], $arr)) {
1346
            $this->setBannerId($arr[$keys[1]]);
1347
        }
1348
        if (array_key_exists($keys[2], $arr)) {
1349
            $this->setTarget($arr[$keys[2]]);
1350
        }
1351
        if (array_key_exists($keys[3], $arr)) {
1352
            $this->setUrl($arr[$keys[3]]);
1353
        }
1354
        if (array_key_exists($keys[4], $arr)) {
1355
            $this->setAllowedPage($arr[$keys[4]]);
1356
        }
1357
        if (array_key_exists($keys[5], $arr)) {
1358
            $this->setPosition($arr[$keys[5]]);
1359
        }
1360
        if (array_key_exists($keys[6], $arr)) {
1361
            $this->setActiveFrom($arr[$keys[6]]);
1362
        }
1363
        if (array_key_exists($keys[7], $arr)) {
1364
            $this->setActiveTo($arr[$keys[7]]);
1365
        }
1366
        if (array_key_exists($keys[8], $arr)) {
1367
            $this->setActive($arr[$keys[8]]);
1368
        }
1369
        if (array_key_exists($keys[9], $arr)) {
1370
            $this->setPermanent($arr[$keys[9]]);
1371
        }
1372
    }
1373
1374
     /**
1375
     * Populate the current object from a string, using a given parser format
1376
     * <code>
1377
     * $book = new Book();
1378
     * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}');
1379
     * </code>
1380
     *
1381
     * You can specify the key type of the array by additionally passing one
1382
     * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME,
1383
     * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
1384
     * The default key type is the column's TableMap::TYPE_PHPNAME.
1385
     *
1386
     * @param mixed $parser A AbstractParser instance,
1387
     *                       or a format name ('XML', 'YAML', 'JSON', 'CSV')
1388
     * @param string $data The source data to import from
1389
     * @param string $keyType The type of keys the array uses.
1390
     *
1391
     * @return $this|\xbanners\models\BannerImage The current object, for fluid interface
1392
     */
1393 View Code Duplication
    public function importFrom($parser, $data, $keyType = TableMap::TYPE_PHPNAME)
1394
    {
1395
        if (!$parser instanceof AbstractParser) {
0 ignored issues
show
The class Propel\Runtime\Parser\AbstractParser does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
1396
            $parser = AbstractParser::getParser($parser);
1397
        }
1398
1399
        $this->fromArray($parser->toArray($data), $keyType);
1400
1401
        return $this;
1402
    }
1403
1404
    /**
1405
     * Build a Criteria object containing the values of all modified columns in this object.
1406
     *
1407
     * @return Criteria The Criteria object containing all modified values.
1408
     */
1409
    public function buildCriteria()
1410
    {
1411
        $criteria = new Criteria(BannerImageTableMap::DATABASE_NAME);
1412
1413
        if ($this->isColumnModified(BannerImageTableMap::COL_ID)) {
1414
            $criteria->add(BannerImageTableMap::COL_ID, $this->id);
1415
        }
1416
        if ($this->isColumnModified(BannerImageTableMap::COL_BANNER_ID)) {
1417
            $criteria->add(BannerImageTableMap::COL_BANNER_ID, $this->banner_id);
1418
        }
1419
        if ($this->isColumnModified(BannerImageTableMap::COL_TARGET)) {
1420
            $criteria->add(BannerImageTableMap::COL_TARGET, $this->target);
1421
        }
1422
        if ($this->isColumnModified(BannerImageTableMap::COL_URL)) {
1423
            $criteria->add(BannerImageTableMap::COL_URL, $this->url);
1424
        }
1425
        if ($this->isColumnModified(BannerImageTableMap::COL_ALLOWED_PAGE)) {
1426
            $criteria->add(BannerImageTableMap::COL_ALLOWED_PAGE, $this->allowed_page);
1427
        }
1428
        if ($this->isColumnModified(BannerImageTableMap::COL_POSITION)) {
1429
            $criteria->add(BannerImageTableMap::COL_POSITION, $this->position);
1430
        }
1431
        if ($this->isColumnModified(BannerImageTableMap::COL_ACTIVE_FROM)) {
1432
            $criteria->add(BannerImageTableMap::COL_ACTIVE_FROM, $this->active_from);
1433
        }
1434
        if ($this->isColumnModified(BannerImageTableMap::COL_ACTIVE_TO)) {
1435
            $criteria->add(BannerImageTableMap::COL_ACTIVE_TO, $this->active_to);
1436
        }
1437
        if ($this->isColumnModified(BannerImageTableMap::COL_ACTIVE)) {
1438
            $criteria->add(BannerImageTableMap::COL_ACTIVE, $this->active);
1439
        }
1440
        if ($this->isColumnModified(BannerImageTableMap::COL_PERMANENT)) {
1441
            $criteria->add(BannerImageTableMap::COL_PERMANENT, $this->permanent);
1442
        }
1443
1444
        return $criteria;
1445
    }
1446
1447
    /**
1448
     * Builds a Criteria object containing the primary key for this object.
1449
     *
1450
     * Unlike buildCriteria() this method includes the primary key values regardless
1451
     * of whether or not they have been modified.
1452
     *
1453
     * @throws LogicException if no primary key is defined
1454
     *
1455
     * @return Criteria The Criteria object containing value(s) for primary key(s).
1456
     */
1457
    public function buildPkeyCriteria()
1458
    {
1459
        $criteria = ChildBannerImageQuery::create();
1460
        $criteria->add(BannerImageTableMap::COL_ID, $this->id);
1461
1462
        return $criteria;
1463
    }
1464
1465
    /**
1466
     * If the primary key is not null, return the hashcode of the
1467
     * primary key. Otherwise, return the hash code of the object.
1468
     *
1469
     * @return int Hashcode
1470
     */
1471 View Code Duplication
    public function hashCode()
1472
    {
1473
        $validPk = null !== $this->getId();
1474
1475
        $validPrimaryKeyFKs = 0;
1476
        $primaryKeyFKs = [];
1477
1478
        if ($validPk) {
1479
            return crc32(json_encode($this->getPrimaryKey(), JSON_UNESCAPED_UNICODE));
1480
        } elseif ($validPrimaryKeyFKs) {
1481
            return crc32(json_encode($primaryKeyFKs, JSON_UNESCAPED_UNICODE));
1482
        }
1483
1484
        return spl_object_hash($this);
1485
    }
1486
1487
    /**
1488
     * Returns the primary key for this object (row).
1489
     * @return int
1490
     */
1491
    public function getPrimaryKey()
1492
    {
1493
        return $this->getId();
1494
    }
1495
1496
    /**
1497
     * Generic method to set the primary key (id column).
1498
     *
1499
     * @param       int $key Primary key.
1500
     * @return void
1501
     */
1502
    public function setPrimaryKey($key)
1503
    {
1504
        $this->setId($key);
1505
    }
1506
1507
    /**
1508
     * Returns true if the primary key for this object is null.
1509
     * @return boolean
1510
     */
1511
    public function isPrimaryKeyNull()
1512
    {
1513
        return null === $this->getId();
1514
    }
1515
1516
    /**
1517
     * Sets contents of passed object to values from current object.
1518
     *
1519
     * If desired, this method can also make copies of all associated (fkey referrers)
1520
     * objects.
1521
     *
1522
     * @param      object $copyObj An object of \xbanners\models\BannerImage (or compatible) type.
1523
     * @param      boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1524
     * @param      boolean $makeNew Whether to reset autoincrement PKs and make the object new.
1525
     * @throws PropelException
1526
     */
1527
    public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
1528
    {
1529
        $copyObj->setBannerId($this->getBannerId());
1530
        $copyObj->setTarget($this->getTarget());
1531
        $copyObj->setUrl($this->getUrl());
1532
        $copyObj->setAllowedPage($this->getAllowedPage());
1533
        $copyObj->setPosition($this->getPosition());
1534
        $copyObj->setActiveFrom($this->getActiveFrom());
1535
        $copyObj->setActiveTo($this->getActiveTo());
1536
        $copyObj->setActive($this->getActive());
1537
        $copyObj->setPermanent($this->getPermanent());
1538
1539
        if ($deepCopy) {
1540
            // important: temporarily setNew(false) because this affects the behavior of
1541
            // the getter/setter methods for fkey referrer objects.
1542
            $copyObj->setNew(false);
1543
1544
            foreach ($this->getBannerImageI18ns() as $relObj) {
1545
                if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1546
                    $copyObj->addBannerImageI18n($relObj->copy($deepCopy));
1547
                }
1548
            }
1549
1550
        } // if ($deepCopy)
1551
1552
        if ($makeNew) {
1553
            $copyObj->setNew(true);
1554
            $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
1555
        }
1556
    }
1557
1558
    /**
1559
     * Makes a copy of this object that will be inserted as a new row in table when saved.
1560
     * It creates a new object filling in the simple attributes, but skipping any primary
1561
     * keys that are defined for the table.
1562
     *
1563
     * If desired, this method can also make copies of all associated (fkey referrers)
1564
     * objects.
1565
     *
1566
     * @param  boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1567
     * @return \xbanners\models\BannerImage Clone of current object.
1568
     * @throws PropelException
1569
     */
1570 View Code Duplication
    public function copy($deepCopy = false)
1571
    {
1572
        // we use get_class(), because this might be a subclass
1573
        $clazz = get_class($this);
1574
        $copyObj = new $clazz();
1575
        $this->copyInto($copyObj, $deepCopy);
1576
1577
        return $copyObj;
1578
    }
1579
1580
    /**
1581
     * Declares an association between this object and a ChildBanners object.
1582
     *
1583
     * @param  ChildBanners $v
1584
     * @return $this|\xbanners\models\BannerImage The current object (for fluent API support)
1585
     * @throws PropelException
1586
     */
1587
    public function setBanners(ChildBanners $v = null)
1588
    {
1589
        if ($v === null) {
1590
            $this->setBannerId(NULL);
1591
        } else {
1592
            $this->setBannerId($v->getId());
1593
        }
1594
1595
        $this->aBanners = $v;
1596
1597
        // Add binding for other direction of this n:n relationship.
1598
        // If this object has already been added to the ChildBanners object, it will not be re-added.
1599
        if ($v !== null) {
1600
            $v->addBannerImage($this);
1601
        }
1602
1603
1604
        return $this;
1605
    }
1606
1607
1608
    /**
1609
     * Get the associated ChildBanners object
1610
     *
1611
     * @param  ConnectionInterface $con Optional Connection object.
1612
     * @return ChildBanners The associated ChildBanners object.
1613
     * @throws PropelException
1614
     */
1615 View Code Duplication
    public function getBanners(ConnectionInterface $con = null)
1616
    {
1617
        if ($this->aBanners === null && ($this->banner_id !== null)) {
1618
            $this->aBanners = ChildBannersQuery::create()->findPk($this->banner_id, $con);
1619
            /* The following can be used additionally to
1620
                guarantee the related object contains a reference
1621
                to this object.  This level of coupling may, however, be
1622
                undesirable since it could result in an only partially populated collection
1623
                in the referenced object.
1624
                $this->aBanners->addBannerImages($this);
1625
             */
1626
        }
1627
1628
        return $this->aBanners;
1629
    }
1630
1631
1632
    /**
1633
     * Initializes a collection based on the name of a relation.
1634
     * Avoids crafting an 'init[$relationName]s' method name
1635
     * that wouldn't work when StandardEnglishPluralizer is used.
1636
     *
1637
     * @param      string $relationName The name of the relation to initialize
1638
     * @return void
1639
     */
1640
    public function initRelation($relationName)
1641
    {
1642
        if ('BannerImageI18n' == $relationName) {
1643
            return $this->initBannerImageI18ns();
1644
        }
1645
    }
1646
1647
    /**
1648
     * Clears out the collBannerImageI18ns collection
1649
     *
1650
     * This does not modify the database; however, it will remove any associated objects, causing
1651
     * them to be refetched by subsequent calls to accessor method.
1652
     *
1653
     * @return void
1654
     * @see        addBannerImageI18ns()
1655
     */
1656
    public function clearBannerImageI18ns()
1657
    {
1658
        $this->collBannerImageI18ns = null; // important to set this to NULL since that means it is uninitialized
1659
    }
1660
1661
    /**
1662
     * Reset is the collBannerImageI18ns collection loaded partially.
1663
     */
1664
    public function resetPartialBannerImageI18ns($v = true)
1665
    {
1666
        $this->collBannerImageI18nsPartial = $v;
1667
    }
1668
1669
    /**
1670
     * Initializes the collBannerImageI18ns collection.
1671
     *
1672
     * By default this just sets the collBannerImageI18ns collection to an empty array (like clearcollBannerImageI18ns());
1673
     * however, you may wish to override this method in your stub class to provide setting appropriate
1674
     * to your application -- for example, setting the initial array to the values stored in database.
1675
     *
1676
     * @param      boolean $overrideExisting If set to true, the method call initializes
1677
     *                                        the collection even if it is not empty
1678
     *
1679
     * @return void
1680
     */
1681 View Code Duplication
    public function initBannerImageI18ns($overrideExisting = true)
1682
    {
1683
        if (null !== $this->collBannerImageI18ns && !$overrideExisting) {
1684
            return;
1685
        }
1686
1687
        $collectionClassName = BannerImageI18nTableMap::getTableMap()->getCollectionClassName();
1688
1689
        $this->collBannerImageI18ns = new $collectionClassName;
1690
        $this->collBannerImageI18ns->setModel('\xbanners\models\BannerImageI18n');
1691
    }
1692
1693
    /**
1694
     * Gets an array of ChildBannerImageI18n objects which contain a foreign key that references this object.
1695
     *
1696
     * If the $criteria is not null, it is used to always fetch the results from the database.
1697
     * Otherwise the results are fetched from the database the first time, then cached.
1698
     * Next time the same method is called without $criteria, the cached collection is returned.
1699
     * If this ChildBannerImage is new, it will return
1700
     * an empty collection or the current collection; the criteria is ignored on a new object.
1701
     *
1702
     * @param      Criteria $criteria optional Criteria object to narrow the query
1703
     * @param      ConnectionInterface $con optional connection object
1704
     * @return ObjectCollection|ChildBannerImageI18n[] List of ChildBannerImageI18n objects
1705
     * @throws PropelException
1706
     */
1707 View Code Duplication
    public function getBannerImageI18ns(Criteria $criteria = null, ConnectionInterface $con = null)
1708
    {
1709
        $partial = $this->collBannerImageI18nsPartial && !$this->isNew();
1710
        if (null === $this->collBannerImageI18ns || null !== $criteria  || $partial) {
1711
            if ($this->isNew() && null === $this->collBannerImageI18ns) {
1712
                // return empty collection
1713
                $this->initBannerImageI18ns();
1714
            } else {
1715
                $collBannerImageI18ns = ChildBannerImageI18nQuery::create(null, $criteria)
1716
                    ->filterByBannerImage($this)
1717
                    ->find($con);
1718
1719
                if (null !== $criteria) {
1720
                    if (false !== $this->collBannerImageI18nsPartial && count($collBannerImageI18ns)) {
1721
                        $this->initBannerImageI18ns(false);
1722
1723
                        foreach ($collBannerImageI18ns as $obj) {
1724
                            if (false == $this->collBannerImageI18ns->contains($obj)) {
1725
                                $this->collBannerImageI18ns->append($obj);
1726
                            }
1727
                        }
1728
1729
                        $this->collBannerImageI18nsPartial = true;
1730
                    }
1731
1732
                    return $collBannerImageI18ns;
1733
                }
1734
1735
                if ($partial && $this->collBannerImageI18ns) {
1736
                    foreach ($this->collBannerImageI18ns as $obj) {
1737
                        if ($obj->isNew()) {
1738
                            $collBannerImageI18ns[] = $obj;
1739
                        }
1740
                    }
1741
                }
1742
1743
                $this->collBannerImageI18ns = $collBannerImageI18ns;
1744
                $this->collBannerImageI18nsPartial = false;
1745
            }
1746
        }
1747
1748
        return $this->collBannerImageI18ns;
1749
    }
1750
1751
    /**
1752
     * Sets a collection of ChildBannerImageI18n objects related by a one-to-many relationship
1753
     * to the current object.
1754
     * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
1755
     * and new objects from the given Propel collection.
1756
     *
1757
     * @param      Collection $bannerImageI18ns A Propel collection.
1758
     * @param      ConnectionInterface $con Optional connection object
1759
     * @return $this|ChildBannerImage The current object (for fluent API support)
1760
     */
1761
    public function setBannerImageI18ns(Collection $bannerImageI18ns, ConnectionInterface $con = null)
1762
    {
1763
        /** @var ChildBannerImageI18n[] $bannerImageI18nsToDelete */
1764
        $bannerImageI18nsToDelete = $this->getBannerImageI18ns(new Criteria(), $con)->diff($bannerImageI18ns);
1765
1766
1767
        //since at least one column in the foreign key is at the same time a PK
1768
        //we can not just set a PK to NULL in the lines below. We have to store
1769
        //a backup of all values, so we are able to manipulate these items based on the onDelete value later.
1770
        $this->bannerImageI18nsScheduledForDeletion = clone $bannerImageI18nsToDelete;
1771
1772
        foreach ($bannerImageI18nsToDelete as $bannerImageI18nRemoved) {
1773
            $bannerImageI18nRemoved->setBannerImage(null);
1774
        }
1775
1776
        $this->collBannerImageI18ns = null;
1777
        foreach ($bannerImageI18ns as $bannerImageI18n) {
1778
            $this->addBannerImageI18n($bannerImageI18n);
1779
        }
1780
1781
        $this->collBannerImageI18ns = $bannerImageI18ns;
1782
        $this->collBannerImageI18nsPartial = false;
1783
1784
        return $this;
1785
    }
1786
1787
    /**
1788
     * Returns the number of related BannerImageI18n objects.
1789
     *
1790
     * @param      Criteria $criteria
1791
     * @param      boolean $distinct
1792
     * @param      ConnectionInterface $con
1793
     * @return int             Count of related BannerImageI18n objects.
1794
     * @throws PropelException
1795
     */
1796 View Code Duplication
    public function countBannerImageI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
1797
    {
1798
        $partial = $this->collBannerImageI18nsPartial && !$this->isNew();
1799
        if (null === $this->collBannerImageI18ns || null !== $criteria || $partial) {
1800
            if ($this->isNew() && null === $this->collBannerImageI18ns) {
1801
                return 0;
1802
            }
1803
1804
            if ($partial && !$criteria) {
1805
                return count($this->getBannerImageI18ns());
1806
            }
1807
1808
            $query = ChildBannerImageI18nQuery::create(null, $criteria);
1809
            if ($distinct) {
1810
                $query->distinct();
1811
            }
1812
1813
            return $query
1814
                ->filterByBannerImage($this)
1815
                ->count($con);
1816
        }
1817
1818
        return count($this->collBannerImageI18ns);
1819
    }
1820
1821
    /**
1822
     * Method called to associate a ChildBannerImageI18n object to this object
1823
     * through the ChildBannerImageI18n foreign key attribute.
1824
     *
1825
     * @param  ChildBannerImageI18n $l ChildBannerImageI18n
1826
     * @return $this|\xbanners\models\BannerImage The current object (for fluent API support)
1827
     */
1828 View Code Duplication
    public function addBannerImageI18n(ChildBannerImageI18n $l)
1829
    {
1830
        if ($l && $locale = $l->getLocale()) {
1831
            $this->setLocale($locale);
1832
            $this->currentTranslations[$locale] = $l;
1833
        }
1834
        if ($this->collBannerImageI18ns === null) {
1835
            $this->initBannerImageI18ns();
1836
            $this->collBannerImageI18nsPartial = true;
1837
        }
1838
1839
        if (!$this->collBannerImageI18ns->contains($l)) {
1840
            $this->doAddBannerImageI18n($l);
1841
1842
            if ($this->bannerImageI18nsScheduledForDeletion and $this->bannerImageI18nsScheduledForDeletion->contains($l)) {
1843
                $this->bannerImageI18nsScheduledForDeletion->remove($this->bannerImageI18nsScheduledForDeletion->search($l));
1844
            }
1845
        }
1846
1847
        return $this;
1848
    }
1849
1850
    /**
1851
     * @param ChildBannerImageI18n $bannerImageI18n The ChildBannerImageI18n object to add.
1852
     */
1853
    protected function doAddBannerImageI18n(ChildBannerImageI18n $bannerImageI18n)
1854
    {
1855
        $this->collBannerImageI18ns[]= $bannerImageI18n;
1856
        $bannerImageI18n->setBannerImage($this);
1857
    }
1858
1859
    /**
1860
     * @param  ChildBannerImageI18n $bannerImageI18n The ChildBannerImageI18n object to remove.
1861
     * @return $this|ChildBannerImage The current object (for fluent API support)
1862
     */
1863
    public function removeBannerImageI18n(ChildBannerImageI18n $bannerImageI18n)
1864
    {
1865
        if ($this->getBannerImageI18ns()->contains($bannerImageI18n)) {
1866
            $pos = $this->collBannerImageI18ns->search($bannerImageI18n);
1867
            $this->collBannerImageI18ns->remove($pos);
1868
            if (null === $this->bannerImageI18nsScheduledForDeletion) {
1869
                $this->bannerImageI18nsScheduledForDeletion = clone $this->collBannerImageI18ns;
1870
                $this->bannerImageI18nsScheduledForDeletion->clear();
1871
            }
1872
            $this->bannerImageI18nsScheduledForDeletion[]= clone $bannerImageI18n;
1873
            $bannerImageI18n->setBannerImage(null);
1874
        }
1875
1876
        return $this;
1877
    }
1878
1879
    /**
1880
     * Clears the current object, sets all attributes to their default values and removes
1881
     * outgoing references as well as back-references (from other objects to this one. Results probably in a database
1882
     * change of those foreign objects when you call `save` there).
1883
     */
1884
    public function clear()
1885
    {
1886
        if (null !== $this->aBanners) {
1887
            $this->aBanners->removeBannerImage($this);
1888
        }
1889
        $this->id = null;
1890
        $this->banner_id = null;
1891
        $this->target = null;
1892
        $this->url = null;
1893
        $this->allowed_page = null;
1894
        $this->position = null;
1895
        $this->active_from = null;
1896
        $this->active_to = null;
1897
        $this->active = null;
1898
        $this->permanent = null;
1899
        $this->alreadyInSave = false;
1900
        $this->clearAllReferences();
1901
        $this->resetModified();
1902
        $this->setNew(true);
1903
        $this->setDeleted(false);
1904
    }
1905
1906
    /**
1907
     * Resets all references and back-references to other model objects or collections of model objects.
1908
     *
1909
     * This method is used to reset all php object references (not the actual reference in the database).
1910
     * Necessary for object serialisation.
1911
     *
1912
     * @param      boolean $deep Whether to also clear the references on all referrer objects.
1913
     */
1914
    public function clearAllReferences($deep = false)
1915
    {
1916
        if ($deep) {
1917
            if ($this->collBannerImageI18ns) {
1918
                foreach ($this->collBannerImageI18ns as $o) {
1919
                    $o->clearAllReferences($deep);
1920
                }
1921
            }
1922
        } // if ($deep)
1923
1924
        // i18n behavior
1925
        $this->currentLocale = 'ru';
1926
        $this->currentTranslations = null;
1927
1928
        $this->collBannerImageI18ns = null;
1929
        $this->aBanners = null;
1930
    }
1931
1932
    /**
1933
     * Return the string representation of this object
1934
     *
1935
     * @return string
1936
     */
1937
    public function __toString()
1938
    {
1939
        return (string) $this->exportTo(BannerImageTableMap::DEFAULT_STRING_FORMAT);
1940
    }
1941
1942
    // i18n behavior
1943
1944
    /**
1945
     * Sets the locale for translations
1946
     *
1947
     * @param     string $locale Locale to use for the translation, e.g. 'fr_FR'
1948
     *
1949
     * @return    $this|ChildBannerImage The current object (for fluent API support)
1950
     */
1951
    public function setLocale($locale = 'ru')
1952
    {
1953
        $this->currentLocale = $locale;
1954
1955
        return $this;
1956
    }
1957
1958
    /**
1959
     * Gets the locale for translations
1960
     *
1961
     * @return    string $locale Locale to use for the translation, e.g. 'fr_FR'
1962
     */
1963
    public function getLocale()
1964
    {
1965
        return $this->currentLocale;
1966
    }
1967
1968
    /**
1969
     * Returns the current translation for a given locale
1970
     *
1971
     * @param     string $locale Locale to use for the translation, e.g. 'fr_FR'
1972
     * @param     ConnectionInterface $con an optional connection object
1973
     *
1974
     * @return ChildBannerImageI18n */
1975 View Code Duplication
    public function getTranslation($locale = 'ru', ConnectionInterface $con = null)
1976
    {
1977
        if (!isset($this->currentTranslations[$locale])) {
1978
            if (null !== $this->collBannerImageI18ns) {
1979
                foreach ($this->collBannerImageI18ns as $translation) {
1980
                    if ($translation->getLocale() == $locale) {
1981
                        $this->currentTranslations[$locale] = $translation;
1982
1983
                        return $translation;
1984
                    }
1985
                }
1986
            }
1987
            if ($this->isNew()) {
1988
                $translation = new ChildBannerImageI18n();
1989
                $translation->setLocale($locale);
1990
            } else {
1991
                $translation = ChildBannerImageI18nQuery::create()
1992
                    ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
1993
                    ->findOneOrCreate($con);
1994
                $this->currentTranslations[$locale] = $translation;
1995
            }
1996
            $this->addBannerImageI18n($translation);
1997
        }
1998
1999
        return $this->currentTranslations[$locale];
2000
    }
2001
2002
    /**
2003
     * Remove the translation for a given locale
2004
     *
2005
     * @param     string $locale Locale to use for the translation, e.g. 'fr_FR'
2006
     * @param     ConnectionInterface $con an optional connection object
2007
     *
2008
     * @return    $this|ChildBannerImage The current object (for fluent API support)
2009
     */
2010 View Code Duplication
    public function removeTranslation($locale = 'ru', ConnectionInterface $con = null)
2011
    {
2012
        if (!$this->isNew()) {
2013
            ChildBannerImageI18nQuery::create()
2014
                ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
2015
                ->delete($con);
2016
        }
2017
        if (isset($this->currentTranslations[$locale])) {
2018
            unset($this->currentTranslations[$locale]);
2019
        }
2020
        foreach ($this->collBannerImageI18ns as $key => $translation) {
2021
            if ($translation->getLocale() == $locale) {
2022
                unset($this->collBannerImageI18ns[$key]);
2023
                break;
2024
            }
2025
        }
2026
2027
        return $this;
2028
    }
2029
2030
    /**
2031
     * Returns the current translation
2032
     *
2033
     * @param     ConnectionInterface $con an optional connection object
2034
     *
2035
     * @return ChildBannerImageI18n */
2036
    public function getCurrentTranslation(ConnectionInterface $con = null)
2037
    {
2038
        return $this->getTranslation($this->getLocale(), $con);
2039
    }
2040
2041
2042
        /**
2043
         * Get the [src] column value.
2044
         *
2045
         * @return string
2046
         */
2047
        public function getSrc()
2048
        {
2049
        return $this->getCurrentTranslation()->getSrc();
2050
    }
2051
2052
2053
        /**
2054
         * Set the value of [src] column.
2055
         *
2056
         * @param string $v new value
2057
         * @return $this|\xbanners\models\BannerImageI18n The current object (for fluent API support)
2058
         */
2059
        public function setSrc($v)
2060
        {    $this->getCurrentTranslation()->setSrc($v);
2061
2062
        return $this;
2063
    }
2064
2065
2066
        /**
2067
         * Get the [name] column value.
2068
         *
2069
         * @return string
2070
         */
2071
        public function getName()
2072
        {
2073
        return $this->getCurrentTranslation()->getName();
2074
    }
2075
2076
2077
        /**
2078
         * Set the value of [name] column.
2079
         *
2080
         * @param string $v new value
2081
         * @return $this|\xbanners\models\BannerImageI18n The current object (for fluent API support)
2082
         */
2083
        public function setName($v)
2084
        {    $this->getCurrentTranslation()->setName($v);
2085
2086
        return $this;
2087
    }
2088
2089
2090
        /**
2091
         * Get the [clicks] column value.
2092
         *
2093
         * @return int
2094
         */
2095
        public function getClicks()
2096
        {
2097
        return $this->getCurrentTranslation()->getClicks();
2098
    }
2099
2100
2101
        /**
2102
         * Set the value of [clicks] column.
2103
         *
2104
         * @param int $v new value
2105
         * @return $this|\xbanners\models\BannerImageI18n The current object (for fluent API support)
2106
         */
2107
        public function setClicks($v)
2108
        {    $this->getCurrentTranslation()->setClicks($v);
2109
2110
        return $this;
2111
    }
2112
2113
2114
        /**
2115
         * Get the [description] column value.
2116
         *
2117
         * @return string
2118
         */
2119
        public function getDescription()
2120
        {
2121
        return $this->getCurrentTranslation()->getDescription();
2122
    }
2123
2124
2125
        /**
2126
         * Set the value of [description] column.
2127
         *
2128
         * @param string $v new value
2129
         * @return $this|\xbanners\models\BannerImageI18n The current object (for fluent API support)
2130
         */
2131
        public function setDescription($v)
2132
        {    $this->getCurrentTranslation()->setDescription($v);
2133
2134
        return $this;
2135
    }
2136
2137
    /**
2138
     * Code to be run before persisting the object
2139
     * @param  ConnectionInterface $con
2140
     * @return boolean
2141
     */
2142
    public function preSave(ConnectionInterface $con = null)
2143
    {
2144
        if (is_callable('parent::preSave')) {
2145
            return parent::preSave($con);
2146
        }
2147
        return true;
2148
    }
2149
2150
    /**
2151
     * Code to be run after persisting the object
2152
     * @param ConnectionInterface $con
2153
     */
2154
    public function postSave(ConnectionInterface $con = null)
2155
    {
2156
        if (is_callable('parent::postSave')) {
2157
            parent::postSave($con);
2158
        }
2159
    }
2160
2161
    /**
2162
     * Code to be run before inserting to database
2163
     * @param  ConnectionInterface $con
2164
     * @return boolean
2165
     */
2166
    public function preInsert(ConnectionInterface $con = null)
2167
    {
2168
        if (is_callable('parent::preInsert')) {
2169
            return parent::preInsert($con);
2170
        }
2171
        return true;
2172
    }
2173
2174
    /**
2175
     * Code to be run after inserting to database
2176
     * @param ConnectionInterface $con
2177
     */
2178
    public function postInsert(ConnectionInterface $con = null)
2179
    {
2180
        if (is_callable('parent::postInsert')) {
2181
            parent::postInsert($con);
2182
        }
2183
    }
2184
2185
    /**
2186
     * Code to be run before updating the object in database
2187
     * @param  ConnectionInterface $con
2188
     * @return boolean
2189
     */
2190
    public function preUpdate(ConnectionInterface $con = null)
2191
    {
2192
        if (is_callable('parent::preUpdate')) {
2193
            return parent::preUpdate($con);
2194
        }
2195
        return true;
2196
    }
2197
2198
    /**
2199
     * Code to be run after updating the object in database
2200
     * @param ConnectionInterface $con
2201
     */
2202
    public function postUpdate(ConnectionInterface $con = null)
2203
    {
2204
        if (is_callable('parent::postUpdate')) {
2205
            parent::postUpdate($con);
2206
        }
2207
    }
2208
2209
    /**
2210
     * Code to be run before deleting the object in database
2211
     * @param  ConnectionInterface $con
2212
     * @return boolean
2213
     */
2214
    public function preDelete(ConnectionInterface $con = null)
2215
    {
2216
        if (is_callable('parent::preDelete')) {
2217
            return parent::preDelete($con);
2218
        }
2219
        return true;
2220
    }
2221
2222
    /**
2223
     * Code to be run after deleting the object in database
2224
     * @param ConnectionInterface $con
2225
     */
2226
    public function postDelete(ConnectionInterface $con = null)
2227
    {
2228
        if (is_callable('parent::postDelete')) {
2229
            parent::postDelete($con);
2230
        }
2231
    }
2232
2233
2234
    /**
2235
     * Derived method to catches calls to undefined methods.
2236
     *
2237
     * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
2238
     * Allows to define default __call() behavior if you overwrite __call()
2239
     *
2240
     * @param string $name
2241
     * @param mixed  $params
2242
     *
2243
     * @return array|string
2244
     */
2245 View Code Duplication
    public function __call($name, $params)
2246
    {
2247
        if (0 === strpos($name, 'get')) {
2248
            $virtualColumn = substr($name, 3);
2249
            if ($this->hasVirtualColumn($virtualColumn)) {
2250
                return $this->getVirtualColumn($virtualColumn);
2251
            }
2252
2253
            $virtualColumn = lcfirst($virtualColumn);
2254
            if ($this->hasVirtualColumn($virtualColumn)) {
2255
                return $this->getVirtualColumn($virtualColumn);
2256
            }
2257
        }
2258
2259
        if (0 === strpos($name, 'from')) {
2260
            $format = substr($name, 4);
2261
2262
            return $this->importFrom($format, reset($params));
2263
        }
2264
2265
        if (0 === strpos($name, 'to')) {
2266
            $format = substr($name, 2);
2267
            $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true;
2268
2269
            return $this->exportTo($format, $includeLazyLoadColumns);
2270
        }
2271
2272
        throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
2273
    }
2274
2275
}
2276