Skip to content

Commit 5784bb1

Browse files
committed
updated code compatible with php 8.2
1 parent aca7da2 commit 5784bb1

40 files changed

+2908
-2847
lines changed
Lines changed: 131 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1,128 +1,131 @@
1-
<?php
2-
/**
3-
* Venustheme
4-
*
5-
* NOTICE OF LICENSE
6-
*
7-
* This source file is subject to the Venustheme.com license that is
8-
* available through the world-wide-web at this URL:
9-
* http://www.venustheme.com/license-agreement.html
10-
*
11-
* DISCLAIMER
12-
*
13-
* Do not edit or add to this file if you wish to upgrade this extension to newer
14-
* version in the future.
15-
*
16-
* @category Venustheme
17-
* @package Ves_Blog
18-
* @copyright Copyright (c) 2016 Venustheme (http://www.venustheme.com/)
19-
* @license http://www.venustheme.com/LICENSE-1.0.html
20-
*/
21-
namespace Ves\Blog\Controller\Adminhtml\Author;
22-
23-
use Magento\Backend\App\Action;
24-
25-
class Edit extends \Magento\Backend\App\Action
26-
{
27-
/**
28-
* Core registry
29-
*
30-
* @var \Magento\Framework\Registry
31-
*/
32-
protected $_coreRegistry = null;
33-
34-
/**
35-
* @var \Magento\Framework\View\Result\PageFactory
36-
*/
37-
protected $resultPageFactory;
38-
39-
/**
40-
* @param Action\Context $context
41-
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
42-
* @param \Magento\Backend\Model\Auth\Session $authSession
43-
* @param \Magento\Framework\Registry $registry
44-
*/
45-
public function __construct(
46-
Action\Context $context,
47-
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
48-
\Magento\Backend\Model\Auth\Session $authSession,
49-
\Magento\Framework\Registry $registry
50-
) {
51-
$this->resultPageFactory = $resultPageFactory;
52-
$this->authSession = $authSession;
53-
$this->_coreRegistry = $registry;
54-
parent::__construct($context);
55-
}
56-
57-
public function getCurrentUser()
58-
{
59-
return $this->authSession->getUser();
60-
}
61-
62-
/**
63-
* {@inheritdoc}
64-
*/
65-
protected function _isAllowed()
66-
{
67-
return $this->_authorization->isAllowed('Ves_Blog::author');
68-
}
69-
70-
/**
71-
* Init actions
72-
*
73-
* @return \Magento\Backend\Model\View\Result\Page
74-
*/
75-
protected function _initAction()
76-
{
77-
// load layout, set active menu and breadcrumbs
78-
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
79-
$resultPage = $this->resultPageFactory->create();
80-
$resultPage->setActiveMenu('Ves_Blog::blog')
81-
->addBreadcrumb(__('Blog'), __('Blog'))
82-
->addBreadcrumb(__('My Profile'), __('My Profile'));
83-
return $resultPage;
84-
}
85-
86-
/**
87-
* Edit CMS page
88-
*
89-
* @return \Magento\Backend\Model\View\Result\Page|\Magento\Backend\Model\View\Result\Redirect
90-
* @SuppressWarnings(PHPMD.NPathComplexity)
91-
*/
92-
public function execute()
93-
{
94-
// 1. Get ID and create model
95-
$author_id = $this->getRequest()->getParam('author_id');
96-
$id = $this->getCurrentUser()->getUserId();
97-
$model = $this->_objectManager->create('Ves\Blog\Model\Author');
98-
99-
// 2. Initial checking
100-
if($author_id) {
101-
$model->load($author_id);
102-
}elseif ($id) {
103-
$model->loadByUserId($id);
104-
if (!$model->getId()) {
105-
$data = $this->getCurrentUser()->getData();
106-
$data['nick_name'] = $data['firstname'] . ' ' . $data['lastname'];
107-
$model->setData($data)->save();
108-
}
109-
}
110-
111-
// 3. Set entered data if was error when we do save
112-
$data = $this->_objectManager->get('Magento\Backend\Model\Session')->getFormData(true);
113-
if (!empty($data)) {
114-
$model->setData($data);
115-
}
116-
117-
// 4. Register model to use later in blocks
118-
$this->_coreRegistry->register('current_author', $model);
119-
120-
121-
// 5. Build edit form
122-
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
123-
$resultPage = $this->_initAction();
124-
$resultPage->getConfig()->getTitle()->prepend(__('Author: ' . $model->getNickName()));
125-
126-
return $resultPage;
127-
}
128-
}
1+
<?php
2+
/**
3+
* Venustheme
4+
*
5+
* NOTICE OF LICENSE
6+
*
7+
* This source file is subject to the Venustheme.com license that is
8+
* available through the world-wide-web at this URL:
9+
* http://www.venustheme.com/license-agreement.html
10+
*
11+
* DISCLAIMER
12+
*
13+
* Do not edit or add to this file if you wish to upgrade this extension to newer
14+
* version in the future.
15+
*
16+
* @category Venustheme
17+
* @package Ves_Blog
18+
* @copyright Copyright (c) 2016 Venustheme (http://www.venustheme.com/)
19+
* @license http://www.venustheme.com/LICENSE-1.0.html
20+
*/
21+
namespace Ves\Blog\Controller\Adminhtml\Author;
22+
23+
use Magento\Backend\App\Action;
24+
25+
class Edit extends \Magento\Backend\App\Action
26+
{
27+
/**
28+
* Core registry
29+
*
30+
* @var \Magento\Framework\Registry
31+
*/
32+
protected $_coreRegistry = null;
33+
34+
/**
35+
* @var \Magento\Framework\View\Result\PageFactory
36+
*/
37+
protected $resultPageFactory;
38+
39+
protected $authSession;
40+
41+
/**
42+
* @param Action\Context $context
43+
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
44+
* @param \Magento\Backend\Model\Auth\Session $authSession
45+
* @param \Magento\Framework\Registry $registry
46+
*/
47+
public function __construct(
48+
Action\Context $context,
49+
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
50+
\Magento\Backend\Model\Auth\Session $authSession,
51+
\Magento\Framework\Registry $registry
52+
53+
) {
54+
$this->resultPageFactory = $resultPageFactory;
55+
$this->authSession = $authSession;
56+
$this->_coreRegistry = $registry;
57+
parent::__construct($context);
58+
}
59+
60+
public function getCurrentUser()
61+
{
62+
return $this->authSession->getUser();
63+
}
64+
65+
/**
66+
* {@inheritdoc}
67+
*/
68+
protected function _isAllowed()
69+
{
70+
return $this->_authorization->isAllowed('Ves_Blog::author');
71+
}
72+
73+
/**
74+
* Init actions
75+
*
76+
* @return \Magento\Backend\Model\View\Result\Page
77+
*/
78+
protected function _initAction()
79+
{
80+
// load layout, set active menu and breadcrumbs
81+
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
82+
$resultPage = $this->resultPageFactory->create();
83+
$resultPage->setActiveMenu('Ves_Blog::blog')
84+
->addBreadcrumb(__('Blog'), __('Blog'))
85+
->addBreadcrumb(__('My Profile'), __('My Profile'));
86+
return $resultPage;
87+
}
88+
89+
/**
90+
* Edit CMS page
91+
*
92+
* @return \Magento\Backend\Model\View\Result\Page|\Magento\Backend\Model\View\Result\Redirect
93+
* @SuppressWarnings(PHPMD.NPathComplexity)
94+
*/
95+
public function execute()
96+
{
97+
// 1. Get ID and create model
98+
$author_id = $this->getRequest()->getParam('author_id');
99+
$id = $this->getCurrentUser()->getUserId();
100+
$model = $this->_objectManager->create('Ves\Blog\Model\Author');
101+
102+
// 2. Initial checking
103+
if($author_id) {
104+
$model->load($author_id);
105+
}elseif ($id) {
106+
$model->loadByUserId($id);
107+
if (!$model->getId()) {
108+
$data = $this->getCurrentUser()->getData();
109+
$data['nick_name'] = $data['firstname'] . ' ' . $data['lastname'];
110+
$model->setData($data)->save();
111+
}
112+
}
113+
114+
// 3. Set entered data if was error when we do save
115+
$data = $this->_objectManager->get('Magento\Backend\Model\Session')->getFormData(true);
116+
if (!empty($data)) {
117+
$model->setData($data);
118+
}
119+
120+
// 4. Register model to use later in blocks
121+
$this->_coreRegistry->register('current_author', $model);
122+
123+
124+
// 5. Build edit form
125+
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
126+
$resultPage = $this->_initAction();
127+
$resultPage->getConfig()->getTitle()->prepend(__('Author: ' . $model->getNickName()));
128+
129+
return $resultPage;
130+
}
131+
}

Controller/Adminhtml/Category/Save.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<?php
22
/**
33
* Venustheme
4-
*
4+
*
55
* NOTICE OF LICENSE
6-
*
6+
*
77
* This source file is subject to the Venustheme.com license that is
88
* available through the world-wide-web at this URL:
99
* http://www.venustheme.com/license-agreement.html
10-
*
10+
*
1111
* DISCLAIMER
12-
*
12+
*
1313
* Do not edit or add to this file if you wish to upgrade this extension to newer
1414
* version in the future.
15-
*
15+
*
1616
* @category Venustheme
1717
* @package Ves_Blog
1818
* @copyright Copyright (c) 2016 Venustheme (http://www.venustheme.com/)
@@ -24,7 +24,7 @@
2424

2525
class Save extends \Magento\Backend\App\Action
2626
{
27-
27+
2828
/**
2929
* @var \Magento\Framework\Filesystem
3030
*/
@@ -42,10 +42,10 @@ class Save extends \Magento\Backend\App\Action
4242
* @param \Magento\Backend\Helper\Js
4343
*/
4444
public function __construct(
45-
\Magento\Backend\App\Action\Context $context,
45+
\Magento\Backend\App\Action\Context $context,
4646
\Magento\Framework\Filesystem $filesystem,
4747
\Magento\Backend\Helper\Js $jsHelper
48-
) {
48+
) {
4949
$this->_fileSystem = $filesystem;
5050
$this->jsHelper = $jsHelper;
5151
parent::__construct($context);
@@ -66,7 +66,7 @@ protected function _isAllowed()
6666
*/
6767
public function execute()
6868
{
69-
$data = $this->getRequest()->getPostValue();
69+
$data = $this->getRequest()->getPostValue();
7070

7171
$links = $this->getRequest()->getPost('links');
7272
$links = is_array($links) ? $links : [];
@@ -101,7 +101,7 @@ public function execute()
101101
unset($data['image']);
102102
}
103103
if($image = $this->uploadImage('image')){
104-
104+
105105
$data['image'] = $image;
106106
}
107107
}
@@ -111,7 +111,7 @@ public function execute()
111111
$identifier = strtolower($identifier);
112112
$identifier = str_replace(" ","-",$identifier);
113113
$data['identifier'] = $identifier;
114-
114+
115115
$model->setData($data);
116116
try {
117117
$model->save();
@@ -139,7 +139,7 @@ public function uploadImage($fieldId = 'image')
139139
{
140140
$resultRedirect = $this->resultRedirectFactory->create();
141141

142-
if (isset($_FILES[$fieldId]) && $_FILES[$fieldId]['name']!='')
142+
if (isset($_FILES[$fieldId]) && $_FILES[$fieldId]['name']!='')
143143
{
144144
$uploader = $this->_objectManager->create(
145145
'Magento\Framework\File\Uploader',
@@ -150,7 +150,7 @@ public function uploadImage($fieldId = 'image')
150150
->getDirectoryRead(DirectoryList::MEDIA);
151151
$mediaFolder = 'ves/blog/';
152152
try {
153-
$uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
153+
$uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
154154
$uploader->setAllowRenameFiles(true);
155155
$uploader->setFilesDispersion(false);
156156
$file_name = $uploader->getUploadedFileName();
@@ -167,4 +167,4 @@ public function uploadImage($fieldId = 'image')
167167
return;
168168
}
169169

170-
}
170+
}

0 commit comments

Comments
 (0)