Skip to content

Commit

Permalink
Support 7 (#450)
Browse files Browse the repository at this point in the history
* Add sf 7 to composer.json

* Added missing dependencies

* Added dependency on Symfony validator

* Fix frontend (bug probably also exists in the 6 branch)

* Fix also the error conditions in the UI

* Restrict composer.json to SF 7. The 6 branch is for SF 6, let's keep them separate

* Restrict composer.json to SF 7. The 6 branch is for SF 6, let's keep them separate

* Update minimum php version

* Update github action to use php 8.2

* Remove propel support and fix unit tests (differences in loading files with odm definitions)

* Update the version of github actions to v4

* Remove * from composer.json
  • Loading branch information
bartmcleod authored Feb 17, 2024
1 parent 6bd4e3d commit 7c8531f
Show file tree
Hide file tree
Showing 39 changed files with 115 additions and 1,759 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Run tests


on:
push:
branches: [ "master" ]
Expand All @@ -9,6 +10,7 @@ on:
permissions:
contents: read


jobs:
build:

Expand All @@ -32,14 +34,20 @@ jobs:
MONGO_INITDB_ROOT_PASSWORD: secret

steps:
- uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: mbstring, intl

- uses: actions/checkout@v4

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
vendor
composer.lock
Propel/map
Propel/om

Tests/app/tmp/
1 change: 0 additions & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public function getConfigTreeBuilder(): TreeBuilder
$storages = [
StorageInterface::STORAGE_ORM,
StorageInterface::STORAGE_MONGODB,
StorageInterface::STORAGE_PROPEL,
];
$registrationTypes = ['all', 'files', 'database'];
$inputTypes = ['text', 'textarea'];
Expand Down
3 changes: 0 additions & 3 deletions DependencyInjection/LexikTranslationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,6 @@ protected function buildTranslationStorageDefinition(ContainerBuilder $container
$args = [new Reference('doctrine_mongodb'), $objectManager ?? 'default'];

$this->createDoctrineMappingDriver($container, 'lexik_translation.mongodb.metadata.xml', '%doctrine_mongodb.odm.metadata.xml.class%');
} elseif (StorageInterface::STORAGE_PROPEL == $storage) {
// In the Propel case the object_manager setting is used for the connection name
$args = [$objectManager];
} else {
throw new \RuntimeException(sprintf('Unsupported storage "%s".', $storage));
}
Expand Down
6 changes: 0 additions & 6 deletions Form/Handler/TransUnitFormHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Lexik\Bundle\TranslationBundle\Manager\FileInterface;
use Lexik\Bundle\TranslationBundle\Manager\FileManagerInterface;
use Lexik\Bundle\TranslationBundle\Storage\StorageInterface;
use Lexik\Bundle\TranslationBundle\Propel\TransUnit as PropelTransUnit;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;

Expand Down Expand Up @@ -76,11 +75,6 @@ public function process(FormInterface $form, Request $request)
}
}

if ($transUnit instanceof PropelTransUnit) {
// The setTranslations() method only accepts PropelCollections
$translations = new \PropelObjectCollection($translations);
}

$transUnit->setTranslations($translations);

$this->storage->persist($transUnit);
Expand Down
138 changes: 26 additions & 112 deletions Model/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace Lexik\Bundle\TranslationBundle\Model;


use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Validator\Constraints as Assert;

/**
Expand All @@ -12,155 +14,90 @@
*/
abstract class File
{
/**
* @var int
*/
protected $id;

/**
* @var string
*
* @Assert\NotBlank()
*/
protected $domain;
protected string $domain;

/**
* @var string
*
* @Assert\NotBlank()
*/
protected $locale;
protected string $locale;

/**
* @var string
*
* @Assert\NotBlank()
*/
protected $extention;
protected string $extention;

/**
* @var string
*
* @Assert\NotBlank()
*/
protected $path;
protected string $path;

/**
* @var string
*
* @Assert\NotBlank()
*/
protected $hash;
protected string $hash;

/**
* @var Doctrine\Common\Collections\Collection
*/
protected $translations;
protected Collection $translations;

protected $createdAt;

protected $updatedAt;

/**
* Construct.
*/
public function __construct()
{
$this->translations = new ArrayCollection();
}

/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}

/**
* Set domain
*
* @param string $domain
*/
public function setDomain($domain)
public function setDomain(string $domain): void
{
$this->domain = $domain;
}

/**
* Get domain
*
* @return string
*/
public function getDomain()
public function getDomain(): string
{
return $this->domain;
}

/**
* Set locale
*
* @param string $locale
*/
public function setLocale($locale)
public function setLocale(string $locale): void
{
$this->locale = $locale;
}

/**
* Get locale
*
* @return string
*/
public function getLocale()
public function getLocale(): string
{
return $this->locale;
}

/**
* Set extention
*
* @param string $extention
*/
public function setExtention($extention)
public function setExtention(string $extention): void
{
$this->extention = $extention;
}

/**
* Get extention
*
* @return string
*/
public function getExtention()
public function getExtention(): string
{
return $this->extention;
}

/**
* Set path
*
* @param string $path
*/
public function setPath($path)
public function setPath(string $path): void
{
$this->path = $path;
}

/**
* Get path
*
* @return string
*/
public function getPath()
public function getPath(): string
{
return $this->path;
}

/**
* Set file name
*
* @param string $name
*/
public function setName($name)
public function setName(string $name): void
{
[$domain, $locale, $extention] = explode('.', $name);

Expand All @@ -169,52 +106,29 @@ public function setName($name)
$this->extention = $extention;
}

/**
* Get file name
*
* @return string
*/
public function getName()
public function getName(): string
{
return sprintf('%s.%s.%s', $this->domain, $this->locale, $this->extention);
}

/**
* Set hash
*
* @return string
*/
public function setHash($hash)
public function setHash(string $hash): void
{
$this->hash = $hash;
}

/**
* Get hash
*
* @return string
*/
public function getHash()
public function getHash(): string
{
return $this->hash;
}

/**
* Add translation
*/
public function addTranslation(\Lexik\Bundle\TranslationBundle\Model\Translation $translation)
public function addTranslation(Translation $translation): void
{
$translation->setFile($this);

$this->translations[] = $translation;
}

/**
* Get translations
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getTranslations()
public function getTranslations(): Collection
{
return $this->translations;
}
Expand Down
37 changes: 0 additions & 37 deletions Propel/File.php

This file was deleted.

9 changes: 0 additions & 9 deletions Propel/FileQuery.php

This file was deleted.

Loading

0 comments on commit 7c8531f

Please sign in to comment.