Skip to content

Latest commit

 

History

History
30 lines (24 loc) · 715 Bytes

10_CustomExtractor.md

File metadata and controls

30 lines (24 loc) · 715 Bytes

Custom Extractor

Integrating a custom extractor is very easy.

App\MetaData\Extractor\DescriptionExtractor:
    tags:
        - {name: seo.meta_data.extractor, identifier: my_object_description }
<?php

namespace App\MetaData\Extractor;

use SeoBundle\MetaData\Extractor\ExtractorInterface;
use SeoBundle\Model\SeoMetaDataInterface;

class DescriptionExtractor implements ExtractorInterface
{
    public function supports(mixed $element): bool
    {
        return $element instanceof MyObject;
    }

    public function updateMetaData($element, ?string $locale, SeoMetaDataInterface $seoMetadata): void
    {
        $seoMetadata->setMetaDescription($element->getDescription());
    }
}