• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / Yoast-SEO-for-TYPO3 / 13327579701

14 Feb 2025 10:43AM UTC coverage: 1.276%. First build
13327579701

push

github

web-flow
Merge pull request #597 from Yoast/feature/v11

[FEATURE] Release 11.0.0

21 of 894 new or added lines in 76 files covered. (2.35%)

35 of 2744 relevant lines covered (1.28%)

0.04 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/Classes/MetaTag/AdvancedRobots/AdvancedRobotsGenerator.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace YoastSeoForTypo3\YoastSeo\MetaTag\AdvancedRobots;
6

7
use TYPO3\CMS\Core\Http\ServerRequest;
8
use TYPO3\CMS\Frontend\Page\PageInformation;
9
use YoastSeoForTypo3\YoastSeo\Record\Record;
10
use YoastSeoForTypo3\YoastSeo\Record\RecordService;
11

12
class AdvancedRobotsGenerator
13
{
14
    public function __construct(
15
        protected RecordService $recordService,
16
        protected RobotsMetaTagManager $metaTagManager,
17
        protected RobotsRulesGenerator $robotsRuleGenerator
NEW
18
    ) {}
×
19

20
    /**
21
     * @param array<string, mixed> $params
22
     */
23
    public function generate(array $params): void
24
    {
NEW
25
        $record = $this->getRecord($params);
×
NEW
26
        if ($record === null) {
×
NEW
27
            return;
×
28
        }
29

NEW
30
        $flags = $this->extractFlags($record);
×
NEW
31
        if (array_sum($flags) === 0) { // All flags are false
×
NEW
32
            return;
×
33
        }
34

NEW
35
        $this->metaTagManager->removeRobotsTag();
×
NEW
36
        $robots = $this->robotsRuleGenerator->generateRules($flags);
×
NEW
37
        $this->metaTagManager->addRobotsTag($robots);
×
38
    }
39

40
    /**
41
     * @param array<string, mixed> $params
42
     * @return array<string, mixed>|null
43
     */
44
    protected function getRecord(array $params): ?array
45
    {
NEW
46
        $activeRecord = $this->recordService->getActiveRecord();
×
NEW
47
        if ($activeRecord instanceof Record && $activeRecord->shouldGenerateRobotsTag()) {
×
NEW
48
            return $activeRecord->getRecordData();
×
49
        }
NEW
50
        if (isset($params['request']) && $params['request'] instanceof ServerRequest) {
×
NEW
51
            $pageInfo = $params['request']->getAttribute('frontend.page.information');
×
NEW
52
            if ($pageInfo instanceof PageInformation) {
×
NEW
53
                return $pageInfo->getPageRecord();
×
54
            }
55
        }
NEW
56
        return $params['page'] ?? null;
×
57
    }
58

59
    /**
60
     * @param array<string, mixed> $record
61
     * @return array<string, bool>
62
     */
63
    protected function extractFlags(array $record): array
64
    {
NEW
65
        return [
×
NEW
66
            'noImageIndex' => (bool)($record['tx_yoastseo_robots_noimageindex'] ?? false),
×
NEW
67
            'noArchive' => (bool)($record['tx_yoastseo_robots_noarchive'] ?? false),
×
NEW
68
            'noSnippet' => (bool)($record['tx_yoastseo_robots_nosnippet'] ?? false),
×
NEW
69
            'noIndex' => (bool)($record['no_index'] ?? false),
×
NEW
70
            'noFollow' => (bool)($record['no_follow'] ?? false),
×
NEW
71
        ];
×
72
    }
73
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc