Index::execute()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 20
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 20
rs 9.8333
c 0
b 0
f 0
cc 4
nc 3
nop 0
1
<?php
2
/**
3
 * MagePrince
4
 *
5
 * NOTICE OF LICENSE
6
 *
7
 * This source file is subject to the mageprince.com license that is
8
 * available through the world-wide-web at this URL:
9
 * https://mageprince.com/end-user-license-agreement
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    MagePrince
17
 * @package     Mageprince_Faq
18
 * @copyright   Copyright (c) MagePrince (https://mageprince.com/)
19
 * @license     https://mageprince.com/end-user-license-agreement
20
 */
21
22
namespace Mageprince\Faq\Controller\Index;
23
24
use Magento\Framework\App\Action\Action;
0 ignored issues
show
Bug introduced by
The type Magento\Framework\App\Action\Action 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...
25
use Magento\Framework\App\Action\Context;
0 ignored issues
show
Bug introduced by
The type Magento\Framework\App\Action\Context 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...
26
use Magento\Framework\Controller\ResultInterface;
0 ignored issues
show
Bug introduced by
The type Magento\Framework\Controller\ResultInterface 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...
27
use Magento\Framework\View\Result\PageFactory;
0 ignored issues
show
Bug introduced by
The type Magento\Framework\View\Result\PageFactory 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...
28
use Magento\Theme\Block\Html\Title as HtmlTitle;
0 ignored issues
show
Bug introduced by
The type Magento\Theme\Block\Html\Title 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...
29
use Mageprince\Faq\Helper\Data;
30
use Mageprince\Faq\Model\Config\DefaultConfig;
31
32
class Index extends Action
33
{
34
    /**
35
     * @var PageFactory
36
     */
37
    protected $resultPageFactory;
38
39
    /**
40
     * @var Data
41
     */
42
    protected $helper;
43
44
    /**
45
     * Index constructor.
46
     * @param Context $context
47
     * @param Data $helper
48
     * @param PageFactory $resultPageFactory
49
     */
50
    public function __construct(
51
        Context $context,
52
        Data $helper,
53
        PageFactory $resultPageFactory
54
    ) {
55
        $this->helper = $helper;
56
        $this->resultPageFactory = $resultPageFactory;
57
        parent::__construct($context);
58
    }
59
60
    /**
61
     * Execute view action
62
     *
63
     * @return ResultInterface
64
     */
65
    public function execute()
66
    {
67
        $resultPage = $this->resultPageFactory->create();
68
        if ($this->helper->isEnable()) {
69
            $pageMainTitle = $resultPage->getLayout()->getBlock('page.main.title');
70
            $pageTitle = $this->helper->getConfig(DefaultConfig::CONFIG_PATH_PAGE_TITLE);
71
72
            if ($pageMainTitle && $pageMainTitle instanceof HtmlTitle) {
73
                $pageMainTitle->setPageTitle($pageTitle);
74
            }
75
76
            $metaTitleConfig = $this->helper->getConfig(DefaultConfig::FAQ_META_TITLE);
77
            $metaKeywordsConfig = $this->helper->getConfig(DefaultConfig::FAQ_META_KEYWORD);
78
            $metaDescriptionConfig = $this->helper->getConfig(DefaultConfig::FAQ_META_DESCRIPTION);
79
80
            $resultPage->getConfig()->getTitle()->set($metaTitleConfig);
81
            $resultPage->getConfig()->setDescription($metaDescriptionConfig);
82
            $resultPage->getConfig()->setKeywords($metaKeywordsConfig);
83
        }
84
        return $resultPage;
85
    }
86
}
87