forked from magento/magento2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSharing.php
More file actions
137 lines (123 loc) · 3.12 KB
/
Sharing.php
File metadata and controls
137 lines (123 loc) · 3.12 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Wishlist\Block\Customer;
use Magento\Captcha\Block\Captcha;
/**
* Wishlist customer sharing block
*
* @api
* @since 100.0.2
*/
class Sharing extends \Magento\Framework\View\Element\Template
{
/**
* Entered Data cache
*
* @var array|null
*/
protected $_enteredData = null;
/**
* Wishlist configuration
*
* @var \Magento\Wishlist\Model\Config
*/
protected $_wishlistConfig;
/**
* @var \Magento\Framework\Session\Generic
*/
protected $_wishlistSession;
/**
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Wishlist\Model\Config $wishlistConfig
* @param \Magento\Framework\Session\Generic $wishlistSession
* @param array $data
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Wishlist\Model\Config $wishlistConfig,
\Magento\Framework\Session\Generic $wishlistSession,
array $data = []
) {
$this->_wishlistConfig = $wishlistConfig;
$this->_wishlistSession = $wishlistSession;
parent::__construct($context, $data);
}
/**
* Prepare Global Layout
*
* @return void
*/
protected function _prepareLayout()
{
if (!$this->getChildBlock('captcha')) {
$this->addChild(
'captcha',
Captcha::class,
[
'cacheable' => false,
'after' => '-',
'form_id' => 'share_wishlist_form',
'image_width' => 230,
'image_height' => 230
]
);
}
$this->pageConfig->getTitle()->set(__('Wish List Sharing'));
}
/**
* Retrieve Send Form Action URL
*
* @return string
*/
public function getSendUrl()
{
return $this->getUrl('wishlist/index/send');
}
/**
* Retrieve Entered Data by key
*
* @param string $key
* @return string|null
*/
public function getEnteredData($key)
{
if ($this->_enteredData === null) {
$this->_enteredData = $this->_wishlistSession->getData('sharing_form', true);
}
if (!$this->_enteredData || !isset($this->_enteredData[$key])) {
return null;
} else {
return $this->escapeHtml($this->_enteredData[$key]);
}
}
/**
* Retrieve back button url
*
* @return string
*/
public function getBackUrl()
{
return $this->getUrl('wishlist');
}
/**
* Retrieve number of emails allowed for sharing
*
* @return int
*/
public function getEmailSharingLimit()
{
return $this->_wishlistConfig->getSharingEmailLimit();
}
/**
* Retrieve maximum email length allowed for sharing
*
* @return int
*/
public function getTextSharingLimit()
{
return $this->_wishlistConfig->getSharingTextLimit();
}
}