-
Notifications
You must be signed in to change notification settings - Fork 16
/
FormMini.php
80 lines (68 loc) · 1.93 KB
/
FormMini.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/**
* Tweakwise (https://www.tweakwise.com/) - All Rights Reserved
*
* @copyright Copyright (c) 2017-2022 Tweakwise.com B.V. (https://www.tweakwise.com)
* @license Proprietary and confidential, Unauthorized copying of this file, via any medium is strictly prohibited
*/
namespace Tweakwise\Magento2Tweakwise\Block\Autocomplete;
use Tweakwise\Magento2Tweakwise\Model\Config;
use Magento\Catalog\Api\Data\CategoryInterface;
use Magento\Framework\Locale\Format as LocaleFormat;
use Magento\Framework\Registry;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
class FormMini extends Template
{
/**
* @var Config
*/
protected $config;
/**
* @var LocaleFormat
*/
protected $localeFormat;
/**
* @var Registry
*/
protected $registry;
/**
* FormMini constructor.
* @param Config $config
* @param LocaleFormat $localeFormat
* @param Registry $registry
* @param Context $context
* @param array $data
*/
public function __construct(
Config $config,
LocaleFormat $localeFormat,
Registry $registry,
Context $context,
array $data = []
) {
parent::__construct($context, $data);
$this->config = $config;
$this->localeFormat = $localeFormat;
$this->registry = $registry;
}
/**
* @return string
*/
public function getJsonPriceFormat()
{
return json_encode($this->localeFormat->getPriceFormat());
}
/**
* @return string
*/
public function getAjaxUrl()
{
$routeParams = ['_secure' => $this->getRequest()->isSecure()];
$category = $this->registry->registry('current_category');
if ($category instanceof CategoryInterface) {
$routeParams['cid'] = $category->getId();
}
return $this->getUrl('search/ajax/suggest', $routeParams);
}
}