Skip to content

Commit

Permalink
Remove propel support and fix unit tests (differences in loading file…
Browse files Browse the repository at this point in the history
…s with odm definitions)
  • Loading branch information
bartmcleod committed Feb 17, 2024
1 parent 382aadb commit 372cca5
Show file tree
Hide file tree
Showing 37 changed files with 58 additions and 1,730 deletions.
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.

44 changes: 0 additions & 44 deletions Propel/FileRepository.php

This file was deleted.

Loading

0 comments on commit 372cca5

Please sign in to comment.