Skip to content

Commit

Permalink
5.1.1 (#1216)
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet authored Oct 18, 2024
1 parent a9a2f68 commit 039764d
Show file tree
Hide file tree
Showing 18 changed files with 46 additions and 42 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [5.1.1](https://github.com/sonata-project/SonataBlockBundle/compare/5.1.0...5.1.1) - 2024-10-18
### Fixed
- [[#1212](https://github.com/sonata-project/SonataBlockBundle/pull/1212)] Symfony 7.1 deprecation about `Symfony\Component\HttpKernel\DependencyInjection\Extension` usage ([@VincentLanglet](https://github.com/VincentLanglet))

## [5.1.0](https://github.com/sonata-project/SonataBlockBundle/compare/5.0.1...5.1.0) - 2023-11-23
### Added
- [[#1193](https://github.com/sonata-project/SonataBlockBundle/pull/1193)] Symfony 7 support ([@VincentLanglet](https://github.com/VincentLanglet))
Expand Down
6 changes: 3 additions & 3 deletions src/Block/BlockContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class BlockContext implements BlockContextInterface
*/
public function __construct(
private BlockInterface $block,
private array $settings = []
private array $settings = [],
) {
}

Expand All @@ -39,7 +39,7 @@ public function getSettings(): array
public function getSetting(string $name): mixed
{
if (!\array_key_exists($name, $this->settings)) {
throw new \RuntimeException(sprintf('Unable to find the option `%s` (%s) - define the option in the related BlockServiceInterface', $name, $this->block->getType() ?? ''));
throw new \RuntimeException(\sprintf('Unable to find the option `%s` (%s) - define the option in the related BlockServiceInterface', $name, $this->block->getType() ?? ''));
}

return $this->settings[$name];
Expand All @@ -48,7 +48,7 @@ public function getSetting(string $name): mixed
public function setSetting(string $name, mixed $value): BlockContextInterface
{
if (!\array_key_exists($name, $this->settings)) {
throw new \RuntimeException(sprintf('It\'s not possible add non existing setting `%s`.', $name));
throw new \RuntimeException(\sprintf('It\'s not possible add non existing setting `%s`.', $name));
}

$this->settings[$name] = $value;
Expand Down
4 changes: 2 additions & 2 deletions src/Block/BlockContextManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ final class BlockContextManager implements BlockContextManagerInterface
public function __construct(
private BlockLoaderInterface $blockLoader,
private BlockServiceManagerInterface $blockService,
?LoggerInterface $logger = null
?LoggerInterface $logger = null,
) {
$this->logger = $logger ?? new NullLogger();
}
Expand Down Expand Up @@ -87,7 +87,7 @@ public function get($meta, array $settings = []): BlockContextInterface
try {
$settings = $this->resolve($block, array_merge($block->getSettings(), $settings));
} catch (ExceptionInterface $e) {
$this->logger->error(sprintf(
$this->logger->error(\sprintf(
'[cms::blockContext] block.id=%s - error while resolving options - %s',
$block->getId() ?? '',
$e->getMessage()
Expand Down
4 changes: 2 additions & 2 deletions src/Block/BlockLoaderChain.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function exists(string $type): bool
public function load($configuration): BlockInterface
{
if (!\is_string($configuration) && !\is_array($configuration)) {
throw new \TypeError(sprintf(
throw new \TypeError(\sprintf(
'Argument 1 passed to %s must be of type string or array, %s given',
__METHOD__,
\gettype($configuration)
Expand All @@ -63,7 +63,7 @@ public function load($configuration): BlockInterface
public function support($configuration): bool
{
if (!\is_string($configuration) && !\is_array($configuration)) {
throw new \TypeError(sprintf(
throw new \TypeError(\sprintf(
'Argument 1 passed to %s must be of type string or array, %s given',
__METHOD__,
\gettype($configuration)
Expand Down
6 changes: 3 additions & 3 deletions src/Block/BlockRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class BlockRenderer implements BlockRendererInterface
public function __construct(
private BlockServiceManagerInterface $blockServiceManager,
private StrategyManagerInterface $exceptionStrategyManager,
private ?LoggerInterface $logger = null
private ?LoggerInterface $logger = null,
) {
}

Expand All @@ -35,7 +35,7 @@ public function render(BlockContextInterface $blockContext, ?Response $response

if (null !== $this->logger) {
$this->logger->info(
sprintf('[cms::renderBlock] block.id=%d, block.type=%s', $block->getId() ?? '', $block->getType() ?? '')
\sprintf('[cms::renderBlock] block.id=%d, block.type=%s', $block->getId() ?? '', $block->getType() ?? '')
);
}

Expand All @@ -46,7 +46,7 @@ public function render(BlockContextInterface $blockContext, ?Response $response
$response = $service->execute($blockContext, $response ?? new Response());
} catch (\Throwable $exception) {
if (null !== $this->logger) {
$this->logger->error(sprintf(
$this->logger->error(\sprintf(
'[cms::renderBlock] block.id=%d - error while rendering block - %s',
$block->getId() ?? '',
$exception->getMessage()
Expand Down
8 changes: 4 additions & 4 deletions src/Block/BlockServiceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ final class BlockServiceManager implements BlockServiceManagerInterface
*/
public function __construct(
private ContainerInterface $container,
private array $containerTypes
private array $containerTypes,
) {
}

Expand Down Expand Up @@ -74,7 +74,7 @@ public function has(string $name): bool
public function add(string $name, $service, array $contexts = []): void
{
if (!\is_string($service) && !$service instanceof BlockServiceInterface) {
throw new \TypeError(sprintf(
throw new \TypeError(\sprintf(
'Argument 2 passed to %s() must be of type string or an object implementing %s, %s given',
__METHOD__,
BlockServiceInterface::class,
Expand Down Expand Up @@ -160,13 +160,13 @@ public function validate(ErrorElement $errorElement, BlockInterface $block): voi
private function load(string $type): BlockServiceInterface
{
if (!$this->has($type)) {
throw new BlockServiceNotFoundException(sprintf('The block service `%s` does not exist', $type));
throw new BlockServiceNotFoundException(\sprintf('The block service `%s` does not exist', $type));
}

if (!$this->services[$type] instanceof BlockServiceInterface) {
$blockService = $this->container->get($type);
if (!$blockService instanceof BlockServiceInterface) {
throw new BlockServiceNotFoundException(sprintf('The service %s does not implement BlockServiceInterface', $type));
throw new BlockServiceNotFoundException(\sprintf('The service %s does not implement BlockServiceInterface', $type));
}

$this->services[$type] = $blockService;
Expand Down
6 changes: 3 additions & 3 deletions src/Block/Loader/ServiceLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function exists(string $type): bool
public function load($configuration): BlockInterface
{
if (!\is_string($configuration) && !\is_array($configuration)) {
throw new \TypeError(sprintf(
throw new \TypeError(\sprintf(
'Argument 1 passed to %s must be of type string or array, %s given',
__METHOD__,
\gettype($configuration)
Expand All @@ -53,7 +53,7 @@ public function load($configuration): BlockInterface
}

if (!\in_array($configuration['type'], $this->types, true)) {
throw new \RuntimeException(sprintf(
throw new \RuntimeException(\sprintf(
'The block type "%s" does not exist',
$configuration['type']
));
Expand All @@ -73,7 +73,7 @@ public function load($configuration): BlockInterface
public function support($configuration): bool
{
if (!\is_string($configuration) && !\is_array($configuration)) {
throw new \TypeError(sprintf(
throw new \TypeError(\sprintf(
'Argument 1 passed to %s must be of type string or array, %s given',
__METHOD__,
\gettype($configuration)
Expand Down
2 changes: 1 addition & 1 deletion src/Block/Service/MenuBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final class MenuBlockService extends AbstractMenuBlockService
public function __construct(
Environment $twig,
private MenuProviderInterface $menuProvider,
private MenuRegistryInterface $menuRegistry
private MenuRegistryInterface $menuRegistry,
) {
parent::__construct($twig);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Command/DebugBlocksCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,20 @@ public function execute(InputInterface $input, OutputInterface $output): int

$title = '';
if ($service instanceof EditableBlockService) {
$title = sprintf(' (<comment>%s</comment>)', $service->getMetadata()->getTitle());
$title = \sprintf(' (<comment>%s</comment>)', $service->getMetadata()->getTitle());
}
$output->writeln(sprintf('<info>>> %s</info>%s', $code, $title));
$output->writeln(\sprintf('<info>>> %s</info>%s', $code, $title));

$resolver = new OptionsResolver();
$service->configureSettings($resolver);

try {
foreach ($resolver->resolve() as $key => $val) {
$output->writeln(sprintf(' %-30s%s', $key, json_encode($val, \JSON_THROW_ON_ERROR)));
$output->writeln(\sprintf(' %-30s%s', $key, json_encode($val, \JSON_THROW_ON_ERROR)));
}
} catch (MissingOptionsException) {
foreach ($resolver->getDefinedOptions() as $option) {
$output->writeln(sprintf(' %s', $option));
$output->writeln(\sprintf(' %s', $option));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Compiler/TweakCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function process(ContainerBuilder $container): void
foreach ($container->findTaggedServiceIds('knp_menu.menu') as $serviceId => $tags) {
foreach ($tags as $attributes) {
if (!isset($attributes['alias'])) {
throw new \InvalidArgumentException(sprintf('The alias is not defined in the "knp_menu.menu" tag for the service "%s"', $serviceId));
throw new \InvalidArgumentException(\sprintf('The alias is not defined in the "knp_menu.menu" tag for the service "%s"', $serviceId));
}
$registry->addMethodCall('add', [$attributes['alias']]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/Renderer/InlineDebugRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(
private Environment $twig,
private string $template,
private bool $debug,
private bool $forceStyle = true
private bool $forceStyle = true,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Exception/Renderer/InlineRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class InlineRenderer implements RendererInterface
{
public function __construct(
private Environment $twig,
private string $template
private string $template,
) {
}

Expand Down
10 changes: 5 additions & 5 deletions src/Exception/Strategy/StrategyManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct(
private array $filters,
private array $renderers,
private array $blockFilters,
private array $blockRenderers
private array $blockRenderers,
) {
}

Expand All @@ -57,7 +57,7 @@ public function __construct(
public function setDefaultFilter(string $name): void
{
if (!\array_key_exists($name, $this->filters)) {
throw new \InvalidArgumentException(sprintf('Cannot set default exception filter "%s". It does not exist.', $name));
throw new \InvalidArgumentException(\sprintf('Cannot set default exception filter "%s". It does not exist.', $name));
}

$this->defaultFilter = $name;
Expand All @@ -71,7 +71,7 @@ public function setDefaultFilter(string $name): void
public function setDefaultRenderer(string $name): void
{
if (!\array_key_exists($name, $this->renderers)) {
throw new \InvalidArgumentException(sprintf('Cannot set default exception renderer "%s". It does not exist.', $name));
throw new \InvalidArgumentException(\sprintf('Cannot set default exception renderer "%s". It does not exist.', $name));
}

$this->defaultRenderer = $name;
Expand Down Expand Up @@ -119,7 +119,7 @@ public function getBlockRenderer(BlockInterface $block): RendererInterface
$service = $this->container->get($this->renderers[$name]);

if (!$service instanceof RendererInterface) {
throw new \InvalidArgumentException(sprintf('The service "%s" is not an exception renderer.', $name));
throw new \InvalidArgumentException(\sprintf('The service "%s" is not an exception renderer.', $name));
}

return $service;
Expand All @@ -145,7 +145,7 @@ public function getBlockFilter(BlockInterface $block): FilterInterface
$service = $this->container->get($this->filters[$name]);

if (!$service instanceof FilterInterface) {
throw new \InvalidArgumentException(sprintf('The service "%s" is not an exception filter.', $name));
throw new \InvalidArgumentException(\sprintf('The service "%s" is not an exception filter.', $name));
}

return $service;
Expand Down
4 changes: 2 additions & 2 deletions src/Form/Type/ServiceListType.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public function configureOptions(OptionsResolver $resolver): void
$types = [];
foreach ($manager->getServicesByContext($options['context'], $options['include_containers']) as $code => $service) {
if ($service instanceof EditableBlockService) {
$types[sprintf('%s - %s', $service->getMetadata()->getTitle(), $code)] = $code;
$types[\sprintf('%s - %s', $service->getMetadata()->getTitle(), $code)] = $code;
} else {
$types[sprintf('%s', $code)] = $code;
$types[\sprintf('%s', $code)] = $code;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Meta/Metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(
private ?string $description = null,
private ?string $image = null,
private ?string $domain = null,
private array $options = []
private array $options = [],
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Model/BaseBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function __construct()

public function __toString(): string
{
return sprintf('%s ~ #%s', $this->getName() ?? '', $this->getId() ?? '');
return \sprintf('%s ~ #%s', $this->getName() ?? '', $this->getId() ?? '');
}

public function setName(string $name): void
Expand Down
2 changes: 1 addition & 1 deletion src/Profiler/DataCollector/BlockDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ final class BlockDataCollector extends DataCollector
*/
public function __construct(
private BlockHelper $blocksHelper,
private array $containerTypes
private array $containerTypes,
) {
$this->reset();
}
Expand Down
14 changes: 7 additions & 7 deletions src/Templating/Helper/BlockHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function __construct(
private BlockRendererInterface $blockRenderer,
private BlockContextManagerInterface $blockContextManager,
private EventDispatcherInterface $eventDispatcher,
private ?Stopwatch $stopwatch = null
private ?Stopwatch $stopwatch = null,
) {
}

Expand All @@ -79,7 +79,7 @@ public function includeJavascripts($media, $basePath = '')
{
$html = '';
foreach ($this->assets['js'] as $javascript) {
$html .= "\n".sprintf('<script src="%s%s" type="text/javascript"></script>', $basePath, $javascript);
$html .= "\n".\sprintf('<script src="%s%s" type="text/javascript"></script>', $basePath, $javascript);
}

return $html;
Expand All @@ -97,10 +97,10 @@ public function includeStylesheets($media, $basePath = '')
return '';
}

$html = sprintf("<style type='text/css' media='%s'>", $media);
$html = \sprintf("<style type='text/css' media='%s'>", $media);

foreach ($this->assets['css'] as $stylesheet) {
$html .= "\n".sprintf('@import url(%s%s);', $basePath, $stylesheet);
$html .= "\n".\sprintf('@import url(%s%s);', $basePath, $stylesheet);
}

$html .= "\n</style>";
Expand All @@ -113,7 +113,7 @@ public function includeStylesheets($media, $basePath = '')
*/
public function renderEvent(string $name, array $options = []): string
{
$eventName = sprintf('sonata.block.event.%s', $name);
$eventName = \sprintf('sonata.block.event.%s', $name);

$event = $this->eventDispatcher->dispatch(new BlockEvent($options), $eventName);

Expand Down Expand Up @@ -188,7 +188,7 @@ private function stopTracing(BlockInterface $block, array $stats): void
$event = $this->traces[$block->getId() ?? ''];
if (!$event instanceof StopwatchEvent) {
throw new \InvalidArgumentException(
sprintf('The block %s has no stopwatch event to stop.', $block->getId() ?? '')
\sprintf('The block %s has no stopwatch event to stop.', $block->getId() ?? '')
);
}

Expand Down Expand Up @@ -250,7 +250,7 @@ private function startTracing(BlockInterface $block): array
{
if (null !== $this->stopwatch) {
$this->traces[$block->getId() ?? ''] = $this->stopwatch->start(
sprintf(
\sprintf(
'%s (id: %s, type: %s)',
$block->getName() ?? '',
$block->getId() ?? '',
Expand Down

0 comments on commit 039764d

Please sign in to comment.