Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove 4.x deprecations #2410

Merged
merged 4 commits into from
Apr 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"behatch/contexts": "^3.3",
"bobdenotter/configuration-notices": "^1.1.10",
"bobdenotter/weatherwidget": "^1.1",
"bolt/newswidget": "^1.2",
"bolt/newswidget": "^1.3",
"coduo/php-matcher": "^5.0",
"dama/doctrine-test-bundle": "^6.2.0",
"friends-of-behat/mink": "^1.8",
Expand Down
2 changes: 1 addition & 1 deletion public/theme/skeleton/partials/_recordfooter.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{% endif %}
{{ __('general.phrase.written-by-on', {
'%name%': record.author.displayName|default(__('Unknown')),
'%date%': record.publishedAt|localedatetime("%A %B %e, %Y")
'%date%': record.publishedAt|localdate
}) }}
</p>

Expand Down
8 changes: 0 additions & 8 deletions src/Controller/TwigAwareController.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,6 @@ public function setAutowire(Config $config, Environment $twig, Packages $package
$this->commonExtension = $commonExtension;
}

/**
* @deprecated since Bolt 4.0, use "render()" instead
*/
public function renderTemplate($template, array $parameters = [], ?Response $response = null): Response
{
return $this->render($template, $parameters, $response);
}

/**
* Renders a view.
*
Expand Down
8 changes: 0 additions & 8 deletions src/Event/UserEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,6 @@ public function __construct(User $user, ?Collection $roleOptions = null)
}
}

/**
* @deprecated
*/
public function getContent(): User
{
return $this->user;
}

public function getUser(): User
{
return $this->user;
Expand Down
31 changes: 0 additions & 31 deletions src/Extension/BaseExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use ComposerPackages\Packages;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Twig\Environment;
use Twig\Extension\ExtensionInterface as TwigExtensionInterface;
use Twig\Loader\FilesystemLoader;

/**
Expand Down Expand Up @@ -69,13 +68,6 @@ public function addWidget(WidgetInterface $widget): void
}
}

/**
* @deprecated
*/
public function addTwigExtension(TwigExtensionInterface $extension): void
{
}

/**
* Shortcut method to add a namespace to the current Twig Environment.
*/
Expand Down Expand Up @@ -126,29 +118,6 @@ public function addListener($event, $callback): void
$dp->addListener($event, $callback);
}

/**
* @deprecated
*/
public function registerWidget(WidgetInterface $widget): void
{
$this->addWidget($widget);
}

/**
* @deprecated
*/
public function registerTwigExtension(TwigExtensionInterface $extension): void
{
}

/**
* @deprecated
*/
public function registerListener($event, $callback): void
{
$this->addListener($event, $callback);
}

/**
* Get the ComposerPackage, that contains information about the package,
* version, etc.
Expand Down
7 changes: 0 additions & 7 deletions src/Twig/ContentExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,13 +367,6 @@ public function isCurrent(Environment $env, ?Content $content): bool
$recordParams['contentTypeSlug'] === $routeParams['contentTypeSlug'];
}

/**
* @deprecated since Bolt 4.1.11, you no longer need to use `record|allow_twig` *
*/
public function allowTwig(Environment $env, Content $content): void
{
}

/**
* @param Content|Taxonomy $contentOrTaxonomy
*/
Expand Down
38 changes: 0 additions & 38 deletions src/Twig/LocaleExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ public function getFilters(): array
];

return [
new TwigFilter('localedatetime', [$this, 'localedatetime'], $safe),
new TwigFilter('localedate', [$this, 'localedatetime'], $safe),
new TwigFilter('localdate', [$this, 'localdate'], $safe),
];
}
Expand Down Expand Up @@ -126,42 +124,6 @@ public function flag($localeCode): string
);
}

/**
* @deprecated
*
* @param string|\DateTime $dateTime
*/
public function localedatetime($dateTime, string $format = '%B %e, %Y %H:%M', ?string $locale = '0'): string
{
if (! $dateTime instanceof \DateTime) {
$dateTime = new \DateTime((string) $dateTime);
}

// Check for Windows to find and replace the %e modifier correctly
// @see: http://php.net/strftime
$os = mb_strtoupper(mb_substr(PHP_OS, 0, 3));
$format = $os !== 'WIN' ? $format : preg_replace('#(?<!%)((?:%%)*)%e#', '\1%#d', $format);
$timestamp = $dateTime->getTimestamp();

// According to http://php.net/manual/en/function.setlocale.php manual
// if the second parameter is "0", the locale setting is not affected,
// only the current setting is returned.
$result = setlocale(LC_ALL, $locale);

if ($result === false) {
// This shouldn't occur, but.. Dude!
// You ain't even got locale or English on your platform??
// Various things we could do. We could fail miserably, but a more
// graceful approach is to use the datetime to display a default
// format
// $this->systemLogger->error('No valid locale detected. Fallback on DateTime active.', ['event' => 'system']);

return $dateTime->format('Y-m-d H:i:s');
}

return strftime($format, $timestamp);
}

public function localdate($dateTime, ?string $format = null, ?string $locale = null, ?string $timezone = null): string
{
if ($dateTime instanceof \Datetime) {
Expand Down
9 changes: 0 additions & 9 deletions src/Twig/TranslatableExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public function getFunctions(): array
public function getFilters(): array
{
return [
new TwigFilter('translated', [$this, 'findTranslated']),
new TwigFilter('translate', [$this, 'translate']),
];
}
Expand All @@ -38,14 +37,6 @@ public function findTranslations(TranslatableInterface $entity, ?string $locale
return $translations;
}

/**
* @deprecated
*/
public function findtranslated(Field $entity, string $locale): Field
{
return $this->translate($entity, $locale);
}

public function translate(Field $entity, string $locale): Field
{
if ($locale === '') {
Expand Down
4 changes: 2 additions & 2 deletions templates/content/_fields.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
{% set field = record.getField(key) %}
{% if field.isTranslatable %}
{# If the field is translatable, we want the translated value in the current locale #}
{% set field = field|translated(currentlocale) %}
{% set field = field|translate(currentlocale) %}
{% else %}
{# Otherwise, we want the value in the default locale, explicitly in case it is something else #}
{% set field = field|translated(field.defaultLocale) %}
{% set field = field|translate(field.defaultLocale) %}
{% endif %}
{% else %}
{% set field = field_factory(key, fielddefinition) %}
Expand Down
4 changes: 2 additions & 2 deletions templates/helpers/_field_blocks.twig
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@
{# Date / Datetime fields #}
{% if type == "date" %}
<p>
<strong>{{ field|label }}</strong>: {{ field|localedatetime("%A %B %e, %Y") }}
{%- if field.definition.mode == 'datetime' %}, {{ field|localedatetime("%H:%M:%S") }}{% endif %}
<strong>{{ field|label }}</strong>: {{ field|localdate }}
{%- if field.definition.mode == 'datetime' %}, {{ field|localdate("H:i:s") }}{% endif %}
</p>
{% endif %}

Expand Down