[TASK] Move MetaTagManagers of OpenGraph and Twitter to EXT:seo 62/57162/2
authorBenni Mack <benni@typo3.org>
Sat, 9 Jun 2018 18:04:46 +0000 (20:04 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 9 Jun 2018 20:07:42 +0000 (22:07 +0200)
The new SEO extension handles opengraph and twitter (seo-relevant),
thus do not need to stay in EXT:core, as they are only for sites which
need SEO relevant information to be processed.

Resolves: #85201
Releases: master
Change-Id: Ib0bf503bb939b47747dc32209f78f8e7ce8622c1
Reviewed-on: https://review.typo3.org/57162
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Richard Haeser <richard@maxserv.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
15 files changed:
composer.json
typo3/sysext/core/Classes/MetaTag/OpenGraphMetaTagManager.php [deleted file]
typo3/sysext/core/Classes/MetaTag/TwitterCardMetaTagManager.php [deleted file]
typo3/sysext/core/Tests/Unit/MetaTag/MetaTagManagerRegistryTest.php
typo3/sysext/core/Tests/Unit/MetaTag/OpenGraphMetaTagManagerTest.php [deleted file]
typo3/sysext/core/Tests/Unit/MetaTag/TwitterCardMetaTagManagerTest.php [deleted file]
typo3/sysext/core/ext_localconf.php
typo3/sysext/seo/Classes/Generator/MetaTagGenerator.php [deleted file]
typo3/sysext/seo/Classes/MetaTag/MetaTagGenerator.php [new file with mode: 0644]
typo3/sysext/seo/Classes/MetaTag/OpenGraphMetaTagManager.php [new file with mode: 0644]
typo3/sysext/seo/Classes/MetaTag/TwitterCardMetaTagManager.php [new file with mode: 0644]
typo3/sysext/seo/Tests/Unit/MetaTag/OpenGraphMetaTagManagerTest.php [new file with mode: 0644]
typo3/sysext/seo/Tests/Unit/MetaTag/TwitterCardMetaTagManagerTest.php [new file with mode: 0644]
typo3/sysext/seo/composer.json
typo3/sysext/seo/ext_localconf.php

index 7db2e9b..5dc8874 100644 (file)
                        "TYPO3\\CMS\\Rsaauth\\Tests\\": "typo3/sysext/rsaauth/Tests/",
                        "TYPO3\\CMS\\Saltedpasswords\\Tests\\": "typo3/sysext/saltedpasswords/Tests/",
                        "TYPO3\\CMS\\Scheduler\\Tests\\": "typo3/sysext/scheduler/Tests/",
+                       "TYPO3\\CMS\\Seo\\Tests\\": "typo3/sysext/seo/Tests/",
                        "TYPO3\\CMS\\Setup\\Tests\\": "typo3/sysext/setup/Tests/",
                        "TYPO3\\CMS\\SysAction\\Tests\\": "typo3/sysext/sys_action/Tests/",
                        "TYPO3\\CMS\\SysNote\\Tests\\": "typo3/sysext/sys_note/Tests/",
diff --git a/typo3/sysext/core/Classes/MetaTag/OpenGraphMetaTagManager.php b/typo3/sysext/core/Classes/MetaTag/OpenGraphMetaTagManager.php
deleted file mode 100644 (file)
index 9cf4ed4..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-<?php
-declare(strict_types = 1);
-
-namespace TYPO3\CMS\Core\MetaTag;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-class OpenGraphMetaTagManager extends AbstractMetaTagManager
-{
-    /**
-     * The default attribute that defines the name of the property
-     *
-     * This creates tags like <meta property="" /> by default
-     *
-     * @var string
-     */
-    protected $defaultNameAttribute = 'property';
-
-    /**
-     * Array of properties that can be handled by this manager
-     *
-     * @var array
-     */
-    protected $handledProperties = [
-        'og:type' => [],
-        'og:title' => [],
-        'og:description' => [],
-        'og:site_name' => [],
-        'og:url' => [],
-        'og:audio' => [],
-        'og:video' => [],
-        'og:determiner' => [],
-        'og:locale' => [
-            'allowedSubProperties' => [
-                'alternate' => [
-                    'allowMultipleOccurrences' => true
-                ],
-            ]
-        ],
-        'og:image' => [
-            'allowMultipleOccurrences' => true,
-            'allowedSubProperties' => [
-                'url' => [],
-                'secure_url' => [],
-                'type' => [],
-                'width' => [],
-                'height' => [],
-                'alt' => [],
-            ]
-        ]
-    ];
-}
diff --git a/typo3/sysext/core/Classes/MetaTag/TwitterCardMetaTagManager.php b/typo3/sysext/core/Classes/MetaTag/TwitterCardMetaTagManager.php
deleted file mode 100644 (file)
index eca5519..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-<?php
-declare(strict_types = 1);
-
-namespace TYPO3\CMS\Core\MetaTag;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-class TwitterCardMetaTagManager extends AbstractMetaTagManager
-{
-    /**
-     * Array of properties that can be handled by this manager
-     *
-     * @var array
-     */
-    protected $handledProperties = [
-        'twitter:card' => [],
-        'twitter:site' => [
-            'allowedSubProperties' => [
-                'id' => [],
-            ]
-        ],
-        'twitter:creator' => [
-            'allowedSubProperties' => [
-                'id' => [],
-            ]
-        ],
-        'twitter:description' => [],
-        'twitter:title' => [],
-        'twitter:image' => [
-            'allowedSubProperties' => [
-                'alt' => [],
-            ]
-        ],
-        'twitter:player' => [
-            'allowedSubProperties' => [
-                'width' => [],
-                'height' => [],
-                'stream' => [],
-            ]
-        ],
-        'twitter:app' => [
-            'allowedSubProperties' => [
-                'name:iphone' => [],
-                'id:iphone' => [],
-                'url:iphone' => [],
-                'name:ipad' => [],
-                'id:ipad' => [],
-                'url:ipad' => [],
-                'name:googleplay' => [],
-                'id:googleplay' => [],
-                'url:googleplay' => [],
-            ]
-        ],
-    ];
-}
index abd1e2c..4bdea07 100644 (file)
@@ -1,4 +1,6 @@
 <?php
+declare(strict_types = 1);
+
 namespace TYPO3\CMS\Core\Tests\Unit\MetaTag;
 
 /*
@@ -17,8 +19,8 @@ namespace TYPO3\CMS\Core\Tests\Unit\MetaTag;
 use TYPO3\CMS\Core\MetaTag\GenericMetaTagManager;
 use TYPO3\CMS\Core\MetaTag\Html5MetaTagManager;
 use TYPO3\CMS\Core\MetaTag\MetaTagManagerRegistry;
-use TYPO3\CMS\Core\MetaTag\OpenGraphMetaTagManager;
-use TYPO3\CMS\Core\MetaTag\TwitterCardMetaTagManager;
+use TYPO3\CMS\Seo\MetaTag\OpenGraphMetaTagManager;
+use TYPO3\CMS\Seo\MetaTag\TwitterCardMetaTagManager;
 
 /**
  * Test case
diff --git a/typo3/sysext/core/Tests/Unit/MetaTag/OpenGraphMetaTagManagerTest.php b/typo3/sysext/core/Tests/Unit/MetaTag/OpenGraphMetaTagManagerTest.php
deleted file mode 100644 (file)
index e062a5f..0000000
+++ /dev/null
@@ -1,205 +0,0 @@
-<?php
-namespace TYPO3\CMS\Core\Tests\Unit\MetaTag;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-use TYPO3\CMS\Core\MetaTag\OpenGraphMetaTagManager;
-
-/**
- * Test case
- */
-class OpenGraphMetaTagManagerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
-{
-    /**
-     * @test
-     */
-    public function checkIfGetAllHandledPropertiesReturnsNonEmptyArray()
-    {
-        $manager = new OpenGraphMetaTagManager();
-        $handledProperties = $manager->getAllHandledProperties();
-
-        $this->assertNotEmpty($handledProperties);
-    }
-
-    /**
-     * @dataProvider propertiesProvider
-     *
-     * @test
-     */
-    public function checkIfPropertyIsStoredAfterAddingProperty($property, $expected, $expectedRenderedTag)
-    {
-        $manager = new OpenGraphMetaTagManager();
-        $manager->addProperty(
-            $property['property'],
-            $property['content'],
-            (array)$property['subProperties']
-        );
-
-        $this->assertEquals($expected, $manager->getProperty($property['property']));
-        $this->assertEquals($expectedRenderedTag, $manager->renderProperty($property['property']));
-    }
-
-    /**
-     * @test
-     */
-    public function checkIfAddingOnlySubPropertyAndNoMainPropertyIsReturningException()
-    {
-        $manager = new OpenGraphMetaTagManager();
-
-        $this->expectException(\UnexpectedValueException::class);
-        $manager->addProperty('og:image:width', '400');
-    }
-
-    /**
-     * @test
-     */
-    public function checkRenderAllPropertiesRendersCorrectMetaTags()
-    {
-        $properties = [
-            [
-                'property' => 'og:title',
-                'content' => 'This is a title',
-                'subProperties' => [],
-                'replace' => false,
-                'type' => ''
-            ],
-            [
-                'property' => 'og:image',
-                'content' => '/path/to/image',
-                'subProperties' => [
-                    'width' => 400
-                ],
-                'replace' => false,
-                'type' => ''
-            ],
-            [
-                'property' => 'og:image:height',
-                'content' => '200',
-                'subProperties' => [],
-                'replace' => false,
-                'type' => ''
-            ],
-            [
-                'property' => 'og:title',
-                'content' => 'This is the new title',
-                'subProperties' => [],
-                'replace' => true,
-                'type' => ''
-            ],
-            [
-                'property' => 'og:image',
-                'content' => '/path/to/image2',
-                'subProperties' => [],
-                'replace' => false,
-                'type' => ''
-            ],
-        ];
-
-        $manager = new OpenGraphMetaTagManager();
-        foreach ($properties as $property) {
-            $manager->addProperty(
-                $property['property'],
-                $property['content'],
-                $property['subProperties'],
-                $property['replace'],
-                $property['type']
-            );
-        }
-
-        $expected = '<meta property="og:image" content="/path/to/image" />' . PHP_EOL .
-            '<meta property="og:image:width" content="400" />' . PHP_EOL .
-            '<meta property="og:image:height" content="200" />' . PHP_EOL .
-            '<meta property="og:image" content="/path/to/image2" />' . PHP_EOL .
-            '<meta property="og:title" content="This is the new title" />';
-
-        $this->assertEquals($expected, $manager->renderAllProperties());
-    }
-
-    /**
-     * @test
-     */
-    public function checkIfRemovePropertyReallyRemovesProperty()
-    {
-        $manager = new OpenGraphMetaTagManager();
-        $manager->addProperty('og:title', 'Title');
-        $this->assertEquals([['content' => 'Title', 'subProperties' => []]], $manager->getProperty('og:title'));
-
-        $manager->removeProperty('og:title');
-        $this->assertEquals([], $manager->getProperty('og:title'));
-
-        $manager->addProperty('og:title', 'Title');
-        $manager->addProperty('og:description', 'Description');
-
-        $manager->removeAllProperties();
-
-        $this->assertEquals([], $manager->getProperty('og:title'));
-        $this->assertEquals([], $manager->getProperty('og:description'));
-    }
-
-    /**
-     * @return array
-     */
-    public function propertiesProvider()
-    {
-        return [
-            [
-                [
-                    'property' => 'og:title',
-                    'content' => 'Test title',
-                    'subProperties' => []
-                ],
-                [
-                    [
-                        'content' => 'Test title',
-                        'subProperties' => []
-                    ]
-                ],
-                '<meta property="og:title" content="Test title" />'
-            ],
-            [
-                [
-                    'property' => 'og:image',
-                    'content' => '/path/to/image',
-                    'subProperties' => []
-                ],
-                [
-                    [
-                        'content' => '/path/to/image',
-                        'subProperties' => []
-                    ]
-                ],
-                '<meta property="og:image" content="/path/to/image" />'
-            ],
-            [
-                [
-                    'property' => 'og:image',
-                    'content' => '/path/to/image',
-                    'subProperties' => ['width' => [400], 'height' => [400]]
-                ],
-                [
-                    [
-                        'content' => '/path/to/image',
-                        'subProperties' => [
-                            'width' => [400],
-                            'height' => [400]
-                        ]
-                    ]
-                ],
-                '<meta property="og:image" content="/path/to/image" />' . PHP_EOL .
-                '<meta property="og:image:width" content="400" />' . PHP_EOL .
-                '<meta property="og:image:height" content="400" />'
-            ]
-        ];
-    }
-}
diff --git a/typo3/sysext/core/Tests/Unit/MetaTag/TwitterCardMetaTagManagerTest.php b/typo3/sysext/core/Tests/Unit/MetaTag/TwitterCardMetaTagManagerTest.php
deleted file mode 100644 (file)
index 25c7fd1..0000000
+++ /dev/null
@@ -1,212 +0,0 @@
-<?php
-declare(strict_types = 1);
-namespace TYPO3\CMS\Core\Tests\Unit\MetaTag;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-use TYPO3\CMS\Core\MetaTag\TwitterCardMetaTagManager;
-
-/**
- * Test case
- */
-class TwitterCardMetaTagManagerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
-{
-    /**
-     * @test
-     */
-    public function checkIfGetAllHandledPropertiesReturnsNonEmptyArray()
-    {
-        $manager = new TwitterCardMetaTagManager();
-        $handledProperties = $manager->getAllHandledProperties();
-
-        $this->assertNotEmpty($handledProperties);
-    }
-
-    /**
-     * @dataProvider propertiesProvider
-     *
-     * @test
-     *
-     * @param array $property
-     * @param array $expected
-     * @param string $expectedRenderedTag
-     */
-    public function checkIfPropertyIsStoredAfterAddingProperty(array $property, array $expected, string $expectedRenderedTag)
-    {
-        $manager = new TwitterCardMetaTagManager();
-        $manager->addProperty(
-            $property['property'],
-            $property['content'],
-            (array)$property['subProperties']
-        );
-
-        $this->assertEquals($expected, $manager->getProperty($property['property']));
-        $this->assertEquals($expectedRenderedTag, $manager->renderProperty($property['property']));
-    }
-
-    /**
-     * @return array
-     */
-    public function propertiesProvider()
-    {
-        return [
-            'title is set' => [
-                [
-                    'property' => 'twitter:title',
-                    'content' => 'Test title',
-                    'subProperties' => []
-                ],
-                [
-                    [
-                        'content' => 'Test title',
-                        'subProperties' => []
-                    ]
-                ],
-                '<meta name="twitter:title" content="Test title" />'
-            ],
-            'image path is set' => [
-                [
-                    'property' => 'twitter:image',
-                    'content' => '/path/to/image',
-                    'subProperties' => []
-                ],
-                [
-                    [
-                        'content' => '/path/to/image',
-                        'subProperties' => []
-                    ]
-                ],
-                '<meta name="twitter:image" content="/path/to/image" />'
-            ],
-            'remove not used subproperties' => [
-                [
-                    'property' => 'twitter:image',
-                    'content' => '/path/to/image',
-                    'subProperties' => ['width' => [400], 'height' => [400]]
-                ],
-                [
-                    [
-                        'content' => '/path/to/image',
-                        'subProperties' => []
-                    ]
-                ],
-                '<meta name="twitter:image" content="/path/to/image" />'
-            ],
-            'set alt to twitter:image' => [
-                [
-                    'property' => 'twitter:image',
-                    'content' => '/path/to/image',
-                    'subProperties' => ['alt' => ['Alternative title']]
-                ],
-                [
-                    [
-                        'content' => '/path/to/image',
-                        'subProperties' => [
-                            'alt' => ['Alternative title']
-                        ]
-                    ]
-                ],
-                '<meta name="twitter:image" content="/path/to/image" />' . PHP_EOL .
-                '<meta name="twitter:image:alt" content="Alternative title" />'
-            ]
-        ];
-    }
-
-    /**
-     * @test
-     */
-    public function checkIfAddingOnlySubPropertyAndNoMainPropertyIsReturningException()
-    {
-        $manager = new TwitterCardMetaTagManager();
-
-        $this->expectException(\UnexpectedValueException::class);
-        $manager->addProperty('og:image:width', '400');
-    }
-
-    /**
-     * @test
-     */
-    public function checkRenderAllPropertiesRendersCorrectMetaTags()
-    {
-        $properties = [
-            [
-                'property' => 'twitter:title',
-                'content' => 'This is a title',
-                'subProperties' => [],
-                'replace' => false,
-                'type' => ''
-            ],
-            [
-                'property' => 'twitter:image',
-                'content' => '/path/to/image',
-                'subProperties' => [
-                    'width' => 400
-                ],
-                'replace' => false,
-                'type' => ''
-            ],
-            [
-                'property' => 'twitter:title',
-                'content' => 'This is the new title',
-                'subProperties' => [],
-                'replace' => true,
-                'type' => ''
-            ],
-            [
-                'property' => 'twitter:image',
-                'content' => '/path/to/image2',
-                'subProperties' => [],
-                'replace' => false,
-                'type' => ''
-            ],
-        ];
-
-        $manager = new TwitterCardMetaTagManager();
-        foreach ($properties as $property) {
-            $manager->addProperty(
-                $property['property'],
-                $property['content'],
-                $property['subProperties'],
-                $property['replace'],
-                $property['type']
-            );
-        }
-
-        $expected = '<meta name="twitter:image" content="/path/to/image" />' . PHP_EOL .
-            '<meta name="twitter:title" content="This is the new title" />';
-
-        $this->assertEquals($expected, $manager->renderAllProperties());
-    }
-
-    /**
-     * @test
-     */
-    public function checkIfRemovePropertyReallyRemovesProperty()
-    {
-        $manager = new TwitterCardMetaTagManager();
-        $manager->addProperty('twitter:title', 'Title');
-        $this->assertEquals([['content' => 'Title', 'subProperties' => []]], $manager->getProperty('twitter:title'));
-
-        $manager->removeProperty('twitter:title');
-        $this->assertEquals([], $manager->getProperty('twitter:title'));
-
-        $manager->addProperty('twitter:title', 'Title');
-        $manager->addProperty('twitter:description', 'Description');
-
-        $manager->removeAllProperties();
-
-        $this->assertEquals([], $manager->getProperty('twitter:title'));
-        $this->assertEquals([], $manager->getProperty('twitter:description'));
-    }
-}
index a1b392d..c983165 100644 (file)
@@ -127,10 +127,6 @@ unset($extractorRegistry);
 
 $metaTagManagerRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\MetaTag\MetaTagManagerRegistry::class);
 $metaTagManagerRegistry->registerManager(
-    'opengraph',
-    \TYPO3\CMS\Core\MetaTag\OpenGraphMetaTagManager::class
-);
-$metaTagManagerRegistry->registerManager(
     'html5',
     \TYPO3\CMS\Core\MetaTag\Html5MetaTagManager::class
 );
@@ -138,8 +134,4 @@ $metaTagManagerRegistry->registerManager(
     'edge',
     \TYPO3\CMS\Core\MetaTag\EdgeMetaTagManager::class
 );
-$metaTagManagerRegistry->registerManager(
-    'twitter',
-    \TYPO3\CMS\Core\MetaTag\TwitterCardMetaTagManager::class
-);
 unset($metaTagManagerRegistry);
diff --git a/typo3/sysext/seo/Classes/Generator/MetaTagGenerator.php b/typo3/sysext/seo/Classes/Generator/MetaTagGenerator.php
deleted file mode 100644 (file)
index 73215df..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-<?php
-declare(strict_types = 1);
-namespace TYPO3\CMS\Seo\Generator;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-use TYPO3\CMS\Core\Imaging\ImageManipulation\CropVariantCollection;
-use TYPO3\CMS\Core\MetaTag\MetaTagManagerRegistry;
-use TYPO3\CMS\Core\Resource\FileReference;
-use TYPO3\CMS\Core\Resource\ProcessedFile;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Extbase\Service\ImageService;
-use TYPO3\CMS\Frontend\Resource\FileCollector;
-
-/**
- * Class to add the metatags for the SEO fields in core
- *
- * @internal
- */
-class MetaTagGenerator
-{
-    /**
-     * Generate the meta tags that can be set in backend and add them to frontend by using the MetaTag API
-     *
-     * @param array $params
-     */
-    public function generate(array $params)
-    {
-        $metaTagManagerRegistry = GeneralUtility::makeInstance(MetaTagManagerRegistry::class);
-
-        if (!empty($params['page']['description'])) {
-            $manager = $metaTagManagerRegistry->getManagerForProperty('description');
-            $manager->addProperty('description', $params['page']['description']);
-        }
-
-        if (!empty($params['page']['og_title'])) {
-            $manager = $metaTagManagerRegistry->getManagerForProperty('og:title');
-            $manager->addProperty('og:title', $params['page']['og_title']);
-        }
-
-        if (!empty($params['page']['og_description'])) {
-            $manager = $metaTagManagerRegistry->getManagerForProperty('og:description');
-            $manager->addProperty('og:description', $params['page']['og_description']);
-        }
-
-        if (!empty($params['page']['og_image'])) {
-            $fileCollector = GeneralUtility::makeInstance(FileCollector::class);
-            $fileCollector->addFilesFromRelation('pages', 'og_image', $params['page']);
-            $manager = $metaTagManagerRegistry->getManagerForProperty('og:image');
-
-            $ogImages = $this->generateSocialImages($fileCollector->getFiles());
-            foreach ($ogImages as $ogImage) {
-                $subProperties = [];
-                $subProperties['url'] = $ogImage['url'];
-                $subProperties['width'] = $ogImage['width'];
-                $subProperties['height'] = $ogImage['height'];
-
-                if (!empty($ogImage['alternative'])) {
-                    $subProperties['alt'] = $ogImage['alternative'];
-                }
-
-                $manager->addProperty(
-                    'og:image',
-                    $ogImage['url'],
-                    $subProperties
-                );
-            }
-        }
-
-        if (!empty($params['page']['twitter_title'])) {
-            $manager = $metaTagManagerRegistry->getManagerForProperty('twitter:title');
-            $manager->addProperty('twitter:title', $params['page']['twitter_title']);
-        }
-
-        if (!empty($params['page']['twitter_description'])) {
-            $manager = $metaTagManagerRegistry->getManagerForProperty('twitter:description');
-            $manager->addProperty('twitter:description', $params['page']['twitter_description']);
-        }
-
-        if (!empty($params['page']['twitter_image'])) {
-            $fileCollector = GeneralUtility::makeInstance(FileCollector::class);
-            $fileCollector->addFilesFromRelation('pages', 'twitter_image', $params['page']);
-            $manager = $metaTagManagerRegistry->getManagerForProperty('twitter:image');
-
-            $twitterImages = $this->generateSocialImages($fileCollector->getFiles());
-            foreach ($twitterImages as $twitterImage) {
-                $subProperties = [];
-
-                if (!empty($twitterImage['alternative'])) {
-                    $subProperties['alt'] = $twitterImage['alternative'];
-                }
-
-                $manager->addProperty(
-                    'twitter:image',
-                    $twitterImage['url'],
-                    $subProperties
-                );
-            }
-        }
-
-        $noIndex = ((bool)$params['page']['no_index']) ? 'noindex' : 'index';
-        $noFollow = ((bool)$params['page']['no_follow']) ? 'nofollow' : 'follow';
-
-        $manager = $metaTagManagerRegistry->getManagerForProperty('robots');
-        $manager->addProperty('robots', implode(',', [$noIndex, $noFollow]));
-    }
-
-    /**
-     * @param array $fileReferences
-     * @return array
-     */
-    protected function generateSocialImages(array $fileReferences): array
-    {
-        $imageService = GeneralUtility::makeInstance(ImageService::class);
-
-        $socialImages = [];
-
-        /** @var FileReference $file */
-        foreach ($fileReferences as $file) {
-            $arguments = $file->getProperties();
-            $cropVariantCollection = CropVariantCollection::create((string)$arguments['crop']);
-            $cropVariant = $arguments['cropVariant'] ?: 'default';
-            $cropArea = $cropVariantCollection->getCropArea($cropVariant);
-            $crop = $cropArea->makeAbsoluteBasedOnFile($file);
-
-            $cropInformation = $crop->asArray();
-
-            $processingConfiguration = [
-                'crop' => $crop
-            ];
-
-            $processedImage = $file->getOriginalFile()->process(
-                ProcessedFile::CONTEXT_IMAGECROPSCALEMASK,
-                $processingConfiguration
-            );
-
-            $imageUri = $imageService->getImageUri($processedImage, true);
-
-            $socialImages[] = [
-                'url' => $imageUri,
-                'width' => floor($cropInformation['width']),
-                'height' => floor($cropInformation['height']),
-                'alternative' => $arguments['alternative'],
-            ];
-        }
-
-        return $socialImages;
-    }
-}
diff --git a/typo3/sysext/seo/Classes/MetaTag/MetaTagGenerator.php b/typo3/sysext/seo/Classes/MetaTag/MetaTagGenerator.php
new file mode 100644 (file)
index 0000000..ef77f74
--- /dev/null
@@ -0,0 +1,161 @@
+<?php
+declare(strict_types = 1);
+
+namespace TYPO3\CMS\Seo\MetaTag;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Core\Imaging\ImageManipulation\CropVariantCollection;
+use TYPO3\CMS\Core\MetaTag\MetaTagManagerRegistry;
+use TYPO3\CMS\Core\Resource\FileReference;
+use TYPO3\CMS\Core\Resource\ProcessedFile;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Extbase\Service\ImageService;
+use TYPO3\CMS\Frontend\Resource\FileCollector;
+
+/**
+ * Class to add the metatags for the SEO fields in core
+ *
+ * @internal
+ */
+class MetaTagGenerator
+{
+    /**
+     * Generate the meta tags that can be set in backend and add them to frontend by using the MetaTag API
+     *
+     * @param array $params
+     */
+    public function generate(array $params)
+    {
+        $metaTagManagerRegistry = GeneralUtility::makeInstance(MetaTagManagerRegistry::class);
+
+        if (!empty($params['page']['description'])) {
+            $manager = $metaTagManagerRegistry->getManagerForProperty('description');
+            $manager->addProperty('description', $params['page']['description']);
+        }
+
+        if (!empty($params['page']['og_title'])) {
+            $manager = $metaTagManagerRegistry->getManagerForProperty('og:title');
+            $manager->addProperty('og:title', $params['page']['og_title']);
+        }
+
+        if (!empty($params['page']['og_description'])) {
+            $manager = $metaTagManagerRegistry->getManagerForProperty('og:description');
+            $manager->addProperty('og:description', $params['page']['og_description']);
+        }
+
+        if (!empty($params['page']['og_image'])) {
+            $fileCollector = GeneralUtility::makeInstance(FileCollector::class);
+            $fileCollector->addFilesFromRelation('pages', 'og_image', $params['page']);
+            $manager = $metaTagManagerRegistry->getManagerForProperty('og:image');
+
+            $ogImages = $this->generateSocialImages($fileCollector->getFiles());
+            foreach ($ogImages as $ogImage) {
+                $subProperties = [];
+                $subProperties['url'] = $ogImage['url'];
+                $subProperties['width'] = $ogImage['width'];
+                $subProperties['height'] = $ogImage['height'];
+
+                if (!empty($ogImage['alternative'])) {
+                    $subProperties['alt'] = $ogImage['alternative'];
+                }
+
+                $manager->addProperty(
+                    'og:image',
+                    $ogImage['url'],
+                    $subProperties
+                );
+            }
+        }
+
+        if (!empty($params['page']['twitter_title'])) {
+            $manager = $metaTagManagerRegistry->getManagerForProperty('twitter:title');
+            $manager->addProperty('twitter:title', $params['page']['twitter_title']);
+        }
+
+        if (!empty($params['page']['twitter_description'])) {
+            $manager = $metaTagManagerRegistry->getManagerForProperty('twitter:description');
+            $manager->addProperty('twitter:description', $params['page']['twitter_description']);
+        }
+
+        if (!empty($params['page']['twitter_image'])) {
+            $fileCollector = GeneralUtility::makeInstance(FileCollector::class);
+            $fileCollector->addFilesFromRelation('pages', 'twitter_image', $params['page']);
+            $manager = $metaTagManagerRegistry->getManagerForProperty('twitter:image');
+
+            $twitterImages = $this->generateSocialImages($fileCollector->getFiles());
+            foreach ($twitterImages as $twitterImage) {
+                $subProperties = [];
+
+                if (!empty($twitterImage['alternative'])) {
+                    $subProperties['alt'] = $twitterImage['alternative'];
+                }
+
+                $manager->addProperty(
+                    'twitter:image',
+                    $twitterImage['url'],
+                    $subProperties
+                );
+            }
+        }
+
+        $noIndex = ((bool)$params['page']['no_index']) ? 'noindex' : 'index';
+        $noFollow = ((bool)$params['page']['no_follow']) ? 'nofollow' : 'follow';
+
+        $manager = $metaTagManagerRegistry->getManagerForProperty('robots');
+        $manager->addProperty('robots', implode(',', [$noIndex, $noFollow]));
+    }
+
+    /**
+     * @param array $fileReferences
+     * @return array
+     */
+    protected function generateSocialImages(array $fileReferences): array
+    {
+        $imageService = GeneralUtility::makeInstance(ImageService::class);
+
+        $socialImages = [];
+
+        /** @var FileReference $file */
+        foreach ($fileReferences as $file) {
+            $arguments = $file->getProperties();
+            $cropVariantCollection = CropVariantCollection::create((string)$arguments['crop']);
+            $cropVariant = $arguments['cropVariant'] ?: 'default';
+            $cropArea = $cropVariantCollection->getCropArea($cropVariant);
+            $crop = $cropArea->makeAbsoluteBasedOnFile($file);
+
+            $cropInformation = $crop->asArray();
+
+            $processingConfiguration = [
+                'crop' => $crop
+            ];
+
+            $processedImage = $file->getOriginalFile()->process(
+                ProcessedFile::CONTEXT_IMAGECROPSCALEMASK,
+                $processingConfiguration
+            );
+
+            $imageUri = $imageService->getImageUri($processedImage, true);
+
+            $socialImages[] = [
+                'url' => $imageUri,
+                'width' => floor($cropInformation['width']),
+                'height' => floor($cropInformation['height']),
+                'alternative' => $arguments['alternative'],
+            ];
+        }
+
+        return $socialImages;
+    }
+}
diff --git a/typo3/sysext/seo/Classes/MetaTag/OpenGraphMetaTagManager.php b/typo3/sysext/seo/Classes/MetaTag/OpenGraphMetaTagManager.php
new file mode 100644 (file)
index 0000000..dcea320
--- /dev/null
@@ -0,0 +1,65 @@
+<?php
+declare(strict_types = 1);
+
+namespace TYPO3\CMS\Seo\MetaTag;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Core\MetaTag\AbstractMetaTagManager;
+
+class OpenGraphMetaTagManager extends AbstractMetaTagManager
+{
+    /**
+     * The default attribute that defines the name of the property
+     *
+     * This creates tags like <meta property="" /> by default
+     *
+     * @var string
+     */
+    protected $defaultNameAttribute = 'property';
+
+    /**
+     * Array of properties that can be handled by this manager
+     *
+     * @var array
+     */
+    protected $handledProperties = [
+        'og:type' => [],
+        'og:title' => [],
+        'og:description' => [],
+        'og:site_name' => [],
+        'og:url' => [],
+        'og:audio' => [],
+        'og:video' => [],
+        'og:determiner' => [],
+        'og:locale' => [
+            'allowedSubProperties' => [
+                'alternate' => [
+                    'allowMultipleOccurrences' => true
+                ],
+            ]
+        ],
+        'og:image' => [
+            'allowMultipleOccurrences' => true,
+            'allowedSubProperties' => [
+                'url' => [],
+                'secure_url' => [],
+                'type' => [],
+                'width' => [],
+                'height' => [],
+                'alt' => [],
+            ]
+        ]
+    ];
+}
diff --git a/typo3/sysext/seo/Classes/MetaTag/TwitterCardMetaTagManager.php b/typo3/sysext/seo/Classes/MetaTag/TwitterCardMetaTagManager.php
new file mode 100644 (file)
index 0000000..20ef817
--- /dev/null
@@ -0,0 +1,68 @@
+<?php
+declare(strict_types = 1);
+
+namespace TYPO3\CMS\Seo\MetaTag;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Core\MetaTag\AbstractMetaTagManager;
+
+class TwitterCardMetaTagManager extends AbstractMetaTagManager
+{
+    /**
+     * Array of properties that can be handled by this manager
+     *
+     * @var array
+     */
+    protected $handledProperties = [
+        'twitter:card' => [],
+        'twitter:site' => [
+            'allowedSubProperties' => [
+                'id' => [],
+            ]
+        ],
+        'twitter:creator' => [
+            'allowedSubProperties' => [
+                'id' => [],
+            ]
+        ],
+        'twitter:description' => [],
+        'twitter:title' => [],
+        'twitter:image' => [
+            'allowedSubProperties' => [
+                'alt' => [],
+            ]
+        ],
+        'twitter:player' => [
+            'allowedSubProperties' => [
+                'width' => [],
+                'height' => [],
+                'stream' => [],
+            ]
+        ],
+        'twitter:app' => [
+            'allowedSubProperties' => [
+                'name:iphone' => [],
+                'id:iphone' => [],
+                'url:iphone' => [],
+                'name:ipad' => [],
+                'id:ipad' => [],
+                'url:ipad' => [],
+                'name:googleplay' => [],
+                'id:googleplay' => [],
+                'url:googleplay' => [],
+            ]
+        ],
+    ];
+}
diff --git a/typo3/sysext/seo/Tests/Unit/MetaTag/OpenGraphMetaTagManagerTest.php b/typo3/sysext/seo/Tests/Unit/MetaTag/OpenGraphMetaTagManagerTest.php
new file mode 100644 (file)
index 0000000..10d5f81
--- /dev/null
@@ -0,0 +1,207 @@
+<?php
+declare(strict_types = 1);
+
+namespace TYPO3\CMS\Seo\Tests\Unit\MetaTag;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Seo\MetaTag\OpenGraphMetaTagManager;
+
+/**
+ * Test case
+ */
+class OpenGraphMetaTagManagerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+{
+    /**
+     * @test
+     */
+    public function checkIfGetAllHandledPropertiesReturnsNonEmptyArray()
+    {
+        $manager = new OpenGraphMetaTagManager();
+        $handledProperties = $manager->getAllHandledProperties();
+
+        $this->assertNotEmpty($handledProperties);
+    }
+
+    /**
+     * @dataProvider propertiesProvider
+     *
+     * @test
+     */
+    public function checkIfPropertyIsStoredAfterAddingProperty($property, $expected, $expectedRenderedTag)
+    {
+        $manager = new OpenGraphMetaTagManager();
+        $manager->addProperty(
+            $property['property'],
+            $property['content'],
+            (array)$property['subProperties']
+        );
+
+        $this->assertEquals($expected, $manager->getProperty($property['property']));
+        $this->assertEquals($expectedRenderedTag, $manager->renderProperty($property['property']));
+    }
+
+    /**
+     * @test
+     */
+    public function checkIfAddingOnlySubPropertyAndNoMainPropertyIsReturningException()
+    {
+        $manager = new OpenGraphMetaTagManager();
+
+        $this->expectException(\UnexpectedValueException::class);
+        $manager->addProperty('og:image:width', '400');
+    }
+
+    /**
+     * @test
+     */
+    public function checkRenderAllPropertiesRendersCorrectMetaTags()
+    {
+        $properties = [
+            [
+                'property' => 'og:title',
+                'content' => 'This is a title',
+                'subProperties' => [],
+                'replace' => false,
+                'type' => ''
+            ],
+            [
+                'property' => 'og:image',
+                'content' => '/path/to/image',
+                'subProperties' => [
+                    'width' => 400
+                ],
+                'replace' => false,
+                'type' => ''
+            ],
+            [
+                'property' => 'og:image:height',
+                'content' => '200',
+                'subProperties' => [],
+                'replace' => false,
+                'type' => ''
+            ],
+            [
+                'property' => 'og:title',
+                'content' => 'This is the new title',
+                'subProperties' => [],
+                'replace' => true,
+                'type' => ''
+            ],
+            [
+                'property' => 'og:image',
+                'content' => '/path/to/image2',
+                'subProperties' => [],
+                'replace' => false,
+                'type' => ''
+            ],
+        ];
+
+        $manager = new OpenGraphMetaTagManager();
+        foreach ($properties as $property) {
+            $manager->addProperty(
+                $property['property'],
+                $property['content'],
+                $property['subProperties'],
+                $property['replace'],
+                $property['type']
+            );
+        }
+
+        $expected = '<meta property="og:image" content="/path/to/image" />' . PHP_EOL .
+            '<meta property="og:image:width" content="400" />' . PHP_EOL .
+            '<meta property="og:image:height" content="200" />' . PHP_EOL .
+            '<meta property="og:image" content="/path/to/image2" />' . PHP_EOL .
+            '<meta property="og:title" content="This is the new title" />';
+
+        $this->assertEquals($expected, $manager->renderAllProperties());
+    }
+
+    /**
+     * @test
+     */
+    public function checkIfRemovePropertyReallyRemovesProperty()
+    {
+        $manager = new OpenGraphMetaTagManager();
+        $manager->addProperty('og:title', 'Title');
+        $this->assertEquals([['content' => 'Title', 'subProperties' => []]], $manager->getProperty('og:title'));
+
+        $manager->removeProperty('og:title');
+        $this->assertEquals([], $manager->getProperty('og:title'));
+
+        $manager->addProperty('og:title', 'Title');
+        $manager->addProperty('og:description', 'Description');
+
+        $manager->removeAllProperties();
+
+        $this->assertEquals([], $manager->getProperty('og:title'));
+        $this->assertEquals([], $manager->getProperty('og:description'));
+    }
+
+    /**
+     * @return array
+     */
+    public function propertiesProvider()
+    {
+        return [
+            [
+                [
+                    'property' => 'og:title',
+                    'content' => 'Test title',
+                    'subProperties' => []
+                ],
+                [
+                    [
+                        'content' => 'Test title',
+                        'subProperties' => []
+                    ]
+                ],
+                '<meta property="og:title" content="Test title" />'
+            ],
+            [
+                [
+                    'property' => 'og:image',
+                    'content' => '/path/to/image',
+                    'subProperties' => []
+                ],
+                [
+                    [
+                        'content' => '/path/to/image',
+                        'subProperties' => []
+                    ]
+                ],
+                '<meta property="og:image" content="/path/to/image" />'
+            ],
+            [
+                [
+                    'property' => 'og:image',
+                    'content' => '/path/to/image',
+                    'subProperties' => ['width' => [400], 'height' => [400]]
+                ],
+                [
+                    [
+                        'content' => '/path/to/image',
+                        'subProperties' => [
+                            'width' => [400],
+                            'height' => [400]
+                        ]
+                    ]
+                ],
+                '<meta property="og:image" content="/path/to/image" />' . PHP_EOL .
+                '<meta property="og:image:width" content="400" />' . PHP_EOL .
+                '<meta property="og:image:height" content="400" />'
+            ]
+        ];
+    }
+}
diff --git a/typo3/sysext/seo/Tests/Unit/MetaTag/TwitterCardMetaTagManagerTest.php b/typo3/sysext/seo/Tests/Unit/MetaTag/TwitterCardMetaTagManagerTest.php
new file mode 100644 (file)
index 0000000..3745fad
--- /dev/null
@@ -0,0 +1,213 @@
+<?php
+declare(strict_types = 1);
+
+namespace TYPO3\CMS\Seo\Tests\Unit\MetaTag;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Seo\MetaTag\TwitterCardMetaTagManager;
+
+/**
+ * Test case
+ */
+class TwitterCardMetaTagManagerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+{
+    /**
+     * @test
+     */
+    public function checkIfGetAllHandledPropertiesReturnsNonEmptyArray()
+    {
+        $manager = new TwitterCardMetaTagManager();
+        $handledProperties = $manager->getAllHandledProperties();
+
+        $this->assertNotEmpty($handledProperties);
+    }
+
+    /**
+     * @dataProvider propertiesProvider
+     *
+     * @test
+     *
+     * @param array $property
+     * @param array $expected
+     * @param string $expectedRenderedTag
+     */
+    public function checkIfPropertyIsStoredAfterAddingProperty(array $property, array $expected, string $expectedRenderedTag)
+    {
+        $manager = new TwitterCardMetaTagManager();
+        $manager->addProperty(
+            $property['property'],
+            $property['content'],
+            (array)$property['subProperties']
+        );
+
+        $this->assertEquals($expected, $manager->getProperty($property['property']));
+        $this->assertEquals($expectedRenderedTag, $manager->renderProperty($property['property']));
+    }
+
+    /**
+     * @return array
+     */
+    public function propertiesProvider()
+    {
+        return [
+            'title is set' => [
+                [
+                    'property' => 'twitter:title',
+                    'content' => 'Test title',
+                    'subProperties' => []
+                ],
+                [
+                    [
+                        'content' => 'Test title',
+                        'subProperties' => []
+                    ]
+                ],
+                '<meta name="twitter:title" content="Test title" />'
+            ],
+            'image path is set' => [
+                [
+                    'property' => 'twitter:image',
+                    'content' => '/path/to/image',
+                    'subProperties' => []
+                ],
+                [
+                    [
+                        'content' => '/path/to/image',
+                        'subProperties' => []
+                    ]
+                ],
+                '<meta name="twitter:image" content="/path/to/image" />'
+            ],
+            'remove not used subproperties' => [
+                [
+                    'property' => 'twitter:image',
+                    'content' => '/path/to/image',
+                    'subProperties' => ['width' => [400], 'height' => [400]]
+                ],
+                [
+                    [
+                        'content' => '/path/to/image',
+                        'subProperties' => []
+                    ]
+                ],
+                '<meta name="twitter:image" content="/path/to/image" />'
+            ],
+            'set alt to twitter:image' => [
+                [
+                    'property' => 'twitter:image',
+                    'content' => '/path/to/image',
+                    'subProperties' => ['alt' => ['Alternative title']]
+                ],
+                [
+                    [
+                        'content' => '/path/to/image',
+                        'subProperties' => [
+                            'alt' => ['Alternative title']
+                        ]
+                    ]
+                ],
+                '<meta name="twitter:image" content="/path/to/image" />' . PHP_EOL .
+                '<meta name="twitter:image:alt" content="Alternative title" />'
+            ]
+        ];
+    }
+
+    /**
+     * @test
+     */
+    public function checkIfAddingOnlySubPropertyAndNoMainPropertyIsReturningException()
+    {
+        $manager = new TwitterCardMetaTagManager();
+
+        $this->expectException(\UnexpectedValueException::class);
+        $manager->addProperty('og:image:width', '400');
+    }
+
+    /**
+     * @test
+     */
+    public function checkRenderAllPropertiesRendersCorrectMetaTags()
+    {
+        $properties = [
+            [
+                'property' => 'twitter:title',
+                'content' => 'This is a title',
+                'subProperties' => [],
+                'replace' => false,
+                'type' => ''
+            ],
+            [
+                'property' => 'twitter:image',
+                'content' => '/path/to/image',
+                'subProperties' => [
+                    'width' => 400
+                ],
+                'replace' => false,
+                'type' => ''
+            ],
+            [
+                'property' => 'twitter:title',
+                'content' => 'This is the new title',
+                'subProperties' => [],
+                'replace' => true,
+                'type' => ''
+            ],
+            [
+                'property' => 'twitter:image',
+                'content' => '/path/to/image2',
+                'subProperties' => [],
+                'replace' => false,
+                'type' => ''
+            ],
+        ];
+
+        $manager = new TwitterCardMetaTagManager();
+        foreach ($properties as $property) {
+            $manager->addProperty(
+                $property['property'],
+                $property['content'],
+                $property['subProperties'],
+                $property['replace'],
+                $property['type']
+            );
+        }
+
+        $expected = '<meta name="twitter:image" content="/path/to/image" />' . PHP_EOL .
+            '<meta name="twitter:title" content="This is the new title" />';
+
+        $this->assertEquals($expected, $manager->renderAllProperties());
+    }
+
+    /**
+     * @test
+     */
+    public function checkIfRemovePropertyReallyRemovesProperty()
+    {
+        $manager = new TwitterCardMetaTagManager();
+        $manager->addProperty('twitter:title', 'Title');
+        $this->assertEquals([['content' => 'Title', 'subProperties' => []]], $manager->getProperty('twitter:title'));
+
+        $manager->removeProperty('twitter:title');
+        $this->assertEquals([], $manager->getProperty('twitter:title'));
+
+        $manager->addProperty('twitter:title', 'Title');
+        $manager->addProperty('twitter:description', 'Description');
+
+        $manager->removeAllProperties();
+
+        $this->assertEquals([], $manager->getProperty('twitter:title'));
+        $this->assertEquals([], $manager->getProperty('twitter:description'));
+    }
+}
index ef3c78f..2f05319 100644 (file)
                "psr-4": {
                        "TYPO3\\CMS\\Seo\\": "Classes/"
                }
+       },
+       "autoload-dev": {
+               "psr-4": {
+                       "TYPO3\\CMS\\Seo\\Tests\\": "Tests/"
+               }
        }
 }
index 8de0b29..6128049 100644 (file)
@@ -1,6 +1,16 @@
 <?php
-
 defined('TYPO3_MODE') or die();
 
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\CMS\Frontend\Page\PageGenerator']['generateMetaTags'][] =
-    \TYPO3\CMS\Seo\Generator\MetaTagGenerator::class . '->generate';
+    \TYPO3\CMS\Seo\MetaTag\MetaTagGenerator::class . '->generate';
+
+$metaTagManagerRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\MetaTag\MetaTagManagerRegistry::class);
+$metaTagManagerRegistry->registerManager(
+    'opengraph',
+    \TYPO3\CMS\Seo\MetaTag\OpenGraphMetaTagManager::class
+);
+$metaTagManagerRegistry->registerManager(
+    'twitter',
+    \TYPO3\CMS\Seo\MetaTag\TwitterCardMetaTagManager::class
+);
+unset($metaTagManagerRegistry);