@@ -17,29 +17,29 @@ class Save extends \Magento\Sitemap\Controller\Adminhtml\Sitemap
17
17
const MAX_FILENAME_LENGTH = 32 ;
18
18
19
19
/**
20
- * @var $_stringValidator
20
+ * @var \Magento\Framework\Validator\StringLength
21
21
*/
22
- public $ _stringValidator ;
22
+ private $ stringValidator ;
23
23
24
24
/**
25
- * @var $_pathValidator
25
+ * @var \Magento\MediaStorage\Model\File\Validator\AvailablePath
26
26
*/
27
- public $ _pathValidator ;
27
+ private $ pathValidator ;
28
28
29
29
/**
30
- * @var $_sitemapHelper
30
+ * @var \Magento\Sitemap\Helper\Data
31
31
*/
32
- public $ _sitemapHelper ;
32
+ private $ sitemapHelper ;
33
33
34
34
/**
35
- * @var $_filesystem
35
+ * @var \Magento\Framework\Filesystem
36
36
*/
37
- public $ _filesystem ;
37
+ private $ filesystem ;
38
38
39
39
/**
40
- * @var $_sitemapFactory
40
+ * @var \Magento\Sitemap\Model\SitemapFactory
41
41
*/
42
- public $ _sitemapFactory ;
42
+ private $ sitemapFactory ;
43
43
44
44
/**
45
45
* Save constructor.
@@ -52,18 +52,18 @@ class Save extends \Magento\Sitemap\Controller\Adminhtml\Sitemap
52
52
*/
53
53
public function __construct (
54
54
\Magento \Backend \App \Action \Context $ context ,
55
- \Magento \Framework \Validator \StringLength $ stringValidator ,
56
- \Magento \MediaStorage \Model \File \Validator \AvailablePath $ pathValidator ,
57
- \Magento \Sitemap \Helper \Data $ sitemapHelper ,
58
- \Magento \Framework \Filesystem $ filesystem ,
59
- \Magento \Sitemap \Model \SitemapFactory $ sitemapFactory
55
+ \Magento \Framework \Validator \StringLength $ stringValidator = null ,
56
+ \Magento \MediaStorage \Model \File \Validator \AvailablePath $ pathValidator = null ,
57
+ \Magento \Sitemap \Helper \Data $ sitemapHelper = null ,
58
+ \Magento \Framework \Filesystem $ filesystem = null ,
59
+ \Magento \Sitemap \Model \SitemapFactory $ sitemapFactory = null
60
60
) {
61
61
parent ::__construct ($ context );
62
- $ this ->_stringValidator = $ stringValidator ;
63
- $ this ->_pathValidator = $ pathValidator ;
64
- $ this ->_sitemapHelper = $ sitemapHelper ;
65
- $ this ->_filesystem = $ filesystem ;
66
- $ this ->_sitemapFactory = $ sitemapFactory ;
62
+ $ this ->stringValidator = $ stringValidator ?: $ this -> _objectManager -> get (\ Magento \ Framework \ Validator \StringLength::class) ;
63
+ $ this ->pathValidator = $ pathValidator ?: $ this -> _objectManager -> get (\ Magento \ MediaStorage \ Model \ File \ Validator \AvailablePath::class) ;
64
+ $ this ->sitemapHelper = $ sitemapHelper ?: $ this -> _objectManager -> get (\ Magento \ Sitemap \ Helper \Data::class) ;
65
+ $ this ->filesystem = $ filesystem ?: $ this -> _objectManager -> get (\ Magento \ Framework \Filesystem::class) ;
66
+ $ this ->sitemapFactory = $ sitemapFactory ?: $ this -> _objectManager -> get (\ Magento \ Sitemap \ Model \SitemapFactory::class) ;
67
67
}
68
68
69
69
/**
@@ -78,9 +78,9 @@ protected function validatePath(array $data)
78
78
if (!empty ($ data ['sitemap_filename ' ]) && !empty ($ data ['sitemap_path ' ])) {
79
79
$ data ['sitemap_path ' ] = '/ ' . ltrim ($ data ['sitemap_path ' ], '/ ' );
80
80
$ path = rtrim ($ data ['sitemap_path ' ], '\\/ ' ) . '/ ' . $ data ['sitemap_filename ' ];
81
- $ this ->_pathValidator ->setPaths ($ this ->_sitemapHelper ->getValidPaths ());
82
- if (!$ this ->_pathValidator ->isValid ($ path )) {
83
- foreach ($ this ->_pathValidator ->getMessages () as $ message ) {
81
+ $ this ->pathValidator ->setPaths ($ this ->sitemapHelper ->getValidPaths ());
82
+ if (!$ this ->pathValidator ->isValid ($ path )) {
83
+ foreach ($ this ->pathValidator ->getMessages () as $ message ) {
84
84
$ this ->messageManager ->addErrorMessage ($ message );
85
85
}
86
86
// save data in session
@@ -90,9 +90,9 @@ protected function validatePath(array $data)
90
90
}
91
91
92
92
$ filename = rtrim ($ data ['sitemap_filename ' ]);
93
- $ this ->_stringValidator ->setMax (self ::MAX_FILENAME_LENGTH );
94
- if (!$ this ->_stringValidator ->isValid ($ filename )) {
95
- foreach ($ this ->_stringValidator ->getMessages () as $ message ) {
93
+ $ this ->stringValidator ->setMax (self ::MAX_FILENAME_LENGTH );
94
+ if (!$ this ->stringValidator ->isValid ($ filename )) {
95
+ foreach ($ this ->stringValidator ->getMessages () as $ message ) {
96
96
$ this ->messageManager ->addErrorMessage ($ message );
97
97
}
98
98
// save data in session
@@ -113,7 +113,7 @@ protected function validatePath(array $data)
113
113
protected function clearSiteMap (\Magento \Sitemap \Model \Sitemap $ model )
114
114
{
115
115
/** @var \Magento\Framework\Filesystem $directory */
116
- $ directory = $ this ->_filesystem ->getDirectoryWrite (DirectoryList::ROOT );
116
+ $ directory = $ this ->filesystem ->getDirectoryWrite (DirectoryList::ROOT );
117
117
118
118
if ($ this ->getRequest ()->getParam ('sitemap_id ' )) {
119
119
$ model ->load ($ this ->getRequest ()->getParam ('sitemap_id ' ));
@@ -136,7 +136,7 @@ protected function saveData($data)
136
136
{
137
137
// init model and set data
138
138
/** @var \Magento\Sitemap\Model\Sitemap $model */
139
- $ model = $ this ->_sitemapFactory ->create ();
139
+ $ model = $ this ->sitemapFactory ->create ();
140
140
$ this ->clearSiteMap ($ model );
141
141
$ model ->setData ($ data );
142
142
0 commit comments