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 CMSFactory\PropelBaseModelClass; |
||
8 | use Propel\Runtime\Propel; |
||
9 | use Propel\Runtime\ActiveQuery\Criteria; |
||
10 | use Propel\Runtime\ActiveQuery\ModelCriteria; |
||
11 | use Propel\Runtime\ActiveRecord\ActiveRecordInterface; |
||
12 | use Propel\Runtime\Collection\Collection; |
||
13 | use Propel\Runtime\Collection\ObjectCollection; |
||
14 | use Propel\Runtime\Connection\ConnectionInterface; |
||
15 | use Propel\Runtime\Exception\BadMethodCallException; |
||
16 | use Propel\Runtime\Exception\LogicException; |
||
17 | use Propel\Runtime\Exception\PropelException; |
||
18 | use Propel\Runtime\Map\TableMap; |
||
19 | use Propel\Runtime\Parser\AbstractParser; |
||
20 | use xbanners\models\BannerImage as ChildBannerImage; |
||
21 | use xbanners\models\BannerImageQuery as ChildBannerImageQuery; |
||
22 | use xbanners\models\Banners as ChildBanners; |
||
23 | use xbanners\models\BannersI18n as ChildBannersI18n; |
||
24 | use xbanners\models\BannersI18nQuery as ChildBannersI18nQuery; |
||
25 | use xbanners\models\BannersQuery as ChildBannersQuery; |
||
26 | use xbanners\models\Map\BannerImageTableMap; |
||
27 | use xbanners\models\Map\BannersI18nTableMap; |
||
28 | use xbanners\models\Map\BannersTableMap; |
||
29 | |||
30 | /** |
||
31 | * Base class that represents a row from the 'banners' table. |
||
32 | * |
||
33 | * |
||
34 | * |
||
35 | * @package propel.generator.xbanners.models.Base |
||
36 | */ |
||
37 | abstract class Banners extends PropelBaseModelClass implements ActiveRecordInterface |
||
38 | { |
||
39 | /** |
||
40 | * TableMap class name |
||
41 | */ |
||
42 | const TABLE_MAP = '\\xbanners\\models\\Map\\BannersTableMap'; |
||
43 | |||
44 | |||
45 | /** |
||
46 | * attribute to determine if this object has previously been saved. |
||
47 | * @var boolean |
||
48 | */ |
||
49 | protected $new = true; |
||
50 | |||
51 | /** |
||
52 | * attribute to determine whether this object has been deleted. |
||
53 | * @var boolean |
||
54 | */ |
||
55 | protected $deleted = false; |
||
56 | |||
57 | /** |
||
58 | * The columns that have been modified in current object. |
||
59 | * Tracking modified columns allows us to only update modified columns. |
||
60 | * @var array |
||
61 | */ |
||
62 | protected $modifiedColumns = array(); |
||
63 | |||
64 | /** |
||
65 | * The (virtual) columns that are added at runtime |
||
66 | * The formatters can add supplementary columns based on a resultset |
||
67 | * @var array |
||
68 | */ |
||
69 | protected $virtualColumns = array(); |
||
70 | |||
71 | /** |
||
72 | * The value for the id field. |
||
73 | * |
||
74 | * @var int |
||
75 | */ |
||
76 | protected $id; |
||
77 | |||
78 | /** |
||
79 | * The value for the place field. |
||
80 | * |
||
81 | * @var string |
||
82 | */ |
||
83 | protected $place; |
||
84 | |||
85 | /** |
||
86 | * The value for the width field. |
||
87 | * |
||
88 | * @var int |
||
89 | */ |
||
90 | protected $width; |
||
91 | |||
92 | /** |
||
93 | * The value for the height field. |
||
94 | * |
||
95 | * @var int |
||
96 | */ |
||
97 | protected $height; |
||
98 | |||
99 | /** |
||
100 | * The value for the effects field. |
||
101 | * |
||
102 | * @var string |
||
103 | */ |
||
104 | protected $effects; |
||
105 | |||
106 | /** |
||
107 | * The value for the page_type field. |
||
108 | * |
||
109 | * @var string |
||
110 | */ |
||
111 | protected $page_type; |
||
112 | |||
113 | /** |
||
114 | * @var ObjectCollection|ChildBannerImage[] Collection to store aggregation of ChildBannerImage objects. |
||
115 | */ |
||
116 | protected $collBannerImages; |
||
117 | protected $collBannerImagesPartial; |
||
118 | |||
119 | /** |
||
120 | * @var ObjectCollection|ChildBannersI18n[] Collection to store aggregation of ChildBannersI18n objects. |
||
121 | */ |
||
122 | protected $collBannersI18ns; |
||
123 | protected $collBannersI18nsPartial; |
||
124 | |||
125 | /** |
||
126 | * Flag to prevent endless save loop, if this object is referenced |
||
127 | * by another object which falls in this transaction. |
||
128 | * |
||
129 | * @var boolean |
||
130 | */ |
||
131 | protected $alreadyInSave = false; |
||
132 | |||
133 | // i18n behavior |
||
134 | |||
135 | /** |
||
136 | * Current locale |
||
137 | * @var string |
||
138 | */ |
||
139 | protected $currentLocale = 'ru'; |
||
140 | |||
141 | /** |
||
142 | * Current translation objects |
||
143 | * @var array[ChildBannersI18n] |
||
144 | */ |
||
145 | protected $currentTranslations; |
||
146 | |||
147 | /** |
||
148 | * An array of objects scheduled for deletion. |
||
149 | * @var ObjectCollection|ChildBannerImage[] |
||
150 | */ |
||
151 | protected $bannerImagesScheduledForDeletion = null; |
||
152 | |||
153 | /** |
||
154 | * An array of objects scheduled for deletion. |
||
155 | * @var ObjectCollection|ChildBannersI18n[] |
||
156 | */ |
||
157 | protected $bannersI18nsScheduledForDeletion = null; |
||
158 | |||
159 | /** |
||
160 | * Initializes internal state of xbanners\models\Base\Banners object. |
||
161 | */ |
||
162 | public function __construct() |
||
163 | { |
||
164 | } |
||
165 | |||
166 | /** |
||
167 | * Returns whether the object has been modified. |
||
168 | * |
||
169 | * @return boolean True if the object has been modified. |
||
170 | */ |
||
171 | public function isModified() |
||
172 | { |
||
173 | return !!$this->modifiedColumns; |
||
174 | } |
||
175 | |||
176 | /** |
||
177 | * Has specified column been modified? |
||
178 | * |
||
179 | * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID |
||
180 | * @return boolean True if $col has been modified. |
||
181 | */ |
||
182 | public function isColumnModified($col) |
||
183 | { |
||
184 | return $this->modifiedColumns && isset($this->modifiedColumns[$col]); |
||
185 | } |
||
186 | |||
187 | /** |
||
188 | * Get the columns that have been modified in this object. |
||
189 | * @return array A unique list of the modified column names for this object. |
||
190 | */ |
||
191 | public function getModifiedColumns() |
||
192 | { |
||
193 | return $this->modifiedColumns ? array_keys($this->modifiedColumns) : []; |
||
194 | } |
||
195 | |||
196 | /** |
||
197 | * Returns whether the object has ever been saved. This will |
||
198 | * be false, if the object was retrieved from storage or was created |
||
199 | * and then saved. |
||
200 | * |
||
201 | * @return boolean true, if the object has never been persisted. |
||
202 | */ |
||
203 | public function isNew() |
||
204 | { |
||
205 | return $this->new; |
||
206 | } |
||
207 | |||
208 | /** |
||
209 | * Setter for the isNew attribute. This method will be called |
||
210 | * by Propel-generated children and objects. |
||
211 | * |
||
212 | * @param boolean $b the state of the object. |
||
213 | */ |
||
214 | public function setNew($b) |
||
215 | { |
||
216 | $this->new = (boolean) $b; |
||
217 | } |
||
218 | |||
219 | /** |
||
220 | * Whether this object has been deleted. |
||
221 | * @return boolean The deleted state of this object. |
||
222 | */ |
||
223 | public function isDeleted() |
||
224 | { |
||
225 | return $this->deleted; |
||
226 | } |
||
227 | |||
228 | /** |
||
229 | * Specify whether this object has been deleted. |
||
230 | * @param boolean $b The deleted state of this object. |
||
231 | * @return void |
||
232 | */ |
||
233 | public function setDeleted($b) |
||
234 | { |
||
235 | $this->deleted = (boolean) $b; |
||
236 | } |
||
237 | |||
238 | /** |
||
239 | * Sets the modified state for the object to be false. |
||
240 | * @param string $col If supplied, only the specified column is reset. |
||
241 | * @return void |
||
242 | */ |
||
243 | View Code Duplication | public function resetModified($col = null) |
|
244 | { |
||
245 | if (null !== $col) { |
||
246 | if (isset($this->modifiedColumns[$col])) { |
||
247 | unset($this->modifiedColumns[$col]); |
||
248 | } |
||
249 | } else { |
||
250 | $this->modifiedColumns = array(); |
||
251 | } |
||
252 | } |
||
253 | |||
254 | /** |
||
255 | * Compares this with another <code>Banners</code> instance. If |
||
256 | * <code>obj</code> is an instance of <code>Banners</code>, delegates to |
||
257 | * <code>equals(Banners)</code>. Otherwise, returns <code>false</code>. |
||
258 | * |
||
259 | * @param mixed $obj The object to compare to. |
||
260 | * @return boolean Whether equal to the object specified. |
||
261 | */ |
||
262 | View Code Duplication | public function equals($obj) |
|
263 | { |
||
264 | if (!$obj instanceof static) { |
||
265 | return false; |
||
266 | } |
||
267 | |||
268 | if ($this === $obj) { |
||
269 | return true; |
||
270 | } |
||
271 | |||
272 | if (null === $this->getPrimaryKey() || null === $obj->getPrimaryKey()) { |
||
273 | return false; |
||
274 | } |
||
275 | |||
276 | return $this->getPrimaryKey() === $obj->getPrimaryKey(); |
||
277 | } |
||
278 | |||
279 | /** |
||
280 | * Get the associative array of the virtual columns in this object |
||
281 | * |
||
282 | * @return array |
||
283 | */ |
||
284 | public function getVirtualColumns() |
||
285 | { |
||
286 | return $this->virtualColumns; |
||
287 | } |
||
288 | |||
289 | /** |
||
290 | * Checks the existence of a virtual column in this object |
||
291 | * |
||
292 | * @param string $name The virtual column name |
||
293 | * @return boolean |
||
294 | */ |
||
295 | public function hasVirtualColumn($name) |
||
296 | { |
||
297 | return array_key_exists($name, $this->virtualColumns); |
||
298 | } |
||
299 | |||
300 | /** |
||
301 | * Get the value of a virtual column in this object |
||
302 | * |
||
303 | * @param string $name The virtual column name |
||
304 | * @return mixed |
||
305 | * |
||
306 | * @throws PropelException |
||
307 | */ |
||
308 | View Code Duplication | public function getVirtualColumn($name) |
|
309 | { |
||
310 | if (!$this->hasVirtualColumn($name)) { |
||
311 | throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); |
||
312 | } |
||
313 | |||
314 | return $this->virtualColumns[$name]; |
||
315 | } |
||
316 | |||
317 | /** |
||
318 | * Set the value of a virtual column in this object |
||
319 | * |
||
320 | * @param string $name The virtual column name |
||
321 | * @param mixed $value The value to give to the virtual column |
||
322 | * |
||
323 | * @return $this|Banners The current object, for fluid interface |
||
324 | */ |
||
325 | public function setVirtualColumn($name, $value) |
||
326 | { |
||
327 | $this->virtualColumns[$name] = $value; |
||
328 | |||
329 | return $this; |
||
330 | } |
||
331 | |||
332 | /** |
||
333 | * Logs a message using Propel::log(). |
||
334 | * |
||
335 | * @param string $msg |
||
336 | * @param int $priority One of the Propel::LOG_* logging levels |
||
337 | * @return boolean |
||
338 | */ |
||
339 | protected function log($msg, $priority = Propel::LOG_INFO) |
||
340 | { |
||
341 | return Propel::log(get_class($this) . ': ' . $msg, $priority); |
||
342 | } |
||
343 | |||
344 | /** |
||
345 | * Export the current object properties to a string, using a given parser format |
||
346 | * <code> |
||
347 | * $book = BookQuery::create()->findPk(9012); |
||
348 | * echo $book->exportTo('JSON'); |
||
349 | * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
||
350 | * </code> |
||
351 | * |
||
352 | * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') |
||
353 | * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. |
||
354 | * @return string The exported data |
||
355 | */ |
||
356 | View Code Duplication | public function exportTo($parser, $includeLazyLoadColumns = true) |
|
357 | { |
||
358 | if (!$parser instanceof AbstractParser) { |
||
359 | $parser = AbstractParser::getParser($parser); |
||
360 | } |
||
361 | |||
362 | return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); |
||
363 | } |
||
364 | |||
365 | /** |
||
366 | * Clean up internal collections prior to serializing |
||
367 | * Avoids recursive loops that turn into segmentation faults when serializing |
||
368 | */ |
||
369 | View Code Duplication | public function __sleep() |
|
370 | { |
||
371 | $this->clearAllReferences(); |
||
372 | |||
373 | $cls = new \ReflectionClass($this); |
||
374 | $propertyNames = []; |
||
375 | $serializableProperties = array_diff($cls->getProperties(), $cls->getProperties(\ReflectionProperty::IS_STATIC)); |
||
376 | |||
377 | foreach($serializableProperties as $property) { |
||
378 | $propertyNames[] = $property->getName(); |
||
379 | } |
||
380 | |||
381 | return $propertyNames; |
||
382 | } |
||
383 | |||
384 | /** |
||
385 | * Get the [id] column value. |
||
386 | * |
||
387 | * @return int |
||
388 | */ |
||
389 | public function getId() |
||
390 | { |
||
391 | return $this->id; |
||
392 | } |
||
393 | |||
394 | /** |
||
395 | * Get the [place] column value. |
||
396 | * |
||
397 | * @return string |
||
398 | */ |
||
399 | public function getPlace() |
||
400 | { |
||
401 | return $this->place; |
||
402 | } |
||
403 | |||
404 | /** |
||
405 | * Get the [width] column value. |
||
406 | * |
||
407 | * @return int |
||
408 | */ |
||
409 | public function getWidth() |
||
410 | { |
||
411 | return $this->width; |
||
412 | } |
||
413 | |||
414 | /** |
||
415 | * Get the [height] column value. |
||
416 | * |
||
417 | * @return int |
||
418 | */ |
||
419 | public function getHeight() |
||
420 | { |
||
421 | return $this->height; |
||
422 | } |
||
423 | |||
424 | /** |
||
425 | * Get the [effects] column value. |
||
426 | * |
||
427 | * @return string |
||
428 | */ |
||
429 | public function getEffects() |
||
430 | { |
||
431 | return $this->effects; |
||
432 | } |
||
433 | |||
434 | /** |
||
435 | * Get the [page_type] column value. |
||
436 | * |
||
437 | * @return string |
||
438 | */ |
||
439 | public function getPageType() |
||
440 | { |
||
441 | return $this->page_type; |
||
442 | } |
||
443 | |||
444 | /** |
||
445 | * Set the value of [id] column. |
||
446 | * |
||
447 | * @param int $v new value |
||
448 | * @return $this|\xbanners\models\Banners The current object (for fluent API support) |
||
449 | */ |
||
450 | View Code Duplication | public function setId($v) |
|
451 | { |
||
452 | if ($v !== null) { |
||
453 | $v = (int) $v; |
||
454 | } |
||
455 | |||
456 | if ($this->id !== $v) { |
||
457 | $this->id = $v; |
||
458 | $this->modifiedColumns[BannersTableMap::COL_ID] = true; |
||
459 | } |
||
460 | |||
461 | return $this; |
||
462 | } // setId() |
||
463 | |||
464 | /** |
||
465 | * Set the value of [place] column. |
||
466 | * |
||
467 | * @param string $v new value |
||
468 | * @return $this|\xbanners\models\Banners The current object (for fluent API support) |
||
469 | */ |
||
470 | View Code Duplication | public function setPlace($v) |
|
471 | { |
||
472 | if ($v !== null) { |
||
473 | $v = (string) $v; |
||
474 | } |
||
475 | |||
476 | if ($this->place !== $v) { |
||
477 | $this->place = $v; |
||
478 | $this->modifiedColumns[BannersTableMap::COL_PLACE] = true; |
||
479 | } |
||
480 | |||
481 | return $this; |
||
482 | } // setPlace() |
||
483 | |||
484 | /** |
||
485 | * Set the value of [width] column. |
||
486 | * |
||
487 | * @param int $v new value |
||
488 | * @return $this|\xbanners\models\Banners The current object (for fluent API support) |
||
489 | */ |
||
490 | View Code Duplication | public function setWidth($v) |
|
491 | { |
||
492 | if ($v !== null) { |
||
493 | $v = (int) $v; |
||
494 | } |
||
495 | |||
496 | if ($this->width !== $v) { |
||
497 | $this->width = $v; |
||
498 | $this->modifiedColumns[BannersTableMap::COL_WIDTH] = true; |
||
499 | } |
||
500 | |||
501 | return $this; |
||
502 | } // setWidth() |
||
503 | |||
504 | /** |
||
505 | * Set the value of [height] column. |
||
506 | * |
||
507 | * @param int $v new value |
||
508 | * @return $this|\xbanners\models\Banners The current object (for fluent API support) |
||
509 | */ |
||
510 | View Code Duplication | public function setHeight($v) |
|
511 | { |
||
512 | if ($v !== null) { |
||
513 | $v = (int) $v; |
||
514 | } |
||
515 | |||
516 | if ($this->height !== $v) { |
||
517 | $this->height = $v; |
||
518 | $this->modifiedColumns[BannersTableMap::COL_HEIGHT] = true; |
||
519 | } |
||
520 | |||
521 | return $this; |
||
522 | } // setHeight() |
||
523 | |||
524 | /** |
||
525 | * Set the value of [effects] column. |
||
526 | * |
||
527 | * @param string $v new value |
||
528 | * @return $this|\xbanners\models\Banners The current object (for fluent API support) |
||
529 | */ |
||
530 | View Code Duplication | public function setEffects($v) |
|
531 | { |
||
532 | if ($v !== null) { |
||
533 | $v = (string) $v; |
||
534 | } |
||
535 | |||
536 | if ($this->effects !== $v) { |
||
537 | $this->effects = $v; |
||
538 | $this->modifiedColumns[BannersTableMap::COL_EFFECTS] = true; |
||
539 | } |
||
540 | |||
541 | return $this; |
||
542 | } // setEffects() |
||
543 | |||
544 | /** |
||
545 | * Set the value of [page_type] column. |
||
546 | * |
||
547 | * @param string $v new value |
||
548 | * @return $this|\xbanners\models\Banners The current object (for fluent API support) |
||
549 | */ |
||
550 | View Code Duplication | public function setPageType($v) |
|
551 | { |
||
552 | if ($v !== null) { |
||
553 | $v = (string) $v; |
||
554 | } |
||
555 | |||
556 | if ($this->page_type !== $v) { |
||
557 | $this->page_type = $v; |
||
558 | $this->modifiedColumns[BannersTableMap::COL_PAGE_TYPE] = true; |
||
559 | } |
||
560 | |||
561 | return $this; |
||
562 | } // setPageType() |
||
563 | |||
564 | /** |
||
565 | * Indicates whether the columns in this object are only set to default values. |
||
566 | * |
||
567 | * This method can be used in conjunction with isModified() to indicate whether an object is both |
||
568 | * modified _and_ has some values set which are non-default. |
||
569 | * |
||
570 | * @return boolean Whether the columns in this object are only been set with default values. |
||
571 | */ |
||
572 | public function hasOnlyDefaultValues() |
||
573 | { |
||
574 | // otherwise, everything was equal, so return TRUE |
||
575 | return true; |
||
576 | } // hasOnlyDefaultValues() |
||
577 | |||
578 | /** |
||
579 | * Hydrates (populates) the object variables with values from the database resultset. |
||
580 | * |
||
581 | * An offset (0-based "start column") is specified so that objects can be hydrated |
||
582 | * with a subset of the columns in the resultset rows. This is needed, for example, |
||
583 | * for results of JOIN queries where the resultset row includes columns from two or |
||
584 | * more tables. |
||
585 | * |
||
586 | * @param array $row The row returned by DataFetcher->fetch(). |
||
587 | * @param int $startcol 0-based offset column which indicates which restultset column to start with. |
||
588 | * @param boolean $rehydrate Whether this object is being re-hydrated from the database. |
||
589 | * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
||
590 | One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
591 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
592 | * |
||
593 | * @return int next starting column |
||
594 | * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. |
||
595 | */ |
||
596 | View Code Duplication | public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) |
|
597 | { |
||
598 | try { |
||
599 | |||
600 | $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : BannersTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; |
||
601 | $this->id = (null !== $col) ? (int) $col : null; |
||
602 | |||
603 | $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : BannersTableMap::translateFieldName('Place', TableMap::TYPE_PHPNAME, $indexType)]; |
||
604 | $this->place = (null !== $col) ? (string) $col : null; |
||
605 | |||
606 | $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : BannersTableMap::translateFieldName('Width', TableMap::TYPE_PHPNAME, $indexType)]; |
||
607 | $this->width = (null !== $col) ? (int) $col : null; |
||
608 | |||
609 | $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : BannersTableMap::translateFieldName('Height', TableMap::TYPE_PHPNAME, $indexType)]; |
||
610 | $this->height = (null !== $col) ? (int) $col : null; |
||
611 | |||
612 | $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : BannersTableMap::translateFieldName('Effects', TableMap::TYPE_PHPNAME, $indexType)]; |
||
613 | $this->effects = (null !== $col) ? (string) $col : null; |
||
614 | |||
615 | $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : BannersTableMap::translateFieldName('PageType', TableMap::TYPE_PHPNAME, $indexType)]; |
||
616 | $this->page_type = (null !== $col) ? (string) $col : null; |
||
617 | $this->resetModified(); |
||
618 | |||
619 | $this->setNew(false); |
||
620 | |||
621 | if ($rehydrate) { |
||
622 | $this->ensureConsistency(); |
||
623 | } |
||
624 | |||
625 | return $startcol + 6; // 6 = BannersTableMap::NUM_HYDRATE_COLUMNS. |
||
626 | |||
627 | } catch (Exception $e) { |
||
628 | throw new PropelException(sprintf('Error populating %s object', '\\xbanners\\models\\Banners'), 0, $e); |
||
629 | } |
||
630 | } |
||
631 | |||
632 | /** |
||
633 | * Checks and repairs the internal consistency of the object. |
||
634 | * |
||
635 | * This method is executed after an already-instantiated object is re-hydrated |
||
636 | * from the database. It exists to check any foreign keys to make sure that |
||
637 | * the objects related to the current object are correct based on foreign key. |
||
638 | * |
||
639 | * You can override this method in the stub class, but you should always invoke |
||
640 | * the base method from the overridden method (i.e. parent::ensureConsistency()), |
||
641 | * in case your model changes. |
||
642 | * |
||
643 | * @throws PropelException |
||
644 | */ |
||
645 | public function ensureConsistency() |
||
646 | { |
||
647 | } // ensureConsistency |
||
648 | |||
649 | /** |
||
650 | * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. |
||
651 | * |
||
652 | * This will only work if the object has been saved and has a valid primary key set. |
||
653 | * |
||
654 | * @param boolean $deep (optional) Whether to also de-associated any related objects. |
||
655 | * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. |
||
656 | * @return void |
||
657 | * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db |
||
658 | */ |
||
659 | View Code Duplication | public function reload($deep = false, ConnectionInterface $con = null) |
|
660 | { |
||
661 | if ($this->isDeleted()) { |
||
662 | throw new PropelException("Cannot reload a deleted object."); |
||
663 | } |
||
664 | |||
665 | if ($this->isNew()) { |
||
666 | throw new PropelException("Cannot reload an unsaved object."); |
||
667 | } |
||
668 | |||
669 | if ($con === null) { |
||
670 | $con = Propel::getServiceContainer()->getReadConnection(BannersTableMap::DATABASE_NAME); |
||
671 | } |
||
672 | |||
673 | // We don't need to alter the object instance pool; we're just modifying this instance |
||
674 | // already in the pool. |
||
675 | |||
676 | $dataFetcher = ChildBannersQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); |
||
677 | $row = $dataFetcher->fetch(); |
||
678 | $dataFetcher->close(); |
||
679 | if (!$row) { |
||
680 | throw new PropelException('Cannot find matching row in the database to reload object values.'); |
||
681 | } |
||
682 | $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate |
||
683 | |||
684 | if ($deep) { // also de-associate any related objects? |
||
685 | |||
686 | $this->collBannerImages = null; |
||
687 | |||
688 | $this->collBannersI18ns = null; |
||
689 | |||
690 | } // if (deep) |
||
691 | } |
||
692 | |||
693 | /** |
||
694 | * Removes this object from datastore and sets delete attribute. |
||
695 | * |
||
696 | * @param ConnectionInterface $con |
||
697 | * @return void |
||
698 | * @throws PropelException |
||
699 | * @see Banners::setDeleted() |
||
700 | * @see Banners::isDeleted() |
||
701 | */ |
||
702 | View Code Duplication | public function delete(ConnectionInterface $con = null) |
|
703 | { |
||
704 | if ($this->isDeleted()) { |
||
705 | throw new PropelException("This object has already been deleted."); |
||
706 | } |
||
707 | |||
708 | if ($con === null) { |
||
709 | $con = Propel::getServiceContainer()->getWriteConnection(BannersTableMap::DATABASE_NAME); |
||
710 | } |
||
711 | |||
712 | $con->transaction(function () use ($con) { |
||
713 | $deleteQuery = ChildBannersQuery::create() |
||
714 | ->filterByPrimaryKey($this->getPrimaryKey()); |
||
715 | $ret = $this->preDelete($con); |
||
716 | if ($ret) { |
||
717 | $deleteQuery->delete($con); |
||
718 | $this->postDelete($con); |
||
719 | $this->setDeleted(true); |
||
720 | } |
||
721 | }); |
||
722 | } |
||
723 | |||
724 | /** |
||
725 | * Persists this object to the database. |
||
726 | * |
||
727 | * If the object is new, it inserts it; otherwise an update is performed. |
||
728 | * All modified related objects will also be persisted in the doSave() |
||
729 | * method. This method wraps all precipitate database operations in a |
||
730 | * single transaction. |
||
731 | * |
||
732 | * @param ConnectionInterface $con |
||
733 | * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
||
734 | * @throws PropelException |
||
735 | * @see doSave() |
||
736 | */ |
||
737 | View Code Duplication | public function save(ConnectionInterface $con = null) |
|
738 | { |
||
739 | if ($this->isDeleted()) { |
||
740 | throw new PropelException("You cannot save an object that has been deleted."); |
||
741 | } |
||
742 | |||
743 | if ($con === null) { |
||
744 | $con = Propel::getServiceContainer()->getWriteConnection(BannersTableMap::DATABASE_NAME); |
||
745 | } |
||
746 | |||
747 | return $con->transaction(function () use ($con) { |
||
748 | $ret = $this->preSave($con); |
||
749 | $isInsert = $this->isNew(); |
||
750 | if ($isInsert) { |
||
751 | $ret = $ret && $this->preInsert($con); |
||
752 | } else { |
||
753 | $ret = $ret && $this->preUpdate($con); |
||
754 | } |
||
755 | if ($ret) { |
||
756 | $affectedRows = $this->doSave($con); |
||
757 | if ($isInsert) { |
||
758 | $this->postInsert($con); |
||
759 | } else { |
||
760 | $this->postUpdate($con); |
||
761 | } |
||
762 | $this->postSave($con); |
||
763 | BannersTableMap::addInstanceToPool($this); |
||
764 | } else { |
||
765 | $affectedRows = 0; |
||
766 | } |
||
767 | |||
768 | return $affectedRows; |
||
769 | }); |
||
770 | } |
||
771 | |||
772 | /** |
||
773 | * Performs the work of inserting or updating the row in the database. |
||
774 | * |
||
775 | * If the object is new, it inserts it; otherwise an update is performed. |
||
776 | * All related objects are also updated in this method. |
||
777 | * |
||
778 | * @param ConnectionInterface $con |
||
779 | * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
||
780 | * @throws PropelException |
||
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
781 | * @see save() |
||
782 | */ |
||
783 | View Code Duplication | protected function doSave(ConnectionInterface $con) |
|
784 | { |
||
785 | $affectedRows = 0; // initialize var to track total num of affected rows |
||
786 | if (!$this->alreadyInSave) { |
||
787 | $this->alreadyInSave = true; |
||
788 | |||
789 | if ($this->isNew() || $this->isModified()) { |
||
790 | // persist changes |
||
791 | if ($this->isNew()) { |
||
792 | $this->doInsert($con); |
||
793 | $affectedRows += 1; |
||
794 | } else { |
||
795 | $affectedRows += $this->doUpdate($con); |
||
796 | } |
||
797 | $this->resetModified(); |
||
798 | } |
||
799 | |||
800 | if ($this->bannerImagesScheduledForDeletion !== null) { |
||
801 | if (!$this->bannerImagesScheduledForDeletion->isEmpty()) { |
||
802 | \xbanners\models\BannerImageQuery::create() |
||
803 | ->filterByPrimaryKeys($this->bannerImagesScheduledForDeletion->getPrimaryKeys(false)) |
||
804 | ->delete($con); |
||
805 | $this->bannerImagesScheduledForDeletion = null; |
||
806 | } |
||
807 | } |
||
808 | |||
809 | if ($this->collBannerImages !== null) { |
||
810 | foreach ($this->collBannerImages as $referrerFK) { |
||
811 | if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { |
||
812 | $affectedRows += $referrerFK->save($con); |
||
813 | } |
||
814 | } |
||
815 | } |
||
816 | |||
817 | if ($this->bannersI18nsScheduledForDeletion !== null) { |
||
818 | if (!$this->bannersI18nsScheduledForDeletion->isEmpty()) { |
||
819 | \xbanners\models\BannersI18nQuery::create() |
||
820 | ->filterByPrimaryKeys($this->bannersI18nsScheduledForDeletion->getPrimaryKeys(false)) |
||
821 | ->delete($con); |
||
822 | $this->bannersI18nsScheduledForDeletion = null; |
||
823 | } |
||
824 | } |
||
825 | |||
826 | if ($this->collBannersI18ns !== null) { |
||
827 | foreach ($this->collBannersI18ns as $referrerFK) { |
||
828 | if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { |
||
829 | $affectedRows += $referrerFK->save($con); |
||
830 | } |
||
831 | } |
||
832 | } |
||
833 | |||
834 | $this->alreadyInSave = false; |
||
835 | |||
0 ignored issues
–
show
|
|||
836 | } |
||
837 | |||
838 | return $affectedRows; |
||
839 | } // doSave() |
||
840 | |||
841 | /** |
||
842 | * Insert the row in the database. |
||
843 | * |
||
844 | * @param ConnectionInterface $con |
||
845 | * |
||
846 | * @throws PropelException |
||
0 ignored issues
–
show
|
|||
847 | * @see doSave() |
||
848 | */ |
||
849 | protected function doInsert(ConnectionInterface $con) |
||
850 | { |
||
851 | $modifiedColumns = array(); |
||
852 | $index = 0; |
||
853 | |||
854 | $this->modifiedColumns[BannersTableMap::COL_ID] = true; |
||
855 | if (null !== $this->id) { |
||
856 | throw new PropelException('Cannot insert a value for auto-increment primary key (' . BannersTableMap::COL_ID . ')'); |
||
857 | } |
||
858 | |||
859 | // check the columns in natural order for more readable SQL queries |
||
860 | if ($this->isColumnModified(BannersTableMap::COL_ID)) { |
||
861 | $modifiedColumns[':p' . $index++] = 'id'; |
||
862 | } |
||
863 | if ($this->isColumnModified(BannersTableMap::COL_PLACE)) { |
||
864 | $modifiedColumns[':p' . $index++] = 'place'; |
||
865 | } |
||
866 | if ($this->isColumnModified(BannersTableMap::COL_WIDTH)) { |
||
867 | $modifiedColumns[':p' . $index++] = 'width'; |
||
868 | } |
||
869 | if ($this->isColumnModified(BannersTableMap::COL_HEIGHT)) { |
||
870 | $modifiedColumns[':p' . $index++] = 'height'; |
||
871 | } |
||
872 | if ($this->isColumnModified(BannersTableMap::COL_EFFECTS)) { |
||
873 | $modifiedColumns[':p' . $index++] = 'effects'; |
||
874 | } |
||
875 | if ($this->isColumnModified(BannersTableMap::COL_PAGE_TYPE)) { |
||
876 | $modifiedColumns[':p' . $index++] = 'page_type'; |
||
877 | } |
||
878 | |||
879 | $sql = sprintf( |
||
880 | 'INSERT INTO banners (%s) VALUES (%s)', |
||
881 | implode(', ', $modifiedColumns), |
||
882 | implode(', ', array_keys($modifiedColumns)) |
||
883 | ); |
||
884 | |||
885 | try { |
||
886 | $stmt = $con->prepare($sql); |
||
887 | foreach ($modifiedColumns as $identifier => $columnName) { |
||
888 | switch ($columnName) { |
||
889 | case 'id': |
||
890 | $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); |
||
891 | break; |
||
0 ignored issues
–
show
|
|||
892 | case 'place': |
||
893 | $stmt->bindValue($identifier, $this->place, PDO::PARAM_STR); |
||
894 | break; |
||
0 ignored issues
–
show
|
|||
895 | case 'width': |
||
896 | $stmt->bindValue($identifier, $this->width, PDO::PARAM_INT); |
||
897 | break; |
||
0 ignored issues
–
show
|
|||
898 | case 'height': |
||
899 | $stmt->bindValue($identifier, $this->height, PDO::PARAM_INT); |
||
900 | break; |
||
0 ignored issues
–
show
|
|||
901 | case 'effects': |
||
902 | $stmt->bindValue($identifier, $this->effects, PDO::PARAM_STR); |
||
903 | break; |
||
0 ignored issues
–
show
|
|||
904 | case 'page_type': |
||
905 | $stmt->bindValue($identifier, $this->page_type, PDO::PARAM_STR); |
||
906 | break; |
||
907 | } |
||
908 | } |
||
909 | $stmt->execute(); |
||
910 | } catch (Exception $e) { |
||
911 | Propel::log($e->getMessage(), Propel::LOG_ERR); |
||
912 | throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); |
||
913 | } |
||
914 | |||
915 | try { |
||
916 | $pk = $con->lastInsertId(); |
||
917 | } catch (Exception $e) { |
||
918 | throw new PropelException('Unable to get autoincrement id.', 0, $e); |
||
919 | } |
||
920 | $this->setId($pk); |
||
921 | |||
922 | $this->setNew(false); |
||
923 | } |
||
924 | |||
925 | /** |
||
926 | * Update the row in the database. |
||
927 | * |
||
928 | * @param ConnectionInterface $con |
||
929 | * |
||
930 | * @return Integer Number of updated rows |
||
931 | * @see doSave() |
||
932 | */ |
||
933 | protected function doUpdate(ConnectionInterface $con) |
||
934 | { |
||
935 | $selectCriteria = $this->buildPkeyCriteria(); |
||
936 | $valuesCriteria = $this->buildCriteria(); |
||
937 | |||
938 | return $selectCriteria->doUpdate($valuesCriteria, $con); |
||
939 | } |
||
940 | |||
941 | /** |
||
942 | * Retrieves a field from the object by name passed in as a string. |
||
943 | * |
||
944 | * @param string $name name |
||
945 | * @param string $type The type of fieldname the $name is of: |
||
946 | * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
947 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
948 | * Defaults to TableMap::TYPE_PHPNAME. |
||
949 | * @return mixed Value of field. |
||
950 | */ |
||
951 | View Code Duplication | public function getByName($name, $type = TableMap::TYPE_PHPNAME) |
|
952 | { |
||
953 | $pos = BannersTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); |
||
954 | $field = $this->getByPosition($pos); |
||
955 | |||
956 | return $field; |
||
957 | } |
||
958 | |||
959 | /** |
||
960 | * Retrieves a field from the object by Position as specified in the xml schema. |
||
961 | * Zero-based. |
||
962 | * |
||
963 | * @param int $pos position in xml schema |
||
964 | * @return mixed Value of field at $pos |
||
965 | */ |
||
966 | public function getByPosition($pos) |
||
967 | { |
||
968 | switch ($pos) { |
||
969 | case 0: |
||
970 | return $this->getId(); |
||
971 | break; |
||
0 ignored issues
–
show
break is not strictly necessary here and could be removed.
The break statement is not necessary if it is preceded for example by a return statement: switch ($x) {
case 1:
return 'foo';
break; // This break is not necessary and can be left off.
}
If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.
Loading history...
|
|||
972 | case 1: |
||
973 | return $this->getPlace(); |
||
974 | break; |
||
0 ignored issues
–
show
break is not strictly necessary here and could be removed.
The break statement is not necessary if it is preceded for example by a return statement: switch ($x) {
case 1:
return 'foo';
break; // This break is not necessary and can be left off.
}
If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.
Loading history...
|
|||
975 | case 2: |
||
976 | return $this->getWidth(); |
||
977 | break; |
||
0 ignored issues
–
show
break is not strictly necessary here and could be removed.
The break statement is not necessary if it is preceded for example by a return statement: switch ($x) {
case 1:
return 'foo';
break; // This break is not necessary and can be left off.
}
If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.
Loading history...
|
|||
978 | case 3: |
||
979 | return $this->getHeight(); |
||
980 | break; |
||
0 ignored issues
–
show
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...
|
|||
981 | case 4: |
||
982 | return $this->getEffects(); |
||
983 | break; |
||
0 ignored issues
–
show
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...
|
|||
984 | case 5: |
||
985 | return $this->getPageType(); |
||
986 | break; |
||
0 ignored issues
–
show
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...
|
|||
987 | default: |
||
988 | return null; |
||
989 | break; |
||
0 ignored issues
–
show
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...
|
|||
990 | } // switch() |
||
991 | } |
||
992 | |||
993 | /** |
||
994 | * Exports the object as an array. |
||
995 | * |
||
996 | * You can specify the key type of the array by passing one of the class |
||
997 | * type constants. |
||
998 | * |
||
999 | * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
1000 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
1001 | * Defaults to TableMap::TYPE_PHPNAME. |
||
1002 | * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. |
||
1003 | * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion |
||
1004 | * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. |
||
1005 | * |
||
1006 | * @return array an associative array containing the field names (as keys) and field values |
||
1007 | */ |
||
1008 | View Code Duplication | public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) |
|
1009 | { |
||
1010 | |||
1011 | if (isset($alreadyDumpedObjects['Banners'][$this->hashCode()])) { |
||
1012 | return '*RECURSION*'; |
||
1013 | } |
||
1014 | $alreadyDumpedObjects['Banners'][$this->hashCode()] = true; |
||
1015 | $keys = BannersTableMap::getFieldNames($keyType); |
||
1016 | $result = array( |
||
1017 | $keys[0] => $this->getId(), |
||
1018 | $keys[1] => $this->getPlace(), |
||
1019 | $keys[2] => $this->getWidth(), |
||
1020 | $keys[3] => $this->getHeight(), |
||
1021 | $keys[4] => $this->getEffects(), |
||
1022 | $keys[5] => $this->getPageType(), |
||
1023 | ); |
||
1024 | $virtualColumns = $this->virtualColumns; |
||
1025 | foreach ($virtualColumns as $key => $virtualColumn) { |
||
1026 | $result[$key] = $virtualColumn; |
||
1027 | } |
||
1028 | |||
1029 | if ($includeForeignObjects) { |
||
1030 | if (null !== $this->collBannerImages) { |
||
1031 | |||
1032 | switch ($keyType) { |
||
1033 | case TableMap::TYPE_CAMELNAME: |
||
1034 | $key = 'bannerImages'; |
||
1035 | break; |
||
0 ignored issues
–
show
|
|||
1036 | case TableMap::TYPE_FIELDNAME: |
||
1037 | $key = 'banner_images'; |
||
1038 | break; |
||
0 ignored issues
–
show
|
|||
1039 | default: |
||
1040 | $key = 'BannerImages'; |
||
1041 | } |
||
1042 | |||
1043 | $result[$key] = $this->collBannerImages->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); |
||
1044 | } |
||
1045 | if (null !== $this->collBannersI18ns) { |
||
1046 | |||
1047 | switch ($keyType) { |
||
1048 | case TableMap::TYPE_CAMELNAME: |
||
1049 | $key = 'bannersI18ns'; |
||
1050 | break; |
||
0 ignored issues
–
show
|
|||
1051 | case TableMap::TYPE_FIELDNAME: |
||
1052 | $key = 'banners_i18ns'; |
||
1053 | break; |
||
0 ignored issues
–
show
|
|||
1054 | default: |
||
1055 | $key = 'BannersI18ns'; |
||
1056 | } |
||
1057 | |||
1058 | $result[$key] = $this->collBannersI18ns->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); |
||
1059 | } |
||
1060 | } |
||
1061 | |||
1062 | return $result; |
||
1063 | } |
||
1064 | |||
1065 | /** |
||
1066 | * Sets a field from the object by name passed in as a string. |
||
1067 | * |
||
1068 | * @param string $name |
||
1069 | * @param mixed $value field value |
||
1070 | * @param string $type The type of fieldname the $name is of: |
||
1071 | * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
1072 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
1073 | * Defaults to TableMap::TYPE_PHPNAME. |
||
1074 | * @return $this|\xbanners\models\Banners |
||
0 ignored issues
–
show
|
|||
1075 | */ |
||
1076 | public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) |
||
1077 | { |
||
1078 | $pos = BannersTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); |
||
1079 | |||
1080 | return $this->setByPosition($pos, $value); |
||
1081 | } |
||
1082 | |||
1083 | /** |
||
1084 | * Sets a field from the object by Position as specified in the xml schema. |
||
1085 | * Zero-based. |
||
1086 | * |
||
1087 | * @param int $pos position in xml schema |
||
1088 | * @param mixed $value field value |
||
1089 | * @return $this|\xbanners\models\Banners |
||
0 ignored issues
–
show
|
|||
1090 | */ |
||
1091 | public function setByPosition($pos, $value) |
||
1092 | { |
||
1093 | switch ($pos) { |
||
1094 | case 0: |
||
1095 | $this->setId($value); |
||
1096 | break; |
||
0 ignored issues
–
show
|
|||
1097 | case 1: |
||
1098 | $this->setPlace($value); |
||
1099 | break; |
||
0 ignored issues
–
show
|
|||
1100 | case 2: |
||
1101 | $this->setWidth($value); |
||
1102 | break; |
||
0 ignored issues
–
show
|
|||
1103 | case 3: |
||
1104 | $this->setHeight($value); |
||
1105 | break; |
||
0 ignored issues
–
show
|
|||
1106 | case 4: |
||
1107 | $this->setEffects($value); |
||
1108 | break; |
||
0 ignored issues
–
show
|
|||
1109 | case 5: |
||
1110 | $this->setPageType($value); |
||
1111 | break; |
||
1112 | } // switch() |
||
1113 | |||
1114 | return $this; |
||
1115 | } |
||
1116 | |||
1117 | /** |
||
1118 | * Populates the object using an array. |
||
1119 | * |
||
1120 | * This is particularly useful when populating an object from one of the |
||
1121 | * request arrays (e.g. $_POST). This method goes through the column |
||
1122 | * names, checking to see whether a matching key exists in populated |
||
1123 | * array. If so the setByName() method is called for that column. |
||
1124 | * |
||
1125 | * You can specify the key type of the array by additionally passing one |
||
1126 | * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
1127 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
1128 | * The default key type is the column's TableMap::TYPE_PHPNAME. |
||
1129 | * |
||
1130 | * @param array $arr An array to populate the object from. |
||
1131 | * @param string $keyType The type of keys the array uses. |
||
1132 | * @return void |
||
0 ignored issues
–
show
|
|||
1133 | */ |
||
1134 | View Code Duplication | public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) |
|
1135 | { |
||
1136 | $keys = BannersTableMap::getFieldNames($keyType); |
||
1137 | |||
1138 | if (array_key_exists($keys[0], $arr)) { |
||
1139 | $this->setId($arr[$keys[0]]); |
||
1140 | } |
||
1141 | if (array_key_exists($keys[1], $arr)) { |
||
1142 | $this->setPlace($arr[$keys[1]]); |
||
1143 | } |
||
1144 | if (array_key_exists($keys[2], $arr)) { |
||
1145 | $this->setWidth($arr[$keys[2]]); |
||
1146 | } |
||
1147 | if (array_key_exists($keys[3], $arr)) { |
||
1148 | $this->setHeight($arr[$keys[3]]); |
||
1149 | } |
||
1150 | if (array_key_exists($keys[4], $arr)) { |
||
1151 | $this->setEffects($arr[$keys[4]]); |
||
1152 | } |
||
1153 | if (array_key_exists($keys[5], $arr)) { |
||
1154 | $this->setPageType($arr[$keys[5]]); |
||
1155 | } |
||
1156 | } |
||
1157 | |||
1158 | /** |
||
1159 | * Populate the current object from a string, using a given parser format |
||
1160 | * <code> |
||
1161 | * $book = new Book(); |
||
1162 | * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
||
1163 | * </code> |
||
1164 | * |
||
0 ignored issues
–
show
|
|||
1165 | * You can specify the key type of the array by additionally passing one |
||
1166 | * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
1167 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
1168 | * The default key type is the column's TableMap::TYPE_PHPNAME. |
||
1169 | * |
||
0 ignored issues
–
show
|
|||
1170 | * @param mixed $parser A AbstractParser instance, |
||
1171 | * or a format name ('XML', 'YAML', 'JSON', 'CSV') |
||
1172 | * @param string $data The source data to import from |
||
1173 | * @param string $keyType The type of keys the array uses. |
||
1174 | * |
||
0 ignored issues
–
show
|
|||
1175 | * @return $this|\xbanners\models\Banners The current object, for fluid interface |
||
1176 | */ |
||
1177 | View Code Duplication | public function importFrom($parser, $data, $keyType = TableMap::TYPE_PHPNAME) |
|
1178 | { |
||
1179 | if (!$parser instanceof AbstractParser) { |
||
1180 | $parser = AbstractParser::getParser($parser); |
||
1181 | } |
||
1182 | |||
1183 | $this->fromArray($parser->toArray($data), $keyType); |
||
1184 | |||
1185 | return $this; |
||
1186 | } |
||
1187 | |||
1188 | /** |
||
1189 | * Build a Criteria object containing the values of all modified columns in this object. |
||
1190 | * |
||
1191 | * @return Criteria The Criteria object containing all modified values. |
||
1192 | */ |
||
1193 | public function buildCriteria() |
||
1194 | { |
||
1195 | $criteria = new Criteria(BannersTableMap::DATABASE_NAME); |
||
1196 | |||
1197 | if ($this->isColumnModified(BannersTableMap::COL_ID)) { |
||
1198 | $criteria->add(BannersTableMap::COL_ID, $this->id); |
||
1199 | } |
||
1200 | if ($this->isColumnModified(BannersTableMap::COL_PLACE)) { |
||
1201 | $criteria->add(BannersTableMap::COL_PLACE, $this->place); |
||
1202 | } |
||
1203 | if ($this->isColumnModified(BannersTableMap::COL_WIDTH)) { |
||
1204 | $criteria->add(BannersTableMap::COL_WIDTH, $this->width); |
||
1205 | } |
||
1206 | if ($this->isColumnModified(BannersTableMap::COL_HEIGHT)) { |
||
1207 | $criteria->add(BannersTableMap::COL_HEIGHT, $this->height); |
||
1208 | } |
||
1209 | if ($this->isColumnModified(BannersTableMap::COL_EFFECTS)) { |
||
1210 | $criteria->add(BannersTableMap::COL_EFFECTS, $this->effects); |
||
1211 | } |
||
1212 | if ($this->isColumnModified(BannersTableMap::COL_PAGE_TYPE)) { |
||
1213 | $criteria->add(BannersTableMap::COL_PAGE_TYPE, $this->page_type); |
||
1214 | } |
||
1215 | |||
1216 | return $criteria; |
||
1217 | } |
||
1218 | |||
1219 | /** |
||
1220 | * Builds a Criteria object containing the primary key for this object. |
||
1221 | * |
||
1222 | * Unlike buildCriteria() this method includes the primary key values regardless |
||
1223 | * of whether or not they have been modified. |
||
1224 | * |
||
1225 | * @throws LogicException if no primary key is defined |
||
1226 | * |
||
1227 | * @return Criteria The Criteria object containing value(s) for primary key(s). |
||
1228 | */ |
||
1229 | public function buildPkeyCriteria() |
||
1230 | { |
||
1231 | $criteria = ChildBannersQuery::create(); |
||
1232 | $criteria->add(BannersTableMap::COL_ID, $this->id); |
||
1233 | |||
1234 | return $criteria; |
||
1235 | } |
||
1236 | |||
1237 | /** |
||
1238 | * If the primary key is not null, return the hashcode of the |
||
1239 | * primary key. Otherwise, return the hash code of the object. |
||
1240 | * |
||
1241 | * @return int Hashcode |
||
1242 | */ |
||
1243 | View Code Duplication | public function hashCode() |
|
1244 | { |
||
1245 | $validPk = null !== $this->getId(); |
||
1246 | |||
1247 | $validPrimaryKeyFKs = 0; |
||
1248 | $primaryKeyFKs = []; |
||
1249 | |||
1250 | if ($validPk) { |
||
1251 | return crc32(json_encode($this->getPrimaryKey(), JSON_UNESCAPED_UNICODE)); |
||
1252 | } elseif ($validPrimaryKeyFKs) { |
||
1253 | return crc32(json_encode($primaryKeyFKs, JSON_UNESCAPED_UNICODE)); |
||
1254 | } |
||
1255 | |||
1256 | return spl_object_hash($this); |
||
1257 | } |
||
1258 | |||
1259 | /** |
||
1260 | * Returns the primary key for this object (row). |
||
1261 | * @return int |
||
1262 | */ |
||
1263 | public function getPrimaryKey() |
||
1264 | { |
||
1265 | return $this->getId(); |
||
1266 | } |
||
1267 | |||
1268 | /** |
||
1269 | * Generic method to set the primary key (id column). |
||
1270 | * |
||
1271 | * @param int $key Primary key. |
||
1272 | * @return void |
||
0 ignored issues
–
show
|
|||
1273 | */ |
||
1274 | public function setPrimaryKey($key) |
||
1275 | { |
||
1276 | $this->setId($key); |
||
1277 | } |
||
1278 | |||
1279 | /** |
||
1280 | * Returns true if the primary key for this object is null. |
||
1281 | * @return boolean |
||
1282 | */ |
||
1283 | public function isPrimaryKeyNull() |
||
1284 | { |
||
1285 | return null === $this->getId(); |
||
1286 | } |
||
1287 | |||
1288 | /** |
||
1289 | * Sets contents of passed object to values from current object. |
||
1290 | * |
||
1291 | * If desired, this method can also make copies of all associated (fkey referrers) |
||
1292 | * objects. |
||
1293 | * |
||
1294 | * @param object $copyObj An object of \xbanners\models\Banners (or compatible) type. |
||
1295 | * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
||
1296 | * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. |
||
1297 | * @throws PropelException |
||
0 ignored issues
–
show
|
|||
1298 | */ |
||
1299 | public function copyInto($copyObj, $deepCopy = false, $makeNew = true) |
||
1300 | { |
||
1301 | $copyObj->setPlace($this->getPlace()); |
||
1302 | $copyObj->setWidth($this->getWidth()); |
||
1303 | $copyObj->setHeight($this->getHeight()); |
||
1304 | $copyObj->setEffects($this->getEffects()); |
||
1305 | $copyObj->setPageType($this->getPageType()); |
||
1306 | |||
1307 | if ($deepCopy) { |
||
1308 | // important: temporarily setNew(false) because this affects the behavior of |
||
1309 | // the getter/setter methods for fkey referrer objects. |
||
1310 | $copyObj->setNew(false); |
||
1311 | |||
1312 | foreach ($this->getBannerImages() as $relObj) { |
||
1313 | if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves |
||
1314 | $copyObj->addBannerImage($relObj->copy($deepCopy)); |
||
1315 | } |
||
1316 | } |
||
1317 | |||
1318 | foreach ($this->getBannersI18ns() as $relObj) { |
||
1319 | if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves |
||
1320 | $copyObj->addBannersI18n($relObj->copy($deepCopy)); |
||
1321 | } |
||
1322 | } |
||
1323 | |||
0 ignored issues
–
show
|
|||
1324 | } // if ($deepCopy) |
||
1325 | |||
1326 | if ($makeNew) { |
||
1327 | $copyObj->setNew(true); |
||
1328 | $copyObj->setId(NULL); // this is a auto-increment column, so set to default value |
||
1329 | } |
||
1330 | } |
||
1331 | |||
1332 | /** |
||
1333 | * Makes a copy of this object that will be inserted as a new row in table when saved. |
||
1334 | * It creates a new object filling in the simple attributes, but skipping any primary |
||
1335 | * keys that are defined for the table. |
||
1336 | * |
||
1337 | * If desired, this method can also make copies of all associated (fkey referrers) |
||
1338 | * objects. |
||
1339 | * |
||
1340 | * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
||
1341 | * @return \xbanners\models\Banners Clone of current object. |
||
1342 | * @throws PropelException |
||
0 ignored issues
–
show
|
|||
1343 | */ |
||
1344 | View Code Duplication | public function copy($deepCopy = false) |
|
1345 | { |
||
1346 | // we use get_class(), because this might be a subclass |
||
1347 | $clazz = get_class($this); |
||
1348 | $copyObj = new $clazz(); |
||
1349 | $this->copyInto($copyObj, $deepCopy); |
||
1350 | |||
1351 | return $copyObj; |
||
1352 | } |
||
1353 | |||
1354 | |||
1355 | /** |
||
1356 | * Initializes a collection based on the name of a relation. |
||
1357 | * Avoids crafting an 'init[$relationName]s' method name |
||
1358 | * that wouldn't work when StandardEnglishPluralizer is used. |
||
1359 | * |
||
1360 | * @param string $relationName The name of the relation to initialize |
||
1361 | * @return void |
||
0 ignored issues
–
show
|
|||
1362 | */ |
||
1363 | public function initRelation($relationName) |
||
1364 | { |
||
1365 | if ('BannerImage' == $relationName) { |
||
1366 | return $this->initBannerImages(); |
||
1367 | } |
||
1368 | if ('BannersI18n' == $relationName) { |
||
1369 | return $this->initBannersI18ns(); |
||
1370 | } |
||
1371 | } |
||
1372 | |||
1373 | /** |
||
1374 | * Clears out the collBannerImages collection |
||
1375 | * |
||
1376 | * This does not modify the database; however, it will remove any associated objects, causing |
||
1377 | * them to be refetched by subsequent calls to accessor method. |
||
1378 | * |
||
1379 | * @return void |
||
0 ignored issues
–
show
|
|||
1380 | * @see addBannerImages() |
||
1381 | */ |
||
1382 | public function clearBannerImages() |
||
1383 | { |
||
1384 | $this->collBannerImages = null; // important to set this to NULL since that means it is uninitialized |
||
1385 | } |
||
1386 | |||
1387 | /** |
||
1388 | * Reset is the collBannerImages collection loaded partially. |
||
1389 | */ |
||
1390 | public function resetPartialBannerImages($v = true) |
||
1391 | { |
||
1392 | $this->collBannerImagesPartial = $v; |
||
1393 | } |
||
1394 | |||
1395 | /** |
||
1396 | * Initializes the collBannerImages collection. |
||
1397 | * |
||
1398 | * By default this just sets the collBannerImages collection to an empty array (like clearcollBannerImages()); |
||
1399 | * however, you may wish to override this method in your stub class to provide setting appropriate |
||
1400 | * to your application -- for example, setting the initial array to the values stored in database. |
||
1401 | * |
||
1402 | * @param boolean $overrideExisting If set to true, the method call initializes |
||
1403 | * the collection even if it is not empty |
||
1404 | * |
||
1405 | * @return void |
||
0 ignored issues
–
show
|
|||
1406 | */ |
||
1407 | View Code Duplication | public function initBannerImages($overrideExisting = true) |
|
1408 | { |
||
1409 | if (null !== $this->collBannerImages && !$overrideExisting) { |
||
1410 | return; |
||
1411 | } |
||
1412 | |||
1413 | $collectionClassName = BannerImageTableMap::getTableMap()->getCollectionClassName(); |
||
1414 | |||
1415 | $this->collBannerImages = new $collectionClassName; |
||
1416 | $this->collBannerImages->setModel('\xbanners\models\BannerImage'); |
||
1417 | } |
||
1418 | |||
1419 | /** |
||
1420 | * Gets an array of ChildBannerImage objects which contain a foreign key that references this object. |
||
1421 | * |
||
1422 | * If the $criteria is not null, it is used to always fetch the results from the database. |
||
1423 | * Otherwise the results are fetched from the database the first time, then cached. |
||
1424 | * Next time the same method is called without $criteria, the cached collection is returned. |
||
1425 | * If this ChildBanners is new, it will return |
||
1426 | * an empty collection or the current collection; the criteria is ignored on a new object. |
||
1427 | * |
||
1428 | * @param Criteria $criteria optional Criteria object to narrow the query |
||
1429 | * @param ConnectionInterface $con optional connection object |
||
1430 | * @return ObjectCollection|ChildBannerImage[] List of ChildBannerImage objects |
||
1431 | * @throws PropelException |
||
0 ignored issues
–
show
|
|||
1432 | */ |
||
1433 | View Code Duplication | public function getBannerImages(Criteria $criteria = null, ConnectionInterface $con = null) |
|
1434 | { |
||
1435 | $partial = $this->collBannerImagesPartial && !$this->isNew(); |
||
1436 | if (null === $this->collBannerImages || null !== $criteria || $partial) { |
||
1437 | if ($this->isNew() && null === $this->collBannerImages) { |
||
1438 | // return empty collection |
||
1439 | $this->initBannerImages(); |
||
1440 | } else { |
||
1441 | $collBannerImages = ChildBannerImageQuery::create(null, $criteria) |
||
1442 | ->filterByBanners($this) |
||
1443 | ->find($con); |
||
1444 | |||
1445 | if (null !== $criteria) { |
||
1446 | if (false !== $this->collBannerImagesPartial && count($collBannerImages)) { |
||
1447 | $this->initBannerImages(false); |
||
1448 | |||
1449 | foreach ($collBannerImages as $obj) { |
||
1450 | if (false == $this->collBannerImages->contains($obj)) { |
||
1451 | $this->collBannerImages->append($obj); |
||
1452 | } |
||
1453 | } |
||
1454 | |||
1455 | $this->collBannerImagesPartial = true; |
||
1456 | } |
||
1457 | |||
1458 | return $collBannerImages; |
||
1459 | } |
||
1460 | |||
1461 | if ($partial && $this->collBannerImages) { |
||
1462 | foreach ($this->collBannerImages as $obj) { |
||
1463 | if ($obj->isNew()) { |
||
1464 | $collBannerImages[] = $obj; |
||
1465 | } |
||
1466 | } |
||
1467 | } |
||
1468 | |||
1469 | $this->collBannerImages = $collBannerImages; |
||
1470 | $this->collBannerImagesPartial = false; |
||
1471 | } |
||
1472 | } |
||
1473 | |||
1474 | return $this->collBannerImages; |
||
1475 | } |
||
1476 | |||
1477 | /** |
||
1478 | * Sets a collection of ChildBannerImage objects related by a one-to-many relationship |
||
1479 | * to the current object. |
||
1480 | * It will also schedule objects for deletion based on a diff between old objects (aka persisted) |
||
1481 | * and new objects from the given Propel collection. |
||
1482 | * |
||
1483 | * @param Collection $bannerImages A Propel collection. |
||
1484 | * @param ConnectionInterface $con Optional connection object |
||
1485 | * @return $this|ChildBanners The current object (for fluent API support) |
||
0 ignored issues
–
show
|
|||
1486 | */ |
||
1487 | View Code Duplication | public function setBannerImages(Collection $bannerImages, ConnectionInterface $con = null) |
|
1488 | { |
||
1489 | /** @var ChildBannerImage[] $bannerImagesToDelete */ |
||
1490 | $bannerImagesToDelete = $this->getBannerImages(new Criteria(), $con)->diff($bannerImages); |
||
1491 | |||
1492 | |||
1493 | $this->bannerImagesScheduledForDeletion = $bannerImagesToDelete; |
||
1494 | |||
1495 | foreach ($bannerImagesToDelete as $bannerImageRemoved) { |
||
1496 | $bannerImageRemoved->setBanners(null); |
||
1497 | } |
||
1498 | |||
1499 | $this->collBannerImages = null; |
||
1500 | foreach ($bannerImages as $bannerImage) { |
||
1501 | $this->addBannerImage($bannerImage); |
||
1502 | } |
||
1503 | |||
1504 | $this->collBannerImages = $bannerImages; |
||
1505 | $this->collBannerImagesPartial = false; |
||
1506 | |||
1507 | return $this; |
||
1508 | } |
||
1509 | |||
1510 | /** |
||
1511 | * Returns the number of related BannerImage objects. |
||
1512 | * |
||
1513 | * @param Criteria $criteria |
||
1514 | * @param boolean $distinct |
||
1515 | * @param ConnectionInterface $con |
||
1516 | * @return int Count of related BannerImage objects. |
||
1517 | * @throws PropelException |
||
0 ignored issues
–
show
|
|||
1518 | */ |
||
1519 | View Code Duplication | public function countBannerImages(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) |
|
1520 | { |
||
1521 | $partial = $this->collBannerImagesPartial && !$this->isNew(); |
||
1522 | if (null === $this->collBannerImages || null !== $criteria || $partial) { |
||
1523 | if ($this->isNew() && null === $this->collBannerImages) { |
||
1524 | return 0; |
||
1525 | } |
||
1526 | |||
1527 | if ($partial && !$criteria) { |
||
1528 | return count($this->getBannerImages()); |
||
1529 | } |
||
1530 | |||
1531 | $query = ChildBannerImageQuery::create(null, $criteria); |
||
1532 | if ($distinct) { |
||
1533 | $query->distinct(); |
||
1534 | } |
||
1535 | |||
1536 | return $query |
||
1537 | ->filterByBanners($this) |
||
1538 | ->count($con); |
||
1539 | } |
||
1540 | |||
1541 | return count($this->collBannerImages); |
||
1542 | } |
||
1543 | |||
1544 | /** |
||
1545 | * Method called to associate a ChildBannerImage object to this object |
||
1546 | * through the ChildBannerImage foreign key attribute. |
||
1547 | * |
||
1548 | * @param ChildBannerImage $l ChildBannerImage |
||
1549 | * @return $this|\xbanners\models\Banners The current object (for fluent API support) |
||
0 ignored issues
–
show
|
|||
1550 | */ |
||
1551 | public function addBannerImage(ChildBannerImage $l) |
||
1552 | { |
||
1553 | if ($this->collBannerImages === null) { |
||
1554 | $this->initBannerImages(); |
||
1555 | $this->collBannerImagesPartial = true; |
||
1556 | } |
||
1557 | |||
1558 | if (!$this->collBannerImages->contains($l)) { |
||
1559 | $this->doAddBannerImage($l); |
||
1560 | |||
1561 | if ($this->bannerImagesScheduledForDeletion and $this->bannerImagesScheduledForDeletion->contains($l)) { |
||
1562 | $this->bannerImagesScheduledForDeletion->remove($this->bannerImagesScheduledForDeletion->search($l)); |
||
1563 | } |
||
1564 | } |
||
1565 | |||
1566 | return $this; |
||
1567 | } |
||
1568 | |||
1569 | /** |
||
1570 | * @param ChildBannerImage $bannerImage The ChildBannerImage object to add. |
||
1571 | */ |
||
1572 | protected function doAddBannerImage(ChildBannerImage $bannerImage) |
||
1573 | { |
||
1574 | $this->collBannerImages[]= $bannerImage; |
||
1575 | $bannerImage->setBanners($this); |
||
1576 | } |
||
1577 | |||
1578 | /** |
||
1579 | * @param ChildBannerImage $bannerImage The ChildBannerImage object to remove. |
||
1580 | * @return $this|ChildBanners The current object (for fluent API support) |
||
0 ignored issues
–
show
|
|||
1581 | */ |
||
1582 | View Code Duplication | public function removeBannerImage(ChildBannerImage $bannerImage) |
|
1583 | { |
||
1584 | if ($this->getBannerImages()->contains($bannerImage)) { |
||
1585 | $pos = $this->collBannerImages->search($bannerImage); |
||
1586 | $this->collBannerImages->remove($pos); |
||
1587 | if (null === $this->bannerImagesScheduledForDeletion) { |
||
1588 | $this->bannerImagesScheduledForDeletion = clone $this->collBannerImages; |
||
1589 | $this->bannerImagesScheduledForDeletion->clear(); |
||
1590 | } |
||
1591 | $this->bannerImagesScheduledForDeletion[]= clone $bannerImage; |
||
1592 | $bannerImage->setBanners(null); |
||
1593 | } |
||
1594 | |||
1595 | return $this; |
||
1596 | } |
||
1597 | |||
1598 | /** |
||
1599 | * Clears out the collBannersI18ns collection |
||
1600 | * |
||
1601 | * This does not modify the database; however, it will remove any associated objects, causing |
||
1602 | * them to be refetched by subsequent calls to accessor method. |
||
1603 | * |
||
1604 | * @return void |
||
0 ignored issues
–
show
|
|||
1605 | * @see addBannersI18ns() |
||
1606 | */ |
||
1607 | public function clearBannersI18ns() |
||
1608 | { |
||
1609 | $this->collBannersI18ns = null; // important to set this to NULL since that means it is uninitialized |
||
1610 | } |
||
1611 | |||
1612 | /** |
||
1613 | * Reset is the collBannersI18ns collection loaded partially. |
||
1614 | */ |
||
1615 | public function resetPartialBannersI18ns($v = true) |
||
1616 | { |
||
1617 | $this->collBannersI18nsPartial = $v; |
||
1618 | } |
||
1619 | |||
1620 | /** |
||
1621 | * Initializes the collBannersI18ns collection. |
||
1622 | * |
||
1623 | * By default this just sets the collBannersI18ns collection to an empty array (like clearcollBannersI18ns()); |
||
1624 | * however, you may wish to override this method in your stub class to provide setting appropriate |
||
1625 | * to your application -- for example, setting the initial array to the values stored in database. |
||
1626 | * |
||
1627 | * @param boolean $overrideExisting If set to true, the method call initializes |
||
1628 | * the collection even if it is not empty |
||
1629 | * |
||
1630 | * @return void |
||
0 ignored issues
–
show
|
|||
1631 | */ |
||
1632 | View Code Duplication | public function initBannersI18ns($overrideExisting = true) |
|
1633 | { |
||
1634 | if (null !== $this->collBannersI18ns && !$overrideExisting) { |
||
1635 | return; |
||
1636 | } |
||
1637 | |||
1638 | $collectionClassName = BannersI18nTableMap::getTableMap()->getCollectionClassName(); |
||
1639 | |||
1640 | $this->collBannersI18ns = new $collectionClassName; |
||
1641 | $this->collBannersI18ns->setModel('\xbanners\models\BannersI18n'); |
||
1642 | } |
||
1643 | |||
1644 | /** |
||
1645 | * Gets an array of ChildBannersI18n objects which contain a foreign key that references this object. |
||
1646 | * |
||
1647 | * If the $criteria is not null, it is used to always fetch the results from the database. |
||
1648 | * Otherwise the results are fetched from the database the first time, then cached. |
||
1649 | * Next time the same method is called without $criteria, the cached collection is returned. |
||
1650 | * If this ChildBanners is new, it will return |
||
1651 | * an empty collection or the current collection; the criteria is ignored on a new object. |
||
1652 | * |
||
1653 | * @param Criteria $criteria optional Criteria object to narrow the query |
||
1654 | * @param ConnectionInterface $con optional connection object |
||
1655 | * @return ObjectCollection|ChildBannersI18n[] List of ChildBannersI18n objects |
||
1656 | * @throws PropelException |
||
0 ignored issues
–
show
|
|||
1657 | */ |
||
1658 | View Code Duplication | public function getBannersI18ns(Criteria $criteria = null, ConnectionInterface $con = null) |
|
1659 | { |
||
1660 | $partial = $this->collBannersI18nsPartial && !$this->isNew(); |
||
1661 | if (null === $this->collBannersI18ns || null !== $criteria || $partial) { |
||
1662 | if ($this->isNew() && null === $this->collBannersI18ns) { |
||
1663 | // return empty collection |
||
1664 | $this->initBannersI18ns(); |
||
1665 | } else { |
||
1666 | $collBannersI18ns = ChildBannersI18nQuery::create(null, $criteria) |
||
1667 | ->filterByBanners($this) |
||
1668 | ->find($con); |
||
1669 | |||
1670 | if (null !== $criteria) { |
||
1671 | if (false !== $this->collBannersI18nsPartial && count($collBannersI18ns)) { |
||
1672 | $this->initBannersI18ns(false); |
||
1673 | |||
1674 | foreach ($collBannersI18ns as $obj) { |
||
1675 | if (false == $this->collBannersI18ns->contains($obj)) { |
||
1676 | $this->collBannersI18ns->append($obj); |
||
1677 | } |
||
1678 | } |
||
1679 | |||
1680 | $this->collBannersI18nsPartial = true; |
||
1681 | } |
||
1682 | |||
1683 | return $collBannersI18ns; |
||
1684 | } |
||
1685 | |||
1686 | if ($partial && $this->collBannersI18ns) { |
||
1687 | foreach ($this->collBannersI18ns as $obj) { |
||
1688 | if ($obj->isNew()) { |
||
1689 | $collBannersI18ns[] = $obj; |
||
1690 | } |
||
1691 | } |
||
1692 | } |
||
1693 | |||
1694 | $this->collBannersI18ns = $collBannersI18ns; |
||
1695 | $this->collBannersI18nsPartial = false; |
||
1696 | } |
||
1697 | } |
||
1698 | |||
1699 | return $this->collBannersI18ns; |
||
1700 | } |
||
1701 | |||
1702 | /** |
||
1703 | * Sets a collection of ChildBannersI18n objects related by a one-to-many relationship |
||
1704 | * to the current object. |
||
1705 | * It will also schedule objects for deletion based on a diff between old objects (aka persisted) |
||
1706 | * and new objects from the given Propel collection. |
||
1707 | * |
||
1708 | * @param Collection $bannersI18ns A Propel collection. |
||
1709 | * @param ConnectionInterface $con Optional connection object |
||
1710 | * @return $this|ChildBanners The current object (for fluent API support) |
||
0 ignored issues
–
show
|
|||
1711 | */ |
||
1712 | View Code Duplication | public function setBannersI18ns(Collection $bannersI18ns, ConnectionInterface $con = null) |
|
1713 | { |
||
1714 | /** @var ChildBannersI18n[] $bannersI18nsToDelete */ |
||
1715 | $bannersI18nsToDelete = $this->getBannersI18ns(new Criteria(), $con)->diff($bannersI18ns); |
||
1716 | |||
1717 | |||
1718 | //since at least one column in the foreign key is at the same time a PK |
||
1719 | //we can not just set a PK to NULL in the lines below. We have to store |
||
1720 | //a backup of all values, so we are able to manipulate these items based on the onDelete value later. |
||
1721 | $this->bannersI18nsScheduledForDeletion = clone $bannersI18nsToDelete; |
||
1722 | |||
1723 | foreach ($bannersI18nsToDelete as $bannersI18nRemoved) { |
||
1724 | $bannersI18nRemoved->setBanners(null); |
||
1725 | } |
||
1726 | |||
1727 | $this->collBannersI18ns = null; |
||
1728 | foreach ($bannersI18ns as $bannersI18n) { |
||
1729 | $this->addBannersI18n($bannersI18n); |
||
1730 | } |
||
1731 | |||
1732 | $this->collBannersI18ns = $bannersI18ns; |
||
1733 | $this->collBannersI18nsPartial = false; |
||
1734 | |||
1735 | return $this; |
||
1736 | } |
||
1737 | |||
1738 | /** |
||
1739 | * Returns the number of related BannersI18n objects. |
||
1740 | * |
||
1741 | * @param Criteria $criteria |
||
1742 | * @param boolean $distinct |
||
1743 | * @param ConnectionInterface $con |
||
1744 | * @return int Count of related BannersI18n objects. |
||
1745 | * @throws PropelException |
||
0 ignored issues
–
show
|
|||
1746 | */ |
||
1747 | View Code Duplication | public function countBannersI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) |
|
1748 | { |
||
1749 | $partial = $this->collBannersI18nsPartial && !$this->isNew(); |
||
1750 | if (null === $this->collBannersI18ns || null !== $criteria || $partial) { |
||
1751 | if ($this->isNew() && null === $this->collBannersI18ns) { |
||
1752 | return 0; |
||
1753 | } |
||
1754 | |||
1755 | if ($partial && !$criteria) { |
||
1756 | return count($this->getBannersI18ns()); |
||
1757 | } |
||
1758 | |||
1759 | $query = ChildBannersI18nQuery::create(null, $criteria); |
||
1760 | if ($distinct) { |
||
1761 | $query->distinct(); |
||
1762 | } |
||
1763 | |||
1764 | return $query |
||
1765 | ->filterByBanners($this) |
||
1766 | ->count($con); |
||
1767 | } |
||
1768 | |||
1769 | return count($this->collBannersI18ns); |
||
1770 | } |
||
1771 | |||
1772 | /** |
||
1773 | * Method called to associate a ChildBannersI18n object to this object |
||
1774 | * through the ChildBannersI18n foreign key attribute. |
||
1775 | * |
||
1776 | * @param ChildBannersI18n $l ChildBannersI18n |
||
1777 | * @return $this|\xbanners\models\Banners The current object (for fluent API support) |
||
0 ignored issues
–
show
|
|||
1778 | */ |
||
1779 | View Code Duplication | public function addBannersI18n(ChildBannersI18n $l) |
|
1780 | { |
||
1781 | if ($l && $locale = $l->getLocale()) { |
||
1782 | $this->setLocale($locale); |
||
1783 | $this->currentTranslations[$locale] = $l; |
||
1784 | } |
||
1785 | if ($this->collBannersI18ns === null) { |
||
1786 | $this->initBannersI18ns(); |
||
1787 | $this->collBannersI18nsPartial = true; |
||
1788 | } |
||
1789 | |||
1790 | if (!$this->collBannersI18ns->contains($l)) { |
||
1791 | $this->doAddBannersI18n($l); |
||
1792 | |||
1793 | if ($this->bannersI18nsScheduledForDeletion and $this->bannersI18nsScheduledForDeletion->contains($l)) { |
||
1794 | $this->bannersI18nsScheduledForDeletion->remove($this->bannersI18nsScheduledForDeletion->search($l)); |
||
1795 | } |
||
1796 | } |
||
1797 | |||
1798 | return $this; |
||
1799 | } |
||
1800 | |||
1801 | /** |
||
1802 | * @param ChildBannersI18n $bannersI18n The ChildBannersI18n object to add. |
||
1803 | */ |
||
1804 | protected function doAddBannersI18n(ChildBannersI18n $bannersI18n) |
||
1805 | { |
||
1806 | $this->collBannersI18ns[]= $bannersI18n; |
||
1807 | $bannersI18n->setBanners($this); |
||
1808 | } |
||
1809 | |||
1810 | /** |
||
1811 | * @param ChildBannersI18n $bannersI18n The ChildBannersI18n object to remove. |
||
1812 | * @return $this|ChildBanners The current object (for fluent API support) |
||
0 ignored issues
–
show
|
|||
1813 | */ |
||
1814 | View Code Duplication | public function removeBannersI18n(ChildBannersI18n $bannersI18n) |
|
1815 | { |
||
1816 | if ($this->getBannersI18ns()->contains($bannersI18n)) { |
||
1817 | $pos = $this->collBannersI18ns->search($bannersI18n); |
||
1818 | $this->collBannersI18ns->remove($pos); |
||
1819 | if (null === $this->bannersI18nsScheduledForDeletion) { |
||
1820 | $this->bannersI18nsScheduledForDeletion = clone $this->collBannersI18ns; |
||
1821 | $this->bannersI18nsScheduledForDeletion->clear(); |
||
1822 | } |
||
1823 | $this->bannersI18nsScheduledForDeletion[]= clone $bannersI18n; |
||
1824 | $bannersI18n->setBanners(null); |
||
1825 | } |
||
1826 | |||
1827 | return $this; |
||
1828 | } |
||
1829 | |||
1830 | /** |
||
1831 | * Clears the current object, sets all attributes to their default values and removes |
||
1832 | * outgoing references as well as back-references (from other objects to this one. Results probably in a database |
||
1833 | * change of those foreign objects when you call `save` there). |
||
1834 | */ |
||
1835 | View Code Duplication | public function clear() |
|
1836 | { |
||
1837 | $this->id = null; |
||
1838 | $this->place = null; |
||
1839 | $this->width = null; |
||
1840 | $this->height = null; |
||
1841 | $this->effects = null; |
||
1842 | $this->page_type = null; |
||
1843 | $this->alreadyInSave = false; |
||
1844 | $this->clearAllReferences(); |
||
1845 | $this->resetModified(); |
||
1846 | $this->setNew(true); |
||
1847 | $this->setDeleted(false); |
||
1848 | } |
||
1849 | |||
1850 | /** |
||
1851 | * Resets all references and back-references to other model objects or collections of model objects. |
||
1852 | * |
||
1853 | * This method is used to reset all php object references (not the actual reference in the database). |
||
1854 | * Necessary for object serialisation. |
||
1855 | * |
||
1856 | * @param boolean $deep Whether to also clear the references on all referrer objects. |
||
1857 | */ |
||
1858 | public function clearAllReferences($deep = false) |
||
1859 | { |
||
1860 | if ($deep) { |
||
1861 | if ($this->collBannerImages) { |
||
1862 | foreach ($this->collBannerImages as $o) { |
||
1863 | $o->clearAllReferences($deep); |
||
1864 | } |
||
1865 | } |
||
1866 | if ($this->collBannersI18ns) { |
||
1867 | foreach ($this->collBannersI18ns as $o) { |
||
1868 | $o->clearAllReferences($deep); |
||
1869 | } |
||
1870 | } |
||
1871 | } // if ($deep) |
||
1872 | |||
1873 | // i18n behavior |
||
1874 | $this->currentLocale = 'ru'; |
||
1875 | $this->currentTranslations = null; |
||
1876 | |||
1877 | $this->collBannerImages = null; |
||
1878 | $this->collBannersI18ns = null; |
||
1879 | } |
||
1880 | |||
1881 | /** |
||
1882 | * Return the string representation of this object |
||
1883 | * |
||
1884 | * @return string |
||
1885 | */ |
||
1886 | public function __toString() |
||
1887 | { |
||
1888 | return (string) $this->exportTo(BannersTableMap::DEFAULT_STRING_FORMAT); |
||
1889 | } |
||
1890 | |||
1891 | // i18n behavior |
||
1892 | |||
1893 | /** |
||
1894 | * Sets the locale for translations |
||
1895 | * |
||
1896 | * @param string $locale Locale to use for the translation, e.g. 'fr_FR' |
||
1897 | * |
||
1898 | * @return $this|ChildBanners The current object (for fluent API support) |
||
0 ignored issues
–
show
|
|||
1899 | */ |
||
1900 | public function setLocale($locale = 'ru') |
||
1901 | { |
||
1902 | $this->currentLocale = $locale; |
||
1903 | |||
1904 | return $this; |
||
1905 | } |
||
1906 | |||
1907 | /** |
||
1908 | * Gets the locale for translations |
||
1909 | * |
||
1910 | * @return string $locale Locale to use for the translation, e.g. 'fr_FR' |
||
1911 | */ |
||
1912 | public function getLocale() |
||
1913 | { |
||
1914 | return $this->currentLocale; |
||
1915 | } |
||
1916 | |||
1917 | /** |
||
1918 | * Returns the current translation for a given locale |
||
1919 | * |
||
1920 | * @param string $locale Locale to use for the translation, e.g. 'fr_FR' |
||
1921 | * @param ConnectionInterface $con an optional connection object |
||
1922 | * |
||
1923 | * @return ChildBannersI18n */ |
||
1924 | View Code Duplication | public function getTranslation($locale = 'ru', ConnectionInterface $con = null) |
|
1925 | { |
||
1926 | if (!isset($this->currentTranslations[$locale])) { |
||
1927 | if (null !== $this->collBannersI18ns) { |
||
1928 | foreach ($this->collBannersI18ns as $translation) { |
||
1929 | if ($translation->getLocale() == $locale) { |
||
1930 | $this->currentTranslations[$locale] = $translation; |
||
1931 | |||
1932 | return $translation; |
||
1933 | } |
||
1934 | } |
||
1935 | } |
||
1936 | if ($this->isNew()) { |
||
1937 | $translation = new ChildBannersI18n(); |
||
1938 | $translation->setLocale($locale); |
||
1939 | } else { |
||
1940 | $translation = ChildBannersI18nQuery::create() |
||
1941 | ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) |
||
1942 | ->findOneOrCreate($con); |
||
1943 | $this->currentTranslations[$locale] = $translation; |
||
1944 | } |
||
1945 | $this->addBannersI18n($translation); |
||
1946 | } |
||
1947 | |||
1948 | return $this->currentTranslations[$locale]; |
||
1949 | } |
||
1950 | |||
1951 | /** |
||
1952 | * Remove the translation for a given locale |
||
1953 | * |
||
1954 | * @param string $locale Locale to use for the translation, e.g. 'fr_FR' |
||
1955 | * @param ConnectionInterface $con an optional connection object |
||
1956 | * |
||
1957 | * @return $this|ChildBanners The current object (for fluent API support) |
||
0 ignored issues
–
show
|
|||
1958 | */ |
||
1959 | View Code Duplication | public function removeTranslation($locale = 'ru', ConnectionInterface $con = null) |
|
1960 | { |
||
1961 | if (!$this->isNew()) { |
||
1962 | ChildBannersI18nQuery::create() |
||
1963 | ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) |
||
1964 | ->delete($con); |
||
1965 | } |
||
1966 | if (isset($this->currentTranslations[$locale])) { |
||
1967 | unset($this->currentTranslations[$locale]); |
||
1968 | } |
||
1969 | foreach ($this->collBannersI18ns as $key => $translation) { |
||
1970 | if ($translation->getLocale() == $locale) { |
||
1971 | unset($this->collBannersI18ns[$key]); |
||
1972 | break; |
||
1973 | } |
||
1974 | } |
||
1975 | |||
1976 | return $this; |
||
1977 | } |
||
1978 | |||
1979 | /** |
||
1980 | * Returns the current translation |
||
1981 | * |
||
1982 | * @param ConnectionInterface $con an optional connection object |
||
1983 | * |
||
1984 | * @return ChildBannersI18n */ |
||
1985 | public function getCurrentTranslation(ConnectionInterface $con = null) |
||
1986 | { |
||
1987 | return $this->getTranslation($this->getLocale(), $con); |
||
1988 | } |
||
1989 | |||
1990 | |||
1991 | /** |
||
1992 | * Get the [name] column value. |
||
1993 | * |
||
1994 | * @return string |
||
1995 | */ |
||
1996 | public function getName() |
||
1997 | { |
||
1998 | return $this->getCurrentTranslation()->getName(); |
||
1999 | } |
||
0 ignored issues
–
show
|
|||
2000 | |||
2001 | |||
2002 | /** |
||
2003 | * Set the value of [name] column. |
||
2004 | * |
||
2005 | * @param string $v new value |
||
2006 | * @return $this|\xbanners\models\BannersI18n The current object (for fluent API support) |
||
2007 | */ |
||
2008 | public function setName($v) |
||
2009 | { $this->getCurrentTranslation()->setName($v); |
||
2010 | |||
2011 | return $this; |
||
2012 | } |
||
0 ignored issues
–
show
|
|||
2013 | |||
2014 | /** |
||
2015 | * Code to be run before persisting the object |
||
2016 | * @param ConnectionInterface $con |
||
2017 | * @return boolean |
||
2018 | */ |
||
2019 | public function preSave(ConnectionInterface $con = null) |
||
2020 | { |
||
2021 | if (is_callable('parent::preSave')) { |
||
2022 | return parent::preSave($con); |
||
2023 | } |
||
2024 | return true; |
||
2025 | } |
||
2026 | |||
2027 | /** |
||
2028 | * Code to be run after persisting the object |
||
2029 | * @param ConnectionInterface $con |
||
2030 | */ |
||
2031 | public function postSave(ConnectionInterface $con = null) |
||
2032 | { |
||
2033 | if (is_callable('parent::postSave')) { |
||
2034 | parent::postSave($con); |
||
2035 | } |
||
2036 | } |
||
2037 | |||
2038 | /** |
||
2039 | * Code to be run before inserting to database |
||
2040 | * @param ConnectionInterface $con |
||
2041 | * @return boolean |
||
2042 | */ |
||
2043 | public function preInsert(ConnectionInterface $con = null) |
||
2044 | { |
||
2045 | if (is_callable('parent::preInsert')) { |
||
2046 | return parent::preInsert($con); |
||
2047 | } |
||
2048 | return true; |
||
2049 | } |
||
2050 | |||
2051 | /** |
||
2052 | * Code to be run after inserting to database |
||
2053 | * @param ConnectionInterface $con |
||
2054 | */ |
||
2055 | public function postInsert(ConnectionInterface $con = null) |
||
2056 | { |
||
2057 | if (is_callable('parent::postInsert')) { |
||
2058 | parent::postInsert($con); |
||
2059 | } |
||
2060 | } |
||
2061 | |||
2062 | /** |
||
2063 | * Code to be run before updating the object in database |
||
2064 | * @param ConnectionInterface $con |
||
2065 | * @return boolean |
||
2066 | */ |
||
2067 | public function preUpdate(ConnectionInterface $con = null) |
||
2068 | { |
||
2069 | if (is_callable('parent::preUpdate')) { |
||
2070 | return parent::preUpdate($con); |
||
2071 | } |
||
2072 | return true; |
||
2073 | } |
||
2074 | |||
2075 | /** |
||
2076 | * Code to be run after updating the object in database |
||
2077 | * @param ConnectionInterface $con |
||
2078 | */ |
||
2079 | public function postUpdate(ConnectionInterface $con = null) |
||
2080 | { |
||
2081 | if (is_callable('parent::postUpdate')) { |
||
2082 | parent::postUpdate($con); |
||
2083 | } |
||
2084 | } |
||
2085 | |||
2086 | /** |
||
2087 | * Code to be run before deleting the object in database |
||
2088 | * @param ConnectionInterface $con |
||
2089 | * @return boolean |
||
2090 | */ |
||
2091 | public function preDelete(ConnectionInterface $con = null) |
||
2092 | { |
||
2093 | if (is_callable('parent::preDelete')) { |
||
2094 | return parent::preDelete($con); |
||
2095 | } |
||
2096 | return true; |
||
2097 | } |
||
2098 | |||
2099 | /** |
||
2100 | * Code to be run after deleting the object in database |
||
2101 | * @param ConnectionInterface $con |
||
2102 | */ |
||
2103 | public function postDelete(ConnectionInterface $con = null) |
||
2104 | { |
||
2105 | if (is_callable('parent::postDelete')) { |
||
2106 | parent::postDelete($con); |
||
2107 | } |
||
2108 | } |
||
2109 | |||
2110 | |||
2111 | /** |
||
2112 | * Derived method to catches calls to undefined methods. |
||
2113 | * |
||
2114 | * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). |
||
2115 | * Allows to define default __call() behavior if you overwrite __call() |
||
2116 | * |
||
2117 | * @param string $name |
||
2118 | * @param mixed $params |
||
2119 | * |
||
2120 | * @return array|string |
||
2121 | */ |
||
2122 | View Code Duplication | public function __call($name, $params) |
|
2123 | { |
||
2124 | if (0 === strpos($name, 'get')) { |
||
2125 | $virtualColumn = substr($name, 3); |
||
2126 | if ($this->hasVirtualColumn($virtualColumn)) { |
||
2127 | return $this->getVirtualColumn($virtualColumn); |
||
2128 | } |
||
2129 | |||
2130 | $virtualColumn = lcfirst($virtualColumn); |
||
2131 | if ($this->hasVirtualColumn($virtualColumn)) { |
||
2132 | return $this->getVirtualColumn($virtualColumn); |
||
2133 | } |
||
2134 | } |
||
2135 | |||
2136 | if (0 === strpos($name, 'from')) { |
||
2137 | $format = substr($name, 4); |
||
2138 | |||
2139 | return $this->importFrom($format, reset($params)); |
||
2140 | } |
||
2141 | |||
2142 | if (0 === strpos($name, 'to')) { |
||
2143 | $format = substr($name, 2); |
||
2144 | $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; |
||
2145 | |||
2146 | return $this->exportTo($format, $includeLazyLoadColumns); |
||
2147 | } |
||
2148 | |||
2149 | throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); |
||
2150 | } |
||
2151 | |||
2152 | } |
||
2153 |