1616use Shopsys \FrameworkBundle \Model \Store \Exception \StoreDomainNotFoundException ;
1717use Shopsys \FrameworkBundle \Model \Store \OpeningHours \Exception \OpeningHoursNotFoundException ;
1818use Shopsys \FrameworkBundle \Model \Store \OpeningHours \OpeningHours ;
19- use Shopsys \FrameworkBundle \Model \Store \OpeningHours \OpeningHoursData ;
2019
2120/**
2221 * @ORM\Table(name="stores")
@@ -104,7 +103,7 @@ class Store implements OrderableEntityInterface
104103
105104 /**
106105 * @var \Doctrine\Common\Collections\Collection<int,\Shopsys\FrameworkBundle\Model\Store\OpeningHours\OpeningHours>
107- * @ORM\OneToMany(targetEntity="\Shopsys\FrameworkBundle\Model\Store\OpeningHours\OpeningHours", mappedBy="store", cascade={"persist", "remove"}, orphanRemoval=true, fetch="EAGER" )
106+ * @ORM\OneToMany(targetEntity="\Shopsys\FrameworkBundle\Model\Store\OpeningHours\OpeningHours", mappedBy="store", cascade={"persist", "remove"}, orphanRemoval=true)
108107 * @ORM\OrderBy({"dayOfWeek" = "ASC"})
109108 */
110109 protected $ openingHours ;
@@ -160,6 +159,18 @@ public function edit(StoreData $storeData)
160159 {
161160 $ this ->setDomains ($ storeData );
162161 $ this ->setData ($ storeData );
162+
163+ foreach ($ this ->openingHours as $ index => $ openingHours ) {
164+ $ openingHours ->edit ($ storeData ->openingHours [$ index ]);
165+ }
166+ }
167+
168+ /**
169+ * @param \Shopsys\FrameworkBundle\Model\Store\OpeningHours\OpeningHours[] $openingHours
170+ */
171+ public function setOpeningHours (array $ openingHours ): void
172+ {
173+ $ this ->openingHours = new ArrayCollection ($ openingHours );
163174 }
164175
165176 /**
@@ -176,7 +187,6 @@ public function setData(StoreData $storeData): void
176187 $ this ->city = $ storeData ->city ;
177188 $ this ->postcode = $ storeData ->postcode ;
178189 $ this ->country = $ storeData ->country ;
179- $ this ->openingHours = $ this ->createOpeningHours ($ storeData ->openingHours );
180190 $ this ->contactInfo = $ storeData ->contactInfo ;
181191 $ this ->specialMessage = $ storeData ->specialMessage ;
182192 $ this ->locationLatitude = $ storeData ->locationLatitude ;
@@ -443,20 +453,4 @@ public function setDefault(): void
443453 {
444454 $ this ->isDefault = true ;
445455 }
446-
447- /**
448- * @param \Shopsys\FrameworkBundle\Model\Store\OpeningHours\OpeningHoursData[] $openingHours
449- * @return \Doctrine\Common\Collections\ArrayCollection
450- */
451- protected function createOpeningHours (array $ openingHours ): ArrayCollection
452- {
453- $ openingHours = array_map (function (OpeningHoursData $ openingHourData ): OpeningHours {
454- $ openingHours = new OpeningHours ($ openingHourData );
455- $ openingHours ->setStore ($ this );
456-
457- return $ openingHours ;
458- }, $ openingHours );
459-
460- return new ArrayCollection ($ openingHours );
461- }
462456}
0 commit comments