PHP code example of georgringer / news-importicsxml

1. Go to this page and download the library: Download georgringer/news-importicsxml library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

georgringer / news-importicsxml example snippets




declare(strict_types=1);

namespace Vendor\MyExtension\EventListener;

use GeorgRinger\News\Event\NewsPostImportEvent;
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Core\Cache\CacheManager;

#[AsEventListener]
final class FlushNewsCacheAfterImport
{
    public function __construct(private readonly CacheManager $cacheManager) {}

    public function __invoke(NewsPostImportEvent $event): void
    {
        $pids = array_unique(array_column($event->getImportData(), 'pid'));
        $this->cacheManager->flushCachesInGroupByTags(
            'pages',
            array_map(static fn ($pid): string => 'tx_news_pid_' . $pid, $pids)
        );
    }
}