Issues (1092)

Model/UiComponent/DataProvider.php (6 issues)

1
<?php
2
3
/**
4
 * PAYONE Magento 2 Connector is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU Lesser General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * PAYONE Magento 2 Connector is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public License
15
 * along with PAYONE Magento 2 Connector. If not, see <http://www.gnu.org/licenses/>.
16
 *
17
 * PHP version 5
18
 *
19
 * @category  Payone
20
 * @package   Payone_Magento2_Plugin
21
 * @author    FATCHIP GmbH <[email protected]>
22
 * @copyright 2003 - 2016 Payone GmbH
23
 * @license   <http://www.gnu.org/licenses/> GNU Lesser General Public License
24
 * @link      http://www.payone.de
25
 */
26
27
namespace Payone\Core\Model\UiComponent;
28
29
use Magento\Framework\Api\FilterBuilder;
0 ignored issues
show
The type Magento\Framework\Api\FilterBuilder was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
30
use Magento\Framework\Api\Search\SearchCriteriaBuilder;
0 ignored issues
show
The type Magento\Framework\Api\Search\SearchCriteriaBuilder was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
31
use Magento\Framework\App\RequestInterface;
0 ignored issues
show
The type Magento\Framework\App\RequestInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
32
use Magento\Framework\View\Element\UiComponent\DataProvider\Reporting;
0 ignored issues
show
The type Magento\Framework\View\E...\DataProvider\Reporting was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
33
34
/**
35
 * DataProvider extension model
36
 */
37
class DataProvider extends \Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider
0 ignored issues
show
The type Magento\Framework\View\E...taProvider\DataProvider was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
38
{
39
    /**
40
     * PAYONE database helper
41
     *
42
     * @var \Payone\Core\Helper\Database
43
     */
44
    protected $databaseHelper;
45
46
    /**
47
     * Constructor
48
     *
49
     * @param string                       $name
50
     * @param string                       $primaryFieldName
51
     * @param string                       $requestFieldName
52
     * @param Reporting                    $reporting
53
     * @param SearchCriteriaBuilder        $searchCritBuilder
54
     * @param RequestInterface             $request
55
     * @param FilterBuilder                $filterBuilder
56
     * @param \Payone\Core\Helper\Database $databaseHelper
57
     * @param array                        $meta
58
     * @param array                        $data
59
     */
60
    public function __construct(
61
        $name,
62
        $primaryFieldName,
63
        $requestFieldName,
64
        Reporting $reporting,
65
        SearchCriteriaBuilder $searchCritBuilder,
66
        RequestInterface $request,
67
        FilterBuilder $filterBuilder,
68
        \Payone\Core\Helper\Database $databaseHelper,
69
        array $meta = [],
70
        array $data = []
71
    ) {
72
        $this->databaseHelper = $databaseHelper; // needs to be in front of constructor, doesnt work otherwise for no apparent reason
73
        parent::__construct($name, $primaryFieldName, $requestFieldName, $reporting, $searchCritBuilder, $request, $filterBuilder, $meta, $data);
74
    }
75
76
    /**
77
     * This is used to fix the admin grid filter
78
     * The admin-user can filter by increment_id
79
     * But the ajax-implementation used for the filter somehow sometimes
80
     * sends the order-id instead of the increment_id, so this
81
     * translates the order id to the increment_id
82
     *
83
     * @return void
84
     */
85
    protected function prepareUpdateUrl()
86
    {
87
        if (!isset($this->data['config']['filter_url_params'])) {
88
            return;
89
        }
90
        foreach ($this->data['config']['filter_url_params'] as $paramName => $paramValue) {
91
            if ('*' == $paramValue) {
92
                $paramValue = $this->request->getParam($paramName);
93
            }
94
            if (substr($paramValue, 0, 1) == '0') { // already an increment_id
95
                parent::prepareUpdateUrl();
96
                return;
97
            }
98
            if ($paramValue) {
99
                $sIncrementId = $this->databaseHelper->getIncrementIdByOrderId($paramValue);
100
                if ($sIncrementId) {
101
                    $paramValue = $sIncrementId;
102
                }
103
                $this->data['config']['update_url'] = sprintf(
0 ignored issues
show
Bug Best Practice introduced by
The property data does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
104
                    '%s%s/%s',
105
                    $this->data['config']['update_url'],
106
                    $paramName,
107
                    $paramValue
108
                );
109
                $this->addFilter(
110
                    $this->filterBuilder->setField($paramName)->setValue($paramValue)->setConditionType('eq')->create()
111
                );
112
            }
113
        }
114
    }
115
}
116