1919use Smile \StoreLocator \Api \Data \RetailerAddressInterface ;
2020use Smile \StoreLocator \Block \AbstractView ;
2121
22-
2322/**
2423 * Map rendering block.
2524 *
@@ -54,24 +53,23 @@ class Map extends AbstractView
5453 */
5554 private $ scheduleManager ;
5655
57-
5856 /**
5957 * @var RetailerCollectionFactory
6058 */
6159 private $ retailerCollectionFactory ;
6260
63-
6461 /**
6562 * Constructor.
6663 *
67- * @param \Magento\Framework\View\Element\Template\Context $context Application context.
68- * @param \Magento\Framework\Registry $coreRegistry Application registry.
69- * @param \Smile\Map\Api\MapProviderInterface $mapProvider Map configuration provider.
70- * @param \Smile\StoreLocator\Helper\Data $storeLocatorHelper Store locacator helper.
71- * @param AddressFormatter $addressFormatter Address formatter.
72- * @param \Smile\StoreLocator\Helper\Schedule $scheduleHelper Schedule Helper
73- * @param \Smile\StoreLocator\Model\Retailer\ScheduleManagement $scheduleManagement Schedule Management
74- * @param array $data Additional data.
64+ * @param \Magento\Framework\View\Element\Template\Context $context Application context.
65+ * @param \Magento\Framework\Registry $coreRegistry Application registry.
66+ * @param \Smile\Map\Api\MapProviderInterface $mapProvider Map configuration provider.
67+ * @param \Smile\StoreLocator\Helper\Data $storeLocatorHelper Store locacator helper.
68+ * @param AddressFormatter $addressFormatter Address formatter.
69+ * @param \Smile\StoreLocator\Helper\Schedule $scheduleHelper Schedule Helper
70+ * @param \Smile\StoreLocator\Model\Retailer\ScheduleManagement $scheduleManagement Schedule Management
71+ * @param \Smile\Retailer\Model\ResourceModel\Retailer\CollectionFactory $retailerCollectionFactory The retailer collection factory.
72+ * @param array $data Additional data.
7573 */
7674
7775 public function __construct (
@@ -105,8 +103,13 @@ public function getAddress()
105103 return $ this ->getRetailer ()->getAddress ();
106104 }
107105
108-
109- public function getId () {
106+ /**
107+ * Return the retailer ID.
108+ *
109+ * @return int|null
110+ */
111+ public function getId ()
112+ {
110113 return $ this ->getRetailer ()->getId ();
111114 }
112115
@@ -142,35 +145,33 @@ public function getJsLayout()
142145 return json_encode ($ jsLayout );
143146 }
144147
145-
146148 /**
147149 * Create full marker data for store view.
148150 *
149151 * @return array|null
150152 */
151- public function getMarkerData () {
152-
153+ public function getMarkerData ()
154+ {
153155 $ result = null ;
154156 $ mediaPath = $ this ->getMediaPath ();
155157 $ imageUrlRetailer = $ this ->getImageUrl () . 'seller/ ' ;
156158 $ image = $ mediaPath ? $ imageUrlRetailer . $ mediaPath : false ;
157159 $ retailer = $ this ->getRetailer ();
158160
159-
160161 $ storeMarkerData = [
161162 'latitude ' => $ this ->getCoordinates ()->getLatitude (),
162163 'longitude ' => $ this ->getCoordinates ()->getLongitude (),
163164 'image ' => $ image ,
164165 'id ' => $ this ->getId (),
165166 'phone ' => $ this ->getPhone (),
166- 'mail ' => $ this ->getContactMailMail (),
167+ 'mail ' => $ this ->getContactMail (),
167168 'closestShops ' => $ this ->collectionFull (),
168169 ];
169170 $ storeMarkerData ['schedule ' ] = array_merge (
170171 $ this ->scheduleHelper ->getConfig (),
171172 [
172- 'calendar ' => $ this ->scheduleManager ->getCalendar ($ retailer ),
173- 'openingHours ' => $ this ->scheduleManager ->getWeekOpeningHours ($ retailer ),
173+ 'calendar ' => $ this ->scheduleManager ->getCalendar ($ retailer ),
174+ 'openingHours ' => $ this ->scheduleManager ->getWeekOpeningHours ($ retailer ),
174175 'specialOpeningHours ' => $ retailer ->getExtensionAttributes ()->getSpecialOpeningHours (),
175176 ]
176177 );
@@ -200,7 +201,6 @@ public function getAddressHtml()
200201 return $ this ->addressFormatter ->formatAddress ($ this ->getAddress (), AddressFormatter::FORMAT_HTML );
201202 }
202203
203-
204204 /**
205205 * Get URL used to redirect user to the direction API.
206206 *
@@ -227,99 +227,73 @@ public function getDescription()
227227 * @return mixed
228228 * @throws \Magento\Framework\Exception\NoSuchEntityException
229229 */
230- public function getImageUrl (){
231-
230+ public function getImageUrl ()
231+ {
232232 $ currentStore = $ this ->_storeManager ->getStore ();
233- $ mediaUrl = $ currentStore ->getBaseUrl (\Magento \Framework \UrlInterface::URL_TYPE_MEDIA );
234233
235- return $ mediaUrl ;
234+ return $ currentStore -> getBaseUrl (\ Magento \ Framework \UrlInterface:: URL_TYPE_MEDIA ) ;
236235 }
237236
238237 /**
239238 * Get image name.
240239 *
241240 * @return bool|string
242241 */
243- protected function getMediaPath () {
244-
245- $ retailer = $ this ->getRetailer ();
246-
247- return $ retailer ? $ retailer ->getMediaPath () : false ;
248- }
249-
250- /**
251- * Get current retailer.
252- *
253- * @return \Smile\Retailer\Api\Data\RetailerInterface
254- */
255- protected function currentRetailer () {
256-
257- $ retailer = $ this ->getRetailer ();
258-
259- return $ retailer ;
242+ protected function getMediaPath ()
243+ {
244+ return $ this ->getRetailer ()->getMediaPath () ?: false ;
260245 }
261246
262247 /**
263248 * Get full image url.
264249 *
265250 * @return bool|string
266251 */
267- public function getImage () {
268-
252+ public function getImage ()
253+ {
269254 $ mediaPath = $ this ->getMediaPath ();
270255 $ imageUrlRetailer = $ this ->getImageUrl () . 'seller/ ' ;
271- $ image = $ mediaPath ? $ imageUrlRetailer . $ mediaPath : false ;
272256
273- return $ image ;
257+ return $ mediaPath ? $ imageUrlRetailer . $ mediaPath : false ;
274258 }
275259
276260 /**
277261 * Get store name.
278262 *
279263 * @return string
280264 */
281- public function getStoreName () {
282-
283- $ name = $ this ->getRetailer ()->getName ();
284-
285- return $ name ;
265+ public function getStoreName ()
266+ {
267+ return $ this ->getRetailer ()->getName ();
286268 }
287269
288270 /**
289271 * Get phone number.
290272 *
291- * @return null |string
273+ * @return bool |string
292274 */
293- public function getPhone () {
294-
295- $ retailer = $ this ->getRetailer ();
296- $ phone = $ retailer ->getContactPhone ();
297- $ result = $ phone ? $ phone : false ;
298-
299- return $ result ;
275+ public function getPhone ()
276+ {
277+ return $ this ->getRetailer ()->getContactPhone () ?: false ;
300278 }
301279
302280 /**
303281 * Get email address.
304282 *
305- * @return null |string
283+ * @return bool |string
306284 */
307- public function getContactMailMail () {
308-
309- $ retailer = $ this ->getRetailer ();
310- $ mail = $ retailer ->getMail ();
311- $ result = $ mail ? $ mail : false ;
312-
313- return $ result ;
285+ public function getContactMail ()
286+ {
287+ return $ this ->getRetailer ()->getContactMail () ?: false ;
314288 }
315289
316290 /**
317291 * Get all exist markers.
318292 *
319293 * @return mixed
320294 */
321-
322- public function getAllMarkers () {
295+ public function getAllMarkers ()
296+ {
323297 $ retailerCollection = $ this ->retailerCollectionFactory ->create ();
324298 $ retailerCollection ->addAttributeToSelect (['name ' , 'contact_mail ' , 'contact_phone ' , 'contact_mail ' , 'image ' ]);
325299 $ retailerCollection ->addFieldToFilter ('is_active ' , (int ) true );
@@ -333,17 +307,18 @@ public function getAllMarkers() {
333307 *
334308 * @return array|null
335309 */
336- public function collectionFull () {
310+ public function collectionFull ()
311+ {
337312 $ collection = $ this ->getAllMarkers ();
338313
339314 $ markers = null ;
340315
341316 if (!$ markers ) {
342317 /** @var RetailerInterface $retailer */
343- $ imageUrlRetailer = $ this ->getImageUrl (). 'seller/ ' ;
318+ $ imageUrlRetailer = $ this ->getImageUrl () . 'seller/ ' ;
344319 foreach ($ collection as $ retailer ) {
345320 $ address = $ retailer ->getExtensionAttributes ()->getAddress ();
346- $ image = $ retailer ->getMediaPath () ? $ imageUrlRetailer. $ retailer ->getMediaPath () : false ;
321+ $ image = $ retailer ->getMediaPath () ? $ imageUrlRetailer . $ retailer ->getMediaPath () : false ;
347322 $ markerData = [
348323 'id ' => $ retailer ->getId (),
349324 'latitude ' => $ address ->getCoordinates ()->getLatitude (),
@@ -357,7 +332,7 @@ public function collectionFull() {
357332 ];
358333
359334 foreach (['contact_mail ' , 'contact_phone ' , 'contact_mail ' ] as $ contactAttribute ) {
360- $ markerData [$ contactAttribute ] = $ retailer ->getData ($ contactAttribute ) ? $ retailer -> getData ( $ contactAttribute ) : '' ;
335+ $ markerData [$ contactAttribute ] = $ retailer ->getData ($ contactAttribute ) ?: '' ;
361336 }
362337
363338 $ markerData ['schedule ' ] = array_merge (
0 commit comments