-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into main
- Loading branch information
Showing
35 changed files
with
1,110 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ name: Code Quality | |
|
||
on: | ||
- push | ||
- pull_request | ||
- workflow_dispatch | ||
|
||
jobs: | ||
php-cs-fixer: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ name: Testing | |
|
||
on: | ||
- push | ||
- pull_request | ||
- workflow_dispatch | ||
|
||
jobs: | ||
phpunit: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<script setup> | ||
import ColumnTypeOptions from "./options/column.md"; | ||
</script> | ||
|
||
# EnumColumnType | ||
|
||
The [`EnumColumnType`](https://github.com/Kreyu/data-table-bundle/blob/main/src/Column/Type/EnumColumnType.php) represents a column with [PHP enumeration](https://www.php.net/manual/language.enumerations.php) as value. | ||
|
||
## Overridden options | ||
|
||
### `formatter` | ||
|
||
- **type**: `null` or `callable` | ||
- **default**: callable that translates the enum if possible | ||
|
||
Formats the enum value. If Symfony Translator component is available, and the enum implements [`TranslatableInterface`](https://github.com/symfony/translation-contracts/blob/main/TranslatableInterface.php), | ||
the enum will be translated. Otherwise, the enum name will be displayed. | ||
|
||
## Inherited options | ||
|
||
<ColumnTypeOptions excludedOptions="['formatter']"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Kreyu\Bundle\DataTableBundle\Column\Type; | ||
|
||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
use Symfony\Contracts\Translation\TranslatableInterface; | ||
use Symfony\Contracts\Translation\TranslatorInterface; | ||
|
||
final class EnumColumnType extends AbstractColumnType | ||
{ | ||
public function __construct( | ||
private ?TranslatorInterface $translator, | ||
) { | ||
} | ||
|
||
public function configureOptions(OptionsResolver $resolver): void | ||
{ | ||
$resolver->setDefault('formatter', $this->format(...)); | ||
} | ||
|
||
protected function format(\UnitEnum $enum): string | ||
{ | ||
return $enum instanceof TranslatableInterface ? $enum->trans($this->translator) : $enum->name; | ||
} | ||
|
||
public function getParent(): ?string | ||
{ | ||
return TextColumnType::class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.