Failed Conditions
Pull Request — experimental/sf (#31)
by Kentaro
06:59
created

Page   F

Complexity

Total Complexity 93

Size/Duplication

Total Lines 869
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 869
rs 1.731
c 0
b 0
f 0
wmc 93
lcom 2
cbo 3

66 Methods

Rating   Name   Duplication   Size   Complexity  
A getLayouts() 0 9 2
A getColumnNum() 0 4 3
B getTheme() 0 16 7
A getBlocksPositionByTargetId() 0 11 3
A getUnusedPosition() 0 4 1
A getHeadPosition() 0 4 1
A getHeaderPosition() 0 4 1
A getContentsTopPosition() 0 4 1
A getSideLeftPosition() 0 4 1
A getMainTopPosition() 0 4 1
A getMainBottomPosition() 0 4 1
A getSideRightPosition() 0 4 1
A getContentsBottomPosition() 0 4 1
A getFooterPosition() 0 4 1
A getBlocksByTargetId() 0 11 3
A getUnused() 0 4 1
A getHead() 0 6 2
A getBodyAfter() 0 6 2
A getHeader() 0 6 2
A getContentsTop() 0 6 2
A getSideLeft() 0 6 2
A getMainTop() 0 6 2
A getMainBottom() 0 6 2
A getSideRight() 0 6 2
A getContentsBottom() 0 6 2
A getFooter() 0 6 2
A getDrawer() 0 6 2
A getCloseBodyBefore() 0 6 2
A __construct() 0 5 1
A setId() 0 6 1
A getId() 0 4 1
A setName() 0 6 1
A getName() 0 4 1
A setUrl() 0 6 1
A getUrl() 0 4 1
A setFileName() 0 6 1
A getFileName() 0 4 1
A setEditType() 0 6 1
A getEditType() 0 4 1
A setAuthor() 0 6 1
A getAuthor() 0 4 1
A setDescription() 0 6 1
A getDescription() 0 4 1
A setKeyword() 0 6 1
A getKeyword() 0 4 1
A setUpdateUrl() 0 6 1
A getUpdateUrl() 0 4 1
A setCreateDate() 0 6 1
A getCreateDate() 0 4 1
A setUpdateDate() 0 6 1
A getUpdateDate() 0 4 1
A setMetaRobots() 0 6 1
A getMetaRobots() 0 4 1
A setMetaTags() 0 6 1
A getMetaTags() 0 4 1
A addBlockPosition() 0 6 1
A removeBlockPosition() 0 4 1
A getPageLayouts() 0 4 1
A addPageLayout() 0 6 1
A removePageLayout() 0 4 1
A getBlockPositions() 0 4 1
A setDeviceType() 0 6 1
A getDeviceType() 0 4 1
A setMasterPage() 0 6 1
A getMasterPage() 0 4 1
A getSortNo() 0 13 3

How to fix   Complexity   

Complex Class

Complex classes like Page often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Page, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) LOCKON CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.lockon.co.jp/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Eccube\Entity;
15
16
use Doctrine\ORM\Mapping as ORM;
17
18
if (!class_exists('\Eccube\Entity\Page')) {
19
    /**
20
     * Page
21
     *
22
     * @ORM\Table(name="dtb_page", indexes={@ORM\Index(name="dtb_page_url_idx", columns={"url"})})
23
     * @ORM\InheritanceType("SINGLE_TABLE")
24
     * @ORM\DiscriminatorColumn(name="discriminator_type", type="string", length=255)
25
     * @ORM\HasLifecycleCallbacks()
26
     * @ORM\Entity(repositoryClass="Eccube\Repository\PageRepository")
27
     */
28
    class Page extends \Eccube\Entity\AbstractEntity
29
    {
30
        // 配置ID
31
        /** 配置ID: 未使用 */
32
        const TARGET_ID_UNUSED = 0;
33
        const TARGET_ID_HEAD = 1;
34
        const TARGET_ID_BODY_AFTER = 2;
35
        const TARGET_ID_HEADER = 3;
36
        const TARGET_ID_CONTENTS_TOP = 4;
37
        const TARGET_ID_SIDE_LEFT = 5;
38
        const TARGET_ID_MAIN_TOP = 6;
39
        const TARGET_ID_MAIN_BOTTOM = 7;
40
        const TARGET_ID_SIDE_RIGHT = 8;
41
        const TARGET_ID_CONTENTS_BOTTOM = 9;
42
        const TARGET_ID_FOOTER = 10;
43
        const TARGET_ID_DRAWER = 11;
44
        const TARGET_ID_CLOSE_BODY_BEFORE = 12;
45
46
        // 編集可能フラグ
47
        const EDIT_TYPE_USER = 0;
48
        const EDIT_TYPE_PREVIEW = 1;
49
        const EDIT_TYPE_DEFAULT = 2;
50
51
        public function getLayouts()
52
        {
53
            $Layouts = [];
54
            foreach ($this->PageLayouts as $PageLayout) {
55
                $Layouts[] = $PageLayout->getLayout();
56
            }
57
58
            return $Layouts;
59
        }
60
61
        /**
62
         * Get ColumnNum
63
         *
64
         * @return integer
65
         */
66
        public function getColumnNum()
67
        {
68
            return 1 + ($this->getSideLeft() ? 1 : 0) + ($this->getSideRight() ? 1 : 0);
69
        }
70
71
        public function getTheme()
72
        {
73
            $hasLeft = $this->getSideLeft() ? true : false;
74
            $hasRight = $this->getSideRight() ? true : false;
75
76
            $theme = 'theme_main_only';
77
            if ($hasLeft && $hasRight) {
78
                $theme = 'theme_side_both';
79
            } elseif ($hasLeft) {
80
                $theme = 'theme_side_left';
81
            } elseif ($hasRight) {
82
                $theme = 'theme_side_right';
83
            }
84
85
            return $theme;
86
        }
87
88
        /**
89
         * Get BlockPositionByTargetId
90
         *
91
         * @param integer $target_id
92
         *
93
         * @return array
94
         */
95
        public function getBlocksPositionByTargetId($target_id)
96
        {
97
            $BlockPositions = [];
98
            foreach ($this->getBlockPositions() as $BlockPosition) {
99
                if ($BlockPosition->getSection() === $target_id) {
100
                    $BlockPositions[] = $BlockPosition;
101
                }
102
            }
103
104
            return $BlockPositions;
105
        }
106
107
        /**
108
         * @deprecated
109
         *
110
         * @return BlockPosition
111
         */
112
        public function getUnusedPosition()
113
        {
114
            return $this->getBlocksPositionByTargetId(self::TARGET_ID_UNUSED);
115
        }
116
117
        /**
118
         * @deprecated
119
         *
120
         * @return BlockPosition
121
         */
122
        public function getHeadPosition()
123
        {
124
            return $this->getBlocksPositionByTargetId(self::TARGET_ID_HEAD);
125
        }
126
127
        /**
128
         * @deprecated
129
         *
130
         * @return BlockPosition
131
         */
132
        public function getHeaderPosition()
133
        {
134
            return $this->getBlocksPositionByTargetId(self::TARGET_ID_HEADER);
135
        }
136
137
        /**
138
         * @deprecated
139
         *
140
         * @return BlockPosition
141
         */
142
        public function getContentsTopPosition()
143
        {
144
            return $this->getBlocksPositionByTargetId(self::TARGET_ID_CONTENTS_TOP);
145
        }
146
147
        /**
148
         * @deprecated
149
         *
150
         * @return BlockPosition
151
         */
152
        public function getSideLeftPosition()
153
        {
154
            return $this->getBlocksPositionByTargetId(self::TARGET_ID_SIDE_LEFT);
155
        }
156
157
        /**
158
         * @deprecated
159
         *
160
         * @return BlockPosition
161
         */
162
        public function getMainTopPosition()
163
        {
164
            return $this->getBlocksPositionByTargetId(self::TARGET_ID_MAIN_TOP);
165
        }
166
167
        /**
168
         * @deprecated
169
         *
170
         * @return BlockPosition
171
         */
172
        public function getMainBottomPosition()
173
        {
174
            return $this->getBlocksPositionByTargetId(self::TARGET_ID_MAIN_BOTTOM);
175
        }
176
177
        /**
178
         * @deprecated
179
         *
180
         * @return BlockPosition
181
         */
182
        public function getSideRightPosition()
183
        {
184
            return $this->getBlocksPositionByTargetId(self::TARGET_ID_SIDE_RIGHT);
185
        }
186
187
        /**
188
         * @deprecated
189
         *
190
         * @return BlockPosition
191
         */
192
        public function getContentsBottomPosition()
193
        {
194
            return $this->getBlocksPositionByTargetId(self::TARGET_ID_CONTENTS_BOTTOM);
195
        }
196
197
        public function getFooterPosition()
198
        {
199
            return $this->getBlocksPositionByTargetId(self::TARGET_ID_FOOTER);
200
        }
201
202
        /**
203
         * @deprecated
204
         *
205
         * Get BlocsByTargetId
206
         *
207
         * @param integer $target_id
208
         *
209
         * @return \Eccube\Entity\Block[]
210
         */
211
        public function getBlocksByTargetId($target_id)
212
        {
213
            $Blocks = [];
214
            foreach ($this->getBlockPositions() as $BlockPositions) {
215
                if ($BlockPositions->getTargetId() === $target_id) {
216
                    $Blocks[] = $BlockPositions->getBlock();
217
                }
218
            }
219
220
            return $Blocks;
221
        }
222
223
        public function getUnused()
224
        {
225
            return $this->getBlocksByTargetId(self::TARGET_ID_UNUSED);
0 ignored issues
show
Deprecated Code introduced by
The method Eccube\Entity\Page::getBlocksByTargetId() has been deprecated with message: Get BlocsByTargetId

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
226
        }
227
228
        public function getHead()
229
        {
230
            $Layout = current($this->getLayouts());
231
232
            return $Layout ? $Layout->getBlocks(self::TARGET_ID_HEAD) : [];
233
        }
234
235
        public function getBodyAfter()
236
        {
237
            $Layout = current($this->getLayouts());
238
239
            return $Layout ? $Layout->getBlocks(self::TARGET_ID_BODY_AFTER) : [];
240
        }
241
242
        public function getHeader()
243
        {
244
            $Layout = current($this->getLayouts());
245
246
            return $Layout ? $Layout->getBlocks(self::TARGET_ID_HEADER) : [];
247
        }
248
249
        public function getContentsTop()
250
        {
251
            $Layout = current($this->getLayouts());
252
253
            return $Layout ? $Layout->getBlocks(self::TARGET_ID_CONTENTS_TOP) : [];
254
        }
255
256
        public function getSideLeft()
257
        {
258
            $Layout = current($this->getLayouts());
259
260
            return $Layout ? $Layout->getBlocks(self::TARGET_ID_SIDE_LEFT) : [];
261
        }
262
263
        public function getMainTop()
264
        {
265
            $Layout = current($this->getLayouts());
266
267
            return $Layout ? $Layout->getBlocks(self::TARGET_ID_MAIN_TOP) : [];
268
        }
269
270
        public function getMainBottom()
271
        {
272
            $Layout = current($this->getLayouts());
273
274
            return $Layout ? $Layout->getBlocks(self::TARGET_ID_MAIN_BOTTOM) : [];
275
        }
276
277
        public function getSideRight()
278
        {
279
            $Layout = current($this->getLayouts());
280
281
            return $Layout ? $Layout->getBlocks(self::TARGET_ID_SIDE_RIGHT) : [];
282
        }
283
284
        public function getContentsBottom()
285
        {
286
            $Layout = current($this->getLayouts());
287
288
            return $Layout ? $Layout->getBlocks(self::TARGET_ID_CONTENTS_BOTTOM) : [];
289
        }
290
291
        public function getFooter()
292
        {
293
            $Layout = current($this->getLayouts());
294
295
            return $Layout ? $Layout->getBlocks(self::TARGET_ID_FOOTER) : [];
296
        }
297
298
        public function getDrawer()
299
        {
300
            $Layout = current($this->getLayouts());
301
302
            return $Layout ? $Layout->getBlocks(self::TARGET_ID_DRAWER) : [];
303
        }
304
305
        public function getCloseBodyBefore()
306
        {
307
            $Layout = current($this->getLayouts());
308
309
            return $Layout ? $Layout->getBlocks(self::TARGET_ID_CLOSE_BODY_BEFORE) : [];
310
        }
311
312
        /**
313
         * @var int
314
         *
315
         * @ORM\Column(name="id", type="integer", options={"unsigned":true})
316
         * @ORM\Id
317
         * @ORM\GeneratedValue(strategy="IDENTITY")
318
         */
319
        private $id;
320
321
        /**
322
         * @var string|null
323
         *
324
         * @ORM\Column(name="page_name", type="string", length=255, nullable=true)
325
         */
326
        private $name;
327
328
        /**
329
         * @var string
330
         *
331
         * @ORM\Column(name="url", type="string", length=255)
332
         */
333
        private $url;
334
335
        /**
336
         * @var string|null
337
         *
338
         * @ORM\Column(name="file_name", type="string", length=255, nullable=true)
339
         */
340
        private $file_name;
341
342
        /**
343
         * @var int
344
         *
345
         * @ORM\Column(name="edit_type", type="smallint", options={"unsigned":true,"default":1})
346
         */
347
        private $edit_type = 1;
348
349
        /**
350
         * @var string|null
351
         *
352
         * @ORM\Column(name="author", type="string", length=255, nullable=true)
353
         */
354
        private $author;
355
356
        /**
357
         * @var string|null
358
         *
359
         * @ORM\Column(name="description", type="string", length=255, nullable=true)
360
         */
361
        private $description;
362
363
        /**
364
         * @var string|null
365
         *
366
         * @ORM\Column(name="keyword", type="string", length=255, nullable=true)
367
         */
368
        private $keyword;
369
370
        /**
371
         * @var string|null
372
         *
373
         * @ORM\Column(name="update_url", type="string", length=255, nullable=true)
374
         */
375
        private $update_url;
376
377
        /**
378
         * @var \DateTime
379
         *
380
         * @ORM\Column(name="create_date", type="datetimetz")
381
         */
382
        private $create_date;
383
384
        /**
385
         * @var \DateTime
386
         *
387
         * @ORM\Column(name="update_date", type="datetimetz")
388
         */
389
        private $update_date;
390
391
        /**
392
         * @var string|null
393
         *
394
         * @ORM\Column(name="meta_robots", type="string", length=255, nullable=true)
395
         */
396
        private $meta_robots;
397
398
        /**
399
         * @var string|null
400
         *
401
         * @ORM\Column(name="meta_tags", type="string", length=4000, nullable=true)
402
         */
403
        private $meta_tags;
404
405
        /**
406
         * @var \Doctrine\Common\Collections\Collection
407
         *
408
         * @ORM\OneToMany(targetEntity="Eccube\Entity\BlockPosition", mappedBy="Page", cascade={"persist","remove"})
409
         *
410
         * @deprecated
411
         */
412
        private $BlockPositions;
413
414
        /**
415
         * @var \Doctrine\Common\Collections\Collection
416
         *
417
         * @ORM\OneToMany(targetEntity="Eccube\Entity\PageLayout", mappedBy="Page", cascade={"persist","remove"})
418
         */
419
        private $PageLayouts;
420
421
        /**
422
         * @var \Eccube\Entity\Master\DeviceType
423
         *
424
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\DeviceType")
425
         * @ORM\JoinColumns({
426
         *   @ORM\JoinColumn(name="device_type_id", referencedColumnName="id")
427
         * })
428
         */
429
        private $DeviceType;
430
431
        /**
432
         * @var \Eccube\Entity\Page
433
         *
434
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Page")
435
         * @ORM\JoinColumns({
436
         *   @ORM\JoinColumn(name="master_page_id", referencedColumnName="id")
437
         * })
438
         */
439
        private $MasterPage;
440
441
        /**
442
         * Constructor
443
         */
444
        public function __construct()
445
        {
446
            $this->BlockPositions = new \Doctrine\Common\Collections\ArrayCollection();
0 ignored issues
show
Deprecated Code introduced by
The property Eccube\Entity\Page::$BlockPositions has been deprecated.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
447
            $this->PageLayouts = new \Doctrine\Common\Collections\ArrayCollection();
448
        }
449
450
        /**
451
         * Set id
452
         *
453
         * @return Page
454
         */
455
        public function setId($id)
456
        {
457
            $this->id = $id;
458
459
            return $this;
460
        }
461
462
        /**
463
         * Get id
464
         *
465
         * @return integer
466
         */
467
        public function getId()
468
        {
469
            return $this->id;
470
        }
471
472
        /**
473
         * Set name.
474
         *
475
         * @param string|null $name
476
         *
477
         * @return Page
478
         */
479
        public function setName($name = null)
480
        {
481
            $this->name = $name;
482
483
            return $this;
484
        }
485
486
        /**
487
         * Get name.
488
         *
489
         * @return string|null
490
         */
491
        public function getName()
492
        {
493
            return $this->name;
494
        }
495
496
        /**
497
         * Set url.
498
         *
499
         * @param string $url
500
         *
501
         * @return Page
502
         */
503
        public function setUrl($url)
504
        {
505
            $this->url = $url;
506
507
            return $this;
508
        }
509
510
        /**
511
         * Get url.
512
         *
513
         * @return string
514
         */
515
        public function getUrl()
516
        {
517
            return $this->url;
518
        }
519
520
        /**
521
         * Set fileName.
522
         *
523
         * @param string|null $fileName
524
         *
525
         * @return Page
526
         */
527
        public function setFileName($fileName = null)
528
        {
529
            $this->file_name = $fileName;
530
531
            return $this;
532
        }
533
534
        /**
535
         * Get fileName.
536
         *
537
         * @return string|null
538
         */
539
        public function getFileName()
540
        {
541
            return $this->file_name;
542
        }
543
544
        /**
545
         * Set editType.
546
         *
547
         * @param int $editType
548
         *
549
         * @return Page
550
         */
551
        public function setEditType($editType)
552
        {
553
            $this->edit_type = $editType;
554
555
            return $this;
556
        }
557
558
        /**
559
         * Get editType.
560
         *
561
         * @return int
562
         */
563
        public function getEditType()
564
        {
565
            return $this->edit_type;
566
        }
567
568
        /**
569
         * Set author.
570
         *
571
         * @param string|null $author
572
         *
573
         * @return Page
574
         */
575
        public function setAuthor($author = null)
576
        {
577
            $this->author = $author;
578
579
            return $this;
580
        }
581
582
        /**
583
         * Get author.
584
         *
585
         * @return string|null
586
         */
587
        public function getAuthor()
588
        {
589
            return $this->author;
590
        }
591
592
        /**
593
         * Set description.
594
         *
595
         * @param string|null $description
596
         *
597
         * @return Page
598
         */
599
        public function setDescription($description = null)
600
        {
601
            $this->description = $description;
602
603
            return $this;
604
        }
605
606
        /**
607
         * Get description.
608
         *
609
         * @return string|null
610
         */
611
        public function getDescription()
612
        {
613
            return $this->description;
614
        }
615
616
        /**
617
         * Set keyword.
618
         *
619
         * @param string|null $keyword
620
         *
621
         * @return Page
622
         */
623
        public function setKeyword($keyword = null)
624
        {
625
            $this->keyword = $keyword;
626
627
            return $this;
628
        }
629
630
        /**
631
         * Get keyword.
632
         *
633
         * @return string|null
634
         */
635
        public function getKeyword()
636
        {
637
            return $this->keyword;
638
        }
639
640
        /**
641
         * Set updateUrl.
642
         *
643
         * @param string|null $updateUrl
644
         *
645
         * @return Page
646
         */
647
        public function setUpdateUrl($updateUrl = null)
648
        {
649
            $this->update_url = $updateUrl;
650
651
            return $this;
652
        }
653
654
        /**
655
         * Get updateUrl.
656
         *
657
         * @return string|null
658
         */
659
        public function getUpdateUrl()
660
        {
661
            return $this->update_url;
662
        }
663
664
        /**
665
         * Set createDate.
666
         *
667
         * @param \DateTime $createDate
668
         *
669
         * @return Page
670
         */
671
        public function setCreateDate($createDate)
672
        {
673
            $this->create_date = $createDate;
674
675
            return $this;
676
        }
677
678
        /**
679
         * Get createDate.
680
         *
681
         * @return \DateTime
682
         */
683
        public function getCreateDate()
684
        {
685
            return $this->create_date;
686
        }
687
688
        /**
689
         * Set updateDate.
690
         *
691
         * @param \DateTime $updateDate
692
         *
693
         * @return Page
694
         */
695
        public function setUpdateDate($updateDate)
696
        {
697
            $this->update_date = $updateDate;
698
699
            return $this;
700
        }
701
702
        /**
703
         * Get updateDate.
704
         *
705
         * @return \DateTime
706
         */
707
        public function getUpdateDate()
708
        {
709
            return $this->update_date;
710
        }
711
712
        /**
713
         * Set metaRobots.
714
         *
715
         * @param string|null $metaRobots
716
         *
717
         * @return Page
718
         */
719
        public function setMetaRobots($metaRobots = null)
720
        {
721
            $this->meta_robots = $metaRobots;
722
723
            return $this;
724
        }
725
726
        /**
727
         * Get metaRobots.
728
         *
729
         * @return string|null
730
         */
731
        public function getMetaRobots()
732
        {
733
            return $this->meta_robots;
734
        }
735
736
        /**
737
         * Set meta_tags
738
         *
739
         * @param string $metaTags
740
         *
741
         * @return Page
742
         */
743
        public function setMetaTags($metaTags)
744
        {
745
            $this->meta_tags = $metaTags;
746
747
            return $this;
748
        }
749
750
        /**
751
         * Get meta_tags
752
         *
753
         * @return string
754
         */
755
        public function getMetaTags()
756
        {
757
            return $this->meta_tags;
758
        }
759
760
        /**
761
         * Add blockPosition.
762
         *
763
         * @param \Eccube\Entity\BlockPosition $blockPosition
764
         *
765
         * @return Page
766
         */
767
        public function addBlockPosition(\Eccube\Entity\BlockPosition $blockPosition)
768
        {
769
            $this->BlockPositions[] = $blockPosition;
0 ignored issues
show
Deprecated Code introduced by
The property Eccube\Entity\Page::$BlockPositions has been deprecated.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
770
771
            return $this;
772
        }
773
774
        /**
775
         * Remove blockPosition.
776
         *
777
         * @param \Eccube\Entity\BlockPosition $blockPosition
778
         *
779
         * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
780
         */
781
        public function removeBlockPosition(\Eccube\Entity\BlockPosition $blockPosition)
782
        {
783
            return $this->BlockPositions->removeElement($blockPosition);
0 ignored issues
show
Deprecated Code introduced by
The property Eccube\Entity\Page::$BlockPositions has been deprecated.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
784
        }
785
786
        /**
787
         * Get pageLayoutLayout.
788
         *
789
         * @return \Doctrine\Common\Collections\Collection
790
         */
791
        public function getPageLayouts()
792
        {
793
            return $this->PageLayouts;
794
        }
795
796
        /**
797
         * Add pageLayoutLayout
798
         *
799
         * @param \Eccube\Entity\PageLayout $PageLayout
800
         *
801
         * @return Page
802
         */
803
        public function addPageLayout(\Eccube\Entity\PageLayout $PageLayout)
804
        {
805
            $this->PageLayouts[] = $PageLayout;
806
807
            return $this;
808
        }
809
810
        /**
811
         * Remove pageLayoutLayout
812
         *
813
         * @param \Eccube\Entity\PageLayout $PageLayout
814
         */
815
        public function removePageLayout(\Eccube\Entity\PageLayout $PageLayout)
816
        {
817
            $this->PageLayouts->removeElement($PageLayout);
818
        }
819
820
        /**
821
         * Get blockPositions.
822
         *
823
         * @return \Doctrine\Common\Collections\Collection
824
         */
825
        public function getBlockPositions()
826
        {
827
            return $this->BlockPositions;
0 ignored issues
show
Deprecated Code introduced by
The property Eccube\Entity\Page::$BlockPositions has been deprecated.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
828
        }
829
830
        /**
831
         * Set deviceType.
832
         *
833
         * @param \Eccube\Entity\Master\DeviceType|null $deviceType
834
         *
835
         * @return Page
836
         */
837
        public function setDeviceType(\Eccube\Entity\Master\DeviceType $deviceType = null)
838
        {
839
            $this->DeviceType = $deviceType;
840
841
            return $this;
842
        }
843
844
        /**
845
         * Get deviceType.
846
         *
847
         * @return \Eccube\Entity\Master\DeviceType|null
848
         */
849
        public function getDeviceType()
850
        {
851
            return $this->DeviceType;
852
        }
853
854
        /**
855
         * Set MasterPage.
856
         *
857
         * @param \Eccube\Entity\Page|null $page
858
         *
859
         * @return Page
860
         */
861
        public function setMasterPage(\Eccube\Entity\Page $page = null)
862
        {
863
            $this->MasterPage = $page;
864
865
            return $this;
866
        }
867
868
        /**
869
         * Get MasterPage.
870
         *
871
         * @return \Eccube\Entity\Page|null
872
         */
873
        public function getMasterPage()
874
        {
875
            return $this->MasterPage;
876
        }
877
878
        /**
879
         * @param $layoutId
880
         *
881
         * @return null|int
882
         */
883
        public function getSortNo($layoutId)
884
        {
885
            $pageLayouts = $this->getPageLayouts();
886
887
            /** @var PageLayout $pageLayout */
888
            foreach ($pageLayouts as $pageLayout) {
889
                if ($pageLayout->getLayoutId() == $layoutId) {
890
                    return $pageLayout->getSortNo();
891
                }
892
            }
893
894
            return null;
895
        }
896
    }
897
}
898