AbstractHook::scrapeAssets()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Aoe\Asdis\Typo3\Hook;
3
4
use Aoe\Asdis\Domain\Model\Asset\Collection;
5
use Aoe\Asdis\Domain\Model\Page;
6
use Aoe\Asdis\System\Configuration\Provider;
7
use Aoe\Asdis\System\Log\Logger;
8
use TYPO3\CMS\Core\Utility\GeneralUtility;
9
use TYPO3\CMS\Extbase\Object\ObjectManager;
10
11
/**
12
 * Abstract hook class.
13
 */
14
abstract class AbstractHook
15
{
16
    /**
17
     * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
18
     */
19
    private $objectManager;
20
21
    /**
22
     * @var \Aoe\Asdis\System\Log\Logger
23
     */
24
    private $logger;
25
26
    /**
27
     * @var \Aoe\Asdis\Domain\Model\Page
28
     */
29
    private $page;
30
31
    /**
32
     * @var \Aoe\Asdis\System\Configuration\Provider
33
     */
34
    private $configurationProvider;
35
36
    /**
37
     * Constructor.
38
     */
39
    public function __construct()
40
    {
41
        $this->objectManager = GeneralUtility::makeInstance(ObjectManager::class);
42
        $this->configurationProvider = $this->objectManager->get(Provider::class);
43
        $this->logger = $this->objectManager->get(Logger::class);
44
    }
45
46
    /**
47
     * @return \Aoe\Asdis\System\Configuration\Provider
48
     */
49
    protected function getConfigurationProvider()
50
    {
51
        return $this->configurationProvider;
52
    }
53
54
    /**
55
     * @return \Aoe\Asdis\System\Log\Logger
56
     */
57
    protected function getLogger()
58
    {
59
        return $this->logger;
60
    }
61
62
    /**
63
     * @return void
64
     */
65
    protected function scrapeAssets()
66
    {
67
        $this->page->scrapeAssets();
68
    }
69
70
    /**
71
     * @return void
72
     */
73
    protected function replaceAssets()
74
    {
75
        $this->page->replaceAssets();
76
    }
77
78
    /**
79
     * Scrapes and replaces the assets of the current page.
80
     *
81
     * @return void
82
     */
83
    protected function scrapeAndReplace()
84
    {
85
        $this->scrapeAssets();
86
        $this->replaceAssets();
87
    }
88
89
    /**
90
     * @param \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $pObj
91
     */
92
    protected function setPageObject(\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $pObj)
93
    {
94
        /** @var Tx_Asdis_Domain_Model_Page $page */
95
        $page = $this->objectManager->get(Page::class);
0 ignored issues
show
Deprecated Code introduced by
The function TYPO3\CMS\Extbase\Object...ManagerInterface::get() has been deprecated: since TYPO3 10.4, will be removed in version 12.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

95
        $page = /** @scrutinizer ignore-deprecated */ $this->objectManager->get(Page::class);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
96
        $page->setAssets($this->objectManager->get(Collection::class));
0 ignored issues
show
Deprecated Code introduced by
The function TYPO3\CMS\Extbase\Object...ManagerInterface::get() has been deprecated: since TYPO3 10.4, will be removed in version 12.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

96
        $page->setAssets(/** @scrutinizer ignore-deprecated */ $this->objectManager->get(Collection::class));

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
97
        $page->setPageObject($pObj);
98
        $this->page = $page;
99
    }
100
}