Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
afe32ce
Refactor constructor parameters in SchemaTwigInjectorSubscriber for c…
Dec 16, 2025
343ecc3
Update .gitignore to include additional configuration files
Dec 16, 2025
b2382ee
Merge branch 'main' of github.com:curenect-meiner/SeoBundle
Dec 19, 2025
7103c47
Add strict types declaration and improve code consistency across mult…
Dec 19, 2025
b1db59a
Refactor attributes and improve type handling in multiple classes
Dec 19, 2025
b38f736
Refactor GenerateSitemapCommand to use readonly property and improve …
Dec 19, 2025
4dd1f4b
Enhance type annotations and add assertions for SEO metadata retrieva…
Dec 19, 2025
6d52112
Refactor GoogleTagCompilerPass and MetaPixelCompilerPass to improve c…
Dec 19, 2025
c6fe069
Refactor event subscriber classes to use readonly properties and enha…
Dec 19, 2025
33a3953
Enhance type annotations in MetaTagsManager and MetaTagsManagerInterf…
Dec 19, 2025
066d2cd
Enhance type annotations for tags and structured properties in Articl…
Dec 19, 2025
f35983f
Enhance type annotations in OGArticleManager and OGArticleManagerInte…
Dec 19, 2025
db6d049
Enhance type annotations for itemListElement method in ItemList class…
Dec 19, 2025
1cf8560
Enhance type annotations for properties and method parameters in vari…
Dec 19, 2025
2c09404
Enhance type annotations in OrganizationTrait and BaseType for improv…
Dec 19, 2025
11510cf
Refactor controller extraction in Sitemap.php for improved clarity an…
Dec 19, 2025
5367350
Refactor assertions in MetaTagsControllerTest for improved clarity an…
Dec 19, 2025
5104d68
Remove redundant assertions in BaseTypeTest for improved clarity
Dec 19, 2025
26c8488
Remove redundant test for nullable BaseType in SchemaTest for improve…
Dec 19, 2025
72b5b98
Enhance type annotations in SeoMeta for improved clarity and type safety
Dec 19, 2025
3bb3d89
Enhance type annotations in OpenGraphManager and OpenGraphManagerInte…
Dec 19, 2025
c0cae0f
Enhance type annotations in MetaTagsExtension for improved clarity an…
Dec 19, 2025
38d5bd3
Enhance type annotations in OpenGraphExtension for improved clarity a…
Dec 19, 2025
3f1e1cb
Enhance type annotations and improve config handling in SeoBundle for…
Dec 19, 2025
b3eaab3
Enhance type annotations in SeoMeta for improved clarity and type safety
Dec 19, 2025
4ee46ae
Refactor structured property handling in OpenGraphManager for improve…
Dec 19, 2025
4ccee16
Refactor getPath method in SeoBundle for improved clarity and efficiency
Dec 19, 2025
dae2d3e
Enhance type safety and clarity in Sitemap.php by adding type annotat…
Dec 19, 2025
bbb5fed
Enhance type safety in SeoMeta and MetaTagsExtension by adding type a…
Dec 19, 2025
f2c22aa
Refactor response handling in event subscribers for improved HTML con…
Dec 19, 2025
d5c8784
Update Symfony package versions in composer.json for improved compati…
Dec 19, 2025
bb463d7
Refactor GenerateSitemapCommand for improved argument handling and cl…
Dec 19, 2025
5e24b22
Enhance type safety in SeoCollector by adding type annotations for re…
Dec 19, 2025
4f648a9
Refactor MetaTagsExtension and OpenGraphExtension to extend AbstractE…
Dec 19, 2025
87d41ad
Refactor MetaTagsExtension and OpenGraphExtension to use readonly cla…
Dec 19, 2025
ee68d5d
Refactor service definitions in services.php for improved clarity and…
Dec 19, 2025
44f2b16
Merge remote-tracking branch 'origin/main' into codecleanupandcacheing
Dec 19, 2025
f40f0ee
Refactor breadcrumb-related classes for improved type safety and clarity
Dec 19, 2025
ebc93ed
Refactor breadcrumb and OpenGraph classes for improved code clarity a…
Dec 19, 2025
5eca22a
Refactor breadcrumb item type annotation for improved clarity and typ…
Dec 19, 2025
7d79f74
Add cache TTL configuration option with default value and validation
Dec 19, 2025
663114c
Implement caching for schema rendering with configurable TTL
Dec 19, 2025
282ed5c
Enhance type annotations in BreadcrumbManager and BreadcrumbManagerIn…
Dec 19, 2025
20838d8
Refactor cache retrieval in SchemaTwigInjectorSubscriber for improved…
Dec 19, 2025
8fa8129
Improve type annotation formatting in BreadcrumbManager for enhanced …
Dec 19, 2025
c4ea70d
Refactor Sitemap.php to use fully qualified class name for Sitemap at…
Dec 19, 2025
4467baa
Improve type annotation formatting in BreadcrumbManager for enhanced …
Dec 20, 2025
5003d5b
Enhance SchemaInterface by adding new methods and fully qualified cla…
Dec 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@
/composer.lock
/.env.test
/.phpunit.result.cache
.php-cs-fixer.dist.php
rector.php
Makefile
phpstan-dev.neon
.ddev
22 changes: 11 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,26 @@
],
"require": {
"php": "^8.2",
"symfony/dependency-injection": "^6.0 || ^7.0 || ^8.0",
"symfony/config": "^6.0 || ^7.0 || ^8.0" ,
"symfony/dependency-injection": "^6.4 || ^7.0 || ^8.0",
"symfony/config": "^6.4 || ^7.0 || ^8.0" ,
"twig/twig": "^2.0 || ^3.0",
"symfony/cache": "^6.0 || ^7.0 || ^8.0",
"symfony/http-kernel": "^6.0 | ^7.0 || ^8.0",
"symfony/routing": "^6.0 || ^7.0 || ^8.0",
"symfony/cache": "^6.4 || ^7.0 || ^8.0",
"symfony/http-kernel": "^6.4 | ^7.0 || ^8.0",
"symfony/routing": "^6.4 || ^7.0 || ^8.0",
"doctrine/persistence": "^3.4 || ^4.0",
"symfony/messenger": "^6.0 || ^7.0 || ^8.0",
"symfony/messenger": "^6.4 || ^7.0 || ^8.0",
"ext-dom": "*",
"symfony/console": "^6.0 || ^7.0 || ^8.0",
"symfony/event-dispatcher": "^6.0 || ^7.0 || ^8.0"
"symfony/console": "^6.4 || ^7.0 || ^8.0",
"symfony/event-dispatcher": "^6.4 || ^7.0 || ^8.0"
},
"require-dev": {
"phpstan/phpstan": "^2.1",
"phpunit/phpunit": "^11 || ^12.1",
"symfony/test-pack": "^1.0",
"symfony/framework-bundle": "^6.0 || ^7.0 || ^8.0",
"symfony/yaml": "^6.0 || ^7.0 || ^8.0",
"symfony/framework-bundle": "^6.4 || ^7.0 || ^8.0",
"symfony/yaml": "^6.4 || ^7.0 || ^8.0",
"symfony/profiler-pack": "^1.0",
"symfony/serializer": "^6.0 || ^7.0 || ^8.0"
"symfony/serializer": "^6.4 || ^7.0 || ^8.0"
},
"license": "MIT",
"autoload": {
Expand Down
5 changes: 5 additions & 0 deletions config/definition.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
->addDefaultsIfNotSet()
->children()
->booleanNode('enabled')->defaultFalse()->end()
->integerNode('cache_ttl')
->info('Cache TTL in seconds')
->defaultValue(604800)
->min(0)
->end()
->end()
->end()
->arrayNode('meta_tags')
Expand Down
9 changes: 3 additions & 6 deletions config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@
$services->set('seo.meta.tags', MetaTagsManager::class)->tag('kernel.reset', ['method' => 'reset']);
$services->alias(MetaTagsManagerInterface::class, 'seo.meta.tags');
$services->set(MetaTagsExtension::class, MetaTagsExtension::class)
->autowire()
->tag('twig.extension');
->autowire();

$services->set('seo.sitemap', Sitemap::class);
$services->alias(SitemapInterface::class, 'seo.sitemap')->public();
Expand All @@ -76,8 +75,7 @@
$services->set('open.graph.bundle', OpenGraphManager::class);
$services->alias(OpenGraphManagerInterface::class, 'open.graph.bundle')->public();

$services->set('open.graph.bundle.twig.extension', OpenGraphExtension::class)
->tag('twig.extension');
$services->set('open.graph.bundle.twig.extension', OpenGraphExtension::class);

$services->set('open.graph', OpenGraphManager::class)->tag('kernel.reset', ['method' => 'reset']);

Expand Down Expand Up @@ -144,6 +142,5 @@
->alias(BreadcrumbManagerInterface::class, 'seo.breadcrumb')->public();
$services
->set(BreadcrumbExtension::class, BreadcrumbExtension::class)
->autowire()
->tag('twig.extension');
->autowire();
};
25 changes: 19 additions & 6 deletions src/Breadcrumb/BreadcrumbManager.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

/*
* Copyright (c) 2025.
*
Expand All @@ -15,6 +18,10 @@

class BreadcrumbManager implements BreadcrumbManagerInterface, ResettableInterface
{
/**
* @param array<int, array{label: string, url: string|null}> $items
* @param array<string, string> $options
*/
public function __construct(
public array $items = [],
public array $options = [],
Expand All @@ -24,7 +31,6 @@ public function __construct(
$this->options['active_item'] = 'active';
}


public function addItem(string $label, ?string $url = null): static
{
$this->items[] = [
Expand All @@ -35,27 +41,34 @@ public function addItem(string $label, ?string $url = null): static
return $this;
}

/**
* @inheritDoc
*/
public function reset(): void
{
$this->items = [];
}

/**
* @return array<int, array{label: string, url: string|null}>
*/
public function getItems(): array
{
return $this->items;
return $this->items;
}

/**
* @return array<string, string>
*/
public function getOptions(): array
{
return $this->options;
}

/**
* @param array<string, string> $options
*/
public function setOptions(array $options): static
{
$this->options = $options;

return $this;
}
}
}
14 changes: 13 additions & 1 deletion src/Breadcrumb/BreadcrumbManagerInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

/*
* Copyright (c) 2025.
*
Expand All @@ -15,9 +18,18 @@ interface BreadcrumbManagerInterface
{
public function addItem(string $label, ?string $url = null): static;

/**
* @return array<int, array{label: string, url: string|null}>
*/
public function getItems(): array;

/**
* @return array<string, string>
*/
public function getOptions(): array;

/**
* @param array<string, string> $options
*/
public function setOptions(array $options): static;
}
}
28 changes: 12 additions & 16 deletions src/Command/GenerateSitemapCommand.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* Copyright (c) 2025.
*
Expand All @@ -13,14 +14,11 @@

namespace Rami\SeoBundle\Command;

use Psr\Log\LoggerInterface;
use Rami\SeoBundle\Sitemap\Message\GenerateSitemapMessage;
use Rami\SeoBundle\Sitemap\SitemapInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Attribute\Argument;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Messenger\MessageBusInterface;

#[AsCommand(
Expand All @@ -29,23 +27,21 @@
aliases: ['seo:sitemap:generate'],
hidden: false,
)]
class GenerateSitemapCommand extends Command
readonly class GenerateSitemapCommand
{
public function __construct(
private MessageBusInterface $messageBus
) {
parent::__construct();
}

protected function configure(): void
{
$this->addArgument('baseUrl', InputArgument::REQUIRED, 'The base url to generate sitemap');
}
public function __invoke(
#[Argument(description: 'The base url to generate sitemap', name: 'Base Url')]
string $baseUrl,
SymfonyStyle $symfonyStyle
): int {
$this->messageBus->dispatch(new GenerateSitemapMessage($baseUrl));
$symfonyStyle->success('Generating Sitemap');

protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->messageBus->dispatch(new GenerateSitemapMessage($input->getArgument('baseUrl')));
$output->writeln("<info>Generating Sitemap</info>");
return Command::SUCCESS;
}
}
43 changes: 32 additions & 11 deletions src/DataCollector/SeoCollector.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

/*
* Copyright (c) 2025.
*
Expand All @@ -17,13 +20,17 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Throwable;

use function assert;
use function is_array;

class SeoCollector extends AbstractDataCollector
{
public function __construct(
private MetaTagsManagerInterface $metaTagsManager,
private NormalizerInterface $normalizer,
private OpenGraphManagerInterface $openGraphManager,
private readonly MetaTagsManagerInterface $metaTagsManager,
private readonly NormalizerInterface $normalizer,
private readonly OpenGraphManagerInterface $openGraphManager,
) {
}

Expand All @@ -32,7 +39,7 @@ public static function getTemplate(): ?string
return 'templates/seo/data_collector.html.twig';
}

public function collect(Request $request, Response $response, ?\Throwable $exception = null): void
public function collect(Request $request, Response $response, ?Throwable $exception = null): void
{
$this->data['seo_metas'] = $this->normalizer->normalize(
$this->metaTagsManager->getSeoMeta(),
Expand All @@ -53,22 +60,36 @@ public function collect(Request $request, Response $response, ?\Throwable $excep
);
}

/** @return [] */
/**
* @return array<string, mixed>
*/
public function getSeoMetas(): array
{
return $this->data['seo_metas'];
$data = $this->data['seo_metas'] ?? [];
assert(is_array($data));

/** @var array<string, mixed> $returnData */
$returnData = $data;

return $returnData;
}

/** @return [] */
/**
* @return array<string, mixed>
*/
public function getOpenGraph(): array
{
return $this->data['open_graph'];
}
$data = $this->data['open_graph'] ?? [];
assert(is_array($data));

/** @var array<string, mixed> $returnData */
$returnData = $data;

return $returnData;
}

public function reset(): void
{
$this->data = [];
}

}
}
15 changes: 11 additions & 4 deletions src/DependencyInjection/CompilerPasses/GoogleTagCompilerPass.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* Copyright (c) 2025.
*
Expand All @@ -13,8 +14,11 @@

namespace Rami\SeoBundle\DependencyInjection\CompilerPasses;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

use function assert;
use function is_array;

class GoogleTagCompilerPass implements CompilerPassInterface
{
Expand All @@ -30,9 +34,12 @@ public function process(ContainerBuilder $container): void
return;
}

foreach ($container->findTaggedServiceIds('seo.google_tag_manager') as $id => $tags) {
$definition->addMethodCall('enableGoogleTagManager',[
$container->getParameter('seo.google_tag_manager')['tag_manager_id'],
foreach ($container->findTaggedServiceIds('seo.google_tag_manager') as $tags) {
$config = $container->getParameter('seo.google_tag_manager');
assert(is_array($config));

$definition->addMethodCall('enableGoogleTagManager', [
$config['tag_manager_id'],
]);
}
}
Expand Down
Loading