Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/2.x' into merge-2.x
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/Block/Breadcrumb/BaseBreadcrumbMenuBlockService.php
#	src/Block/Breadcrumb/HomepageBreadcrumbBlockService.php
#	src/Block/Social/BaseFacebookSocialPluginsBlockService.php
#	src/Block/Social/BaseTwitterButtonBlockService.php
#	src/Block/Social/EmailShareButtonBlockService.php
#	src/Block/Social/FacebookLikeBoxBlockService.php
#	src/Block/Social/FacebookLikeButtonBlockService.php
#	src/Block/Social/FacebookSendButtonBlockService.php
#	src/Block/Social/FacebookShareButtonBlockService.php
#	src/Block/Social/PinterestPinButtonBlockService.php
#	src/Block/Social/TwitterEmbedTweetBlockService.php
#	src/Block/Social/TwitterFollowButtonBlockService.php
#	src/Block/Social/TwitterHashtagButtonBlockService.php
#	src/Block/Social/TwitterMentionButtonBlockService.php
#	src/Block/Social/TwitterShareButtonBlockService.php
#	src/Command/SitemapGeneratorCommand.php
#	src/DependencyInjection/Compiler/BreadcrumbBlockServicesCompilerPass.php
#	src/DependencyInjection/Configuration.php
#	src/DependencyInjection/SonataSeoExtension.php
#	src/Event/BreadcrumbListener.php
#	src/Resources/config/blocks.xml
#	src/Seo/SeoPage.php
#	src/Seo/SeoPageInterface.php
#	src/Sitemap/SourceManager.php
#	src/SonataSeoBundle.php
#	src/Twig/Extension/SeoExtension.php
#	tests/DependencyInjection/Compiler/BreadcrumbBlockServicesCompilerPassTest.php
#	tests/DependencyInjection/Compiler/ServiceCompilerPassTest.php
#	tests/DependencyInjection/ConfigurationTest.php
#	tests/Seo/SeoPageTest.php
#	tests/Twig/Extension/SeoExtensionTest.php
  • Loading branch information
core23 committed Oct 7, 2021
2 parents c253f2f + 9fd630b commit 23cf25d
Show file tree
Hide file tree
Showing 15 changed files with 174 additions and 87 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"seo",
"sonata"
],
"homepage": "https://sonata-project.org/bundles/seo",
"homepage": "https://docs.sonata-project.org/projects/SonataSeoBundle",
"license": "MIT",
"authors": [
{
Expand Down
3 changes: 1 addition & 2 deletions src/Block/Breadcrumb/BaseBreadcrumbMenuBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Knp\Menu\ItemInterface;
use Sonata\BlockBundle\Block\BlockContextInterface;
use Sonata\BlockBundle\Block\Service\AbstractBlockService;
use Sonata\SeoBundle\BreadcrumbInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Twig\Environment;

Expand All @@ -26,7 +25,7 @@
*
* @author Sylvain Deloux <sylvain.deloux@ekino.com>
*/
abstract class BaseBreadcrumbMenuBlockService extends AbstractBlockService implements BreadcrumbInterface
abstract class BaseBreadcrumbMenuBlockService extends AbstractBlockService implements BreadcrumbBlockService
{
private FactoryInterface $factory;

Expand Down
20 changes: 20 additions & 0 deletions src/Block/Breadcrumb/BreadcrumbBlockService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Sonata Project package.
*
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Sonata\SeoBundle\Block\Breadcrumb;

use Sonata\SeoBundle\BreadcrumbInterface;

interface BreadcrumbBlockService extends BreadcrumbInterface
{
}
3 changes: 3 additions & 0 deletions src/BreadcrumbInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

use Sonata\BlockBundle\Block\Service\BlockServiceInterface;

/**
* @deprecated since sonata-project/seo-bundle 2.x, to be removed in 3.0. Use Sonata\SeoBundle\Block\Breadcrumb\Breadcrumb instead.
*/
interface BreadcrumbInterface extends BlockServiceInterface
{
public function handleContext(string $context): bool;
Expand Down
12 changes: 6 additions & 6 deletions src/DependencyInjection/SonataSeoExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

Expand All @@ -33,15 +33,15 @@ public function load(array $configs, ContainerBuilder $container): void

$bundles = $container->getParameter('kernel.bundles');

$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader = new Loader\PhpFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));

if (isset($bundles['SonataBlockBundle'], $bundles['KnpMenuBundle'])) {
$loader->load('blocks.xml');
$loader->load('blocks.php');
}

$loader->load('event.xml');
$loader->load('services.xml');
$loader->load('commands.xml');
$loader->load('event.php');
$loader->load('services.php');
$loader->load('commands.php');

$this->configureSeoPage($config['page'], $container);
$this->configureSitemap($config['sitemap'], $container);
Expand Down
35 changes: 35 additions & 0 deletions src/Resources/config/blocks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Sonata Project package.
*
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use Sonata\SeoBundle\Block\Breadcrumb\HomepageBreadcrumbBlockService;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\DependencyInjection\Loader\Configurator\ReferenceConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
// Use "service" function for creating references to services when dropping support for Symfony 4.4
// Use "param" function for creating references to parameters when dropping support for Symfony 5.1
$containerConfigurator->parameters()
->set('sonata.seo.block.breadcrumb.homepage.class', HomepageBreadcrumbBlockService::class);

$containerConfigurator->services()

// Breadcrumb
->set('sonata.seo.block.breadcrumb.homepage', '%sonata.seo.block.breadcrumb.homepage.class%')
->public()
->tag('sonata.block')
->tag('sonata.breadcrumb')
->args([
new ReferenceConfigurator('twig'),
new ReferenceConfigurator('knp_menu.factory'),
]);
};
14 changes: 0 additions & 14 deletions src/Resources/config/blocks.xml

This file was deleted.

30 changes: 30 additions & 0 deletions src/Resources/config/commands.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Sonata Project package.
*
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use Sonata\SeoBundle\Command\SitemapGeneratorCommand;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\DependencyInjection\Loader\Configurator\ReferenceConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
// Use "service" function for creating references to services when dropping support for Symfony 4.4
// Use "param" function for creating references to parameters when dropping support for Symfony 5.1
$containerConfigurator->services()

->set(SitemapGeneratorCommand::class)
->tag('console.command')
->args([
new ReferenceConfigurator('router'),
new ReferenceConfigurator('sonata.seo.sitemap.manager'),
new ReferenceConfigurator('filesystem'),
]);
};
11 changes: 0 additions & 11 deletions src/Resources/config/commands.xml

This file was deleted.

27 changes: 27 additions & 0 deletions src/Resources/config/event.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Sonata Project package.
*
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use Sonata\SeoBundle\Event\BreadcrumbListener;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
// Use "service" function for creating references to services when dropping support for Symfony 4.4
// Use "param" function for creating references to parameters when dropping support for Symfony 5.1
$containerConfigurator->services()

->set('sonata.seo.event.breadcrumb', BreadcrumbListener::class)
->tag('kernel.event_listener', [
'event' => 'sonata.block.event.breadcrumb',
'method' => 'onBlock',
]);
};
8 changes: 0 additions & 8 deletions src/Resources/config/event.xml

This file was deleted.

51 changes: 51 additions & 0 deletions src/Resources/config/services.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Sonata Project package.
*
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use Sonata\Exporter\Source\DoctrineDBALConnectionSourceIterator;
use Sonata\Exporter\Source\SymfonySitemapSourceIterator;
use Sonata\SeoBundle\Seo\SeoPage;
use Sonata\SeoBundle\Sitemap\SourceManager;
use Sonata\SeoBundle\Twig\Extension\SeoExtension;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\DependencyInjection\Loader\Configurator\ReferenceConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
// Use "service" function for creating references to services when dropping support for Symfony 4.4
// Use "param" function for creating references to parameters when dropping support for Symfony 5.1
$containerConfigurator->parameters()

->set('sonata.seo.exporter.database_source_iterator.class', DoctrineDBALConnectionSourceIterator::class)

->set('sonata.seo.exporter.sitemap_source_iterator.class', SymfonySitemapSourceIterator::class)

->set('sonata.seo.page.default.class', SeoPage::class)

->set('sonata.seo.twig.extension.class', SeoExtension::class)

->set('sonata.seo.sitemap.manager.class', SourceManager::class);

$containerConfigurator->services()

->set('sonata.seo.page.default', '%sonata.seo.page.default.class%')
->public()

->set('sonata.seo.twig.extension', '%sonata.seo.twig.extension.class%')
->tag('twig.extension')
->args([
new ReferenceConfigurator('sonata.seo.page'),
'',
])

->set('sonata.seo.sitemap.manager', '%sonata.seo.sitemap.manager.class%')
->public();
};
19 changes: 0 additions & 19 deletions src/Resources/config/services.xml

This file was deleted.

13 changes: 0 additions & 13 deletions src/Seo/SeoPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,6 @@ public function setTitle(string $title): self
return $this;
}

public function addTitle(string $title): self
{
@trigger_error(
'The '.__METHOD__.' method is deprecated since 2.14, to be removed in 3.0. '.
'Use '.__NAMESPACE__.'::addTitlePrefix() or '.__NAMESPACE__.'::addTitleSuffix .instead.',
\E_USER_DEPRECATED
);

$this->title = $title.$this->separator.$this->title;

return $this;
}

public function addTitlePrefix(string $prefix): self
{
$this->title = $prefix.$this->separator.$this->title;
Expand Down
13 changes: 0 additions & 13 deletions tests/Seo/SeoPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,6 @@ public function testSetTitle(): void
static::assertSame('My title', $page->getTitle());
}

/**
* @group legacy
*/
public function testAddTitle(): void
{
$page = new SeoPage();
$page->setTitle('My title');
$page->setSeparator(' - ');
$page->addTitle('Additional title');

static::assertSame('Additional title - My title', $page->getTitle());
}

public function addTitlePrefix(): void
{
$page = new SeoPage();
Expand Down

0 comments on commit 23cf25d

Please sign in to comment.