Skip to content
Closed
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@ Changelog

## 6.0.0 (unreleased)

Make sure to check the [upgrade notes](https://github.com/bolt/core/blob/main/UPGRADING.md) for instructions when upgrading your installation!

- `master` branch has been renamed to the now more common `main`.

### ⚙️ Dependency updates

- Bump `nesbot/carbon` from version 2 to version 3.8+. (macintoshplus, [#3551](https://github.com/bolt/core/issues/3551))
- Replaced `tightenco/collect` with `illuminate/collections`. The namespace has changed from `Tightenco\Collect\Support\*` to `Illuminate\Support\*`. (macintoshplus, [#3555](https://github.com/bolt/core/issues/3555))
- The `knplabs/doctrine-behaviors` package has been removed from the Bolt core, but its functionality has been integrated. (macintoshplus, [#3561](https://github.com/bolt/core/issues/3561))

## 5.2.2

Expand Down
32 changes: 32 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# From Bolt 5.2 to 6.0

## Replaced `tightenco/collect` with `illuminate/collections`

If you were using classes from `Tightenco\Collect\Support`, you should replace them with `Illuminate\Support\` or install the deprecated `tightenco/collect` library yourself.

## Dropped `knplabs/doctrine-behaviors` dependency

The `knplabs/doctrine-behaviors` package has been removed from the Bolt core, but the translation behavior that was used by Bolt core has been integrated.

The following classes have replaced:

| Old class | New class |
|----------------------------------------------------------------------|------------------------------------------------------|
| Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface | Bolt\Entity\TranslatableInterface |
| Knp\DoctrineBehaviors\Contract\Entity\TranslationInterface | Bolt\Entity\TranslationInterface |
| Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait | Use two trait below |
| Knp\DoctrineBehaviors\Model\Translatable\TranslatableMethodsTrait | Bolt\Entity\Translatable\TranslatableMethodsTrait |
| Knp\DoctrineBehaviors\Model\Translatable\TranslatablePropertiesTrait | Bolt\Entity\Translatable\TranslatablePropertiesTrait |
| Knp\DoctrineBehaviors\Model\Translatable\TranslationTrait | Use two trait below |
| Knp\DoctrineBehaviors\Model\Translatable\TranslationMethodsTrait | Bolt\Entity\Translatable\TranslationMethodsTrait |
| Knp\DoctrineBehaviors\Model\Translatable\TranslationPropertiesTrait | Bolt\Entity\Translatable\TranslationPropertiesTrait |
| Knp\DoctrineBehaviors\EventSubscriber\TranslatableEventSubscriber | Bolt\Event\Listener\TranslatableListener |
| Knp\DoctrineBehaviors\Exception\TranslatableException | Bolt\Exception\TranslatableException |
| Knp\DoctrineBehaviors\Provider\LocaleProvider | Bolt\Locale\LocaleProvider |
| Knp\DoctrineBehaviors\Contract\Provider\LocaleProviderInterface | Bolt\Locale\LocaleProviderInterface |

Check if this line has been removed from your `config/bundles.php` file:

```php
Knp\DoctrineBehaviors\DoctrineBehaviorsBundle::class => ['all' => true],
```
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"fakerphp/faker": "^1.16",
"illuminate/collections": "^10.48",
"jasny/twig-extensions": "^1.3",
"knplabs/doctrine-behaviors": "^2.1",
"knplabs/knp-menu-bundle": "^3.1",
"league/glide-symfony": "^2.0",
"miljar/php-exif": "^0.6.4",
Expand Down
1 change: 0 additions & 1 deletion config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
Http\HttplugBundle\HttplugBundle::class => ['dev' => true, 'local' => true],
Knp\Bundle\MenuBundle\KnpMenuBundle::class => ['all' => true],
Knp\DoctrineBehaviors\DoctrineBehaviorsBundle::class => ['all' => true],
Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true],
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
Symfony\Bundle\DebugBundle\DebugBundle::class => ['all' => true],
Expand Down
11 changes: 11 additions & 0 deletions config/services.yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes to the services.yaml will need to have a yaml migration defined as well.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ parameters:
# foo_manager: foo_
bolt.backend_url: /bolt
bolt.remember_lifetime: 2592000 # 30 days in seconds
bolt.doctrine_behaviors_translatable_fetch_mode: LAZY
bolt.doctrine_behaviors_translation_fetch_mode: LAZY

services:
# default configuration for services in *this* file
Expand Down Expand Up @@ -78,6 +80,15 @@ services:
Bolt\Event\Listener\UserAvatarLoadListener:
tags:
- { name: doctrine.event_listener, event: postLoad }

Bolt\Event\Listener\TranslatableListener:
arguments:
$translatableFetchMode: '%bolt.doctrine_behaviors_translatable_fetch_mode%'
$translationFetchMode: '%bolt.doctrine_behaviors_translation_fetch_mode%'
tags:
- { name: doctrine.event_listener, event: loadClassMetadata }
- { name: doctrine.event_listener, event: postLoad }
- { name: doctrine.event_listener, event: prePersist }

Bolt\Extension\RoutesLoader:
tags: [routing.loader]
Expand Down
5 changes: 0 additions & 5 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ parameters:
message: '#Unreachable statement - code above always terminates#'
path: %currentWorkingDirectory%/src/*

# false positive: `TranslationInterface does not know about FieldTranslation::getValue().` Skip this error.
-
message: '#Call to an undefined method Knp\\DoctrineBehaviors\\Contract\\Entity\\TranslationInterface#'
path: %currentWorkingDirectory%/src/*

# false positive: Parameters in Storage\Directive\OrderDirective::orderByNumericField() aren't seen as integers
-
message: '#of method Doctrine\\ORM\\Query\\Expr::substring\(\) expects int#'
Expand Down
34 changes: 27 additions & 7 deletions src/DataFixtures/ContentFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@ class ContentFixtures extends BaseFixture implements DependentFixtureInterface,
/** @var ContentExtension */
private $contentExtension;

public function __construct(Config $config, FileLocations $fileLocations, TagAwareCacheInterface $cache, string $defaultLocale, ContentExtension $contentExtension)
{
public function __construct(
Config $config,
FileLocations $fileLocations,
TagAwareCacheInterface $cache,
string $defaultLocale,
ContentExtension $contentExtension
) {
$this->config = $config;
$this->faker = Factory::create();
$seed = $this->config->get('general/fixtures_seed');
Expand Down Expand Up @@ -180,8 +185,13 @@ private function loadContent(ObjectManager $manager): void
}
}

private function loadCollectionField(Content $content, Field $field, $fieldType, ContentType $contentType, array $preset): Field
{
private function loadCollectionField(
Content $content,
Field $field,
$fieldType,
ContentType $contentType,
array $preset
): Field {
$collectionItems = $field->getDefinition()->get('fields');

$i = 0;
Expand Down Expand Up @@ -211,8 +221,14 @@ private function loadSetField(Content $content, Field $set, ContentType $content
return $set;
}

private function loadField(Content $content, string $name, $fieldType, ContentType $contentType, array $preset, bool $addToContent = true): Field
{
private function loadField(
Content $content,
string $name,
$fieldType,
ContentType $contentType,
array $preset,
bool $addToContent = true
): Field {
$sortorder = 1;

$field = FieldRepository::factory($fieldType, $name);
Expand Down Expand Up @@ -242,7 +258,11 @@ private function loadField(Content $content, string $name, $fieldType, ContentTy
$locales = $contentType['locales']->toArray();
foreach ($locales as $locale) {
if ($locale !== $this->defaultLocale && array_search($locale, $locales, true) !== count($locales) - 1) {
$value = $preset[$name] ?? $this->getValuesforFieldType($fieldType, $contentType['singleton'], $content);
$value = $preset[$name] ?? $this->getValuesforFieldType(
$fieldType,
$contentType['singleton'],
$content
);
$field->translate($locale, false)->setValue($value);
}
}
Expand Down
9 changes: 6 additions & 3 deletions src/Entity/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use Bolt\Common\Arr;
use Bolt\Configuration\Content\FieldType;
use Bolt\Entity\Translatable\TranslatableMethodsTrait;
use Bolt\Entity\Translatable\TranslatablePropertiesTrait;
use Bolt\Event\Listener\FieldFillListener;
use Bolt\Utils\Sanitiser;
use Doctrine\ORM\Mapping as ORM;
use Illuminate\Support\Collection;
use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\SerializedName;
use Twig\Environment;
Expand Down Expand Up @@ -53,10 +53,13 @@
* @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(name="type", type="string", length=191)
* @ORM\DiscriminatorMap({"generic" = "Field"})
*
* @method FieldTranslation translate(?string $locale = null, bool $fallbackToDefault = true)
*/
class Field implements FieldInterface, TranslatableInterface
{
use TranslatableTrait;
use TranslatablePropertiesTrait;
use TranslatableMethodsTrait;

public const TYPE = 'generic';

Expand Down
8 changes: 5 additions & 3 deletions src/Entity/FieldTranslation.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@

namespace Bolt\Entity;

use Bolt\Entity\Translatable\TranslationMethodsTrait;
use Bolt\Entity\Translatable\TranslationPropertiesTrait;
use Doctrine\ORM\Mapping as ORM;
use Knp\DoctrineBehaviors\Model\Translatable\TranslationTrait;

/**
* @ORM\Entity
*/
class FieldTranslation implements TranslationInterface
{
use TranslationTrait;
use TranslationPropertiesTrait;
use TranslationMethodsTrait;

/**
* @ORM\Id()
Expand Down Expand Up @@ -59,6 +61,6 @@ public function set(string $key, $value): self
*/
public static function getTranslatableEntityClass(): string
{
return 'Field';
return Field::class;
}
}
Loading