Skip to content

Commit

Permalink
Fix a warning when serializing metadata (#9)
Browse files Browse the repository at this point in the history
This addresses warnings like...

```
Failed to save key "{key}" of type Webfactory\Bundle\PolyglotBundle\Doctrine\TranslatableClassMetadata: Cache key "..." has non-serializable Webfactory\Bundle\PolyglotBundle\Doctrine\TranslatableClassMetadata value.
```

... that occur when the Cache Driver used (in Doctrine) is the file-based implementation from symfony/cache.
  • Loading branch information
mpdude authored Dec 22, 2020
1 parent 814a923 commit d4183d8
Show file tree
Hide file tree
Showing 32 changed files with 346 additions and 281 deletions.
3 changes: 0 additions & 3 deletions .coveralls.yml

This file was deleted.

36 changes: 36 additions & 0 deletions .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Dependencies

on:
push:
branches:
- master
pull_request:

env:
PHP_VERSION: 7.2

jobs:
composer-require-checker:
name: Check missing composer requirements
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Konfiguriere PHP-Version und -Einstellungen im Worker-Node
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
tools: composer:v2
ini-values: variables_order=EGPCS
- name: Cache Composer Dependencies
uses: actions/cache@v1
with:
path: vendor/
key: composer-${{ env.PHP_VERSION }}-${{ hashFiles('composer.*') }}
restore-keys: |
composer-${{ env.PHP_VERSION }}-${{ github.ref }}
composer-${{ env.PHP_VERSION }}-
- run: |
composer install --no-interaction --no-scripts --no-progress --no-suggest
composer show
- name: ComposerRequireChecker
uses: docker://webfactory/composer-require-checker:2.1.0
50 changes: 50 additions & 0 deletions .github/workflows/fix-cs-php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Update this by running
# curl https://gist.githubusercontent.com/mpdude/ca93a185bcbf56eb7e341632ad4f8263/raw/fix-cs-php.yml > .github/workflows/fix-cs-php.yml

on:
push:
branches:
- master
pull_request:

name: Coding Standards

jobs:
open-pr-for-cs-violations:
name: PHP-CS-Fixer
runs-on: ubuntu-18.04
steps:

- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}

- name: Run PHP-CS-Fixer
uses: docker://oskarstark/php-cs-fixer-ga:2.16.7

- name: Create PR for CS fixups
uses: peter-evans/create-pull-request@c7f493a8000b8aeb17a1332e326ba76b57cb83eb
id: create-pull-request
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: Fix coding standards in ${{ github.ref }}
branch: php-cs-fixer/${{ github.ref }}
assignees: ${{ github.actor }}
labels: php-cs-fixer
body: Please merge these changes into the ${{ github.ref }} branch to fix coding standard violations.
commit-message: Apply php-cs-fixer changes as of ${{ github.sha }}

- name: Leave a notice in the discussion when fixing code in a Pull Request
uses: docker://mpdude/comment-on-pr:v1.2.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: steps.create-pull-request.outputs.pr_number # only if PR was created in the previous step
continue-on-error: true # continue on failure - necessary when the current branch does not have a pending PR
with:
msg: |
@${{ github.actor }} please apply the coding standard fixes from #${{ steps.create-pull-request.outputs.pr_number }}
- name: Fail the workflow when necessary CS fixes were detected
run: echo "Failing workflow run because CS violations were detected." && exit 1
if: steps.create-pull-request.outputs.pr_number
35 changes: 35 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Tests

on:
push:
branches:
- master
pull_request:

env:
PHP_VERSION: 7.2

jobs:
PHPUnit:
name: PHPUnit
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Konfiguriere PHP-Version und -Einstellungen im Worker-Node
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
tools: composer:v2
ini-values: variables_order=EGPCS
- name: Cache Composer Dependencies
uses: actions/cache@v1
with:
path: vendor/
key: composer-${{ env.PHP_VERSION }}-${{ hashFiles('composer.*') }}
restore-keys: |
composer-${{ env.PHP_VERSION }}-${{ github.ref }}
composer-${{ env.PHP_VERSION }}-
- run: |
composer install --no-interaction --no-scripts --no-progress --no-suggest
composer show
- run: vendor/bin/phpunit
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
vendor/
.idea/
composer.lock
phpunit.xml$
.php_cs.cache
19 changes: 19 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

return PhpCsFixer\Config::create()
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'array_syntax' => array('syntax' => 'short'),
'no_unreachable_default_argument_value' => false,
'braces' => array('allow_single_line_closure' => true),
'heredoc_to_nowdoc' => false,
'phpdoc_annotation_without_dot' => false,
])
->setRiskyAllowed(true)
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__)
->notPath('vendor/')
)
;
17 changes: 0 additions & 17 deletions .scrutinizer.yml

This file was deleted.

30 changes: 0 additions & 30 deletions .travis.yml

This file was deleted.

7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# ![webfactory Logo](https://www.webfactory.de/bundles/webfactorytwiglayout/img/logo.png) WebfactoryPolyglotBundle

[![Build Status](https://scrutinizer-ci.com/g/webfactory/WebfactoryPolyglotBundle/badges/build.png?b=master)](https://scrutinizer-ci.com/g/webfactory/WebfactoryPolyglotBundle/build-status/master)
[![Code Coverage](https://scrutinizer-ci.com/g/webfactory/WebfactoryPolyglotBundle/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/webfactory/WebfactoryPolyglotBundle/?branch=master)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/webfactory/WebfactoryPolyglotBundle/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/webfactory/WebfactoryPolyglotBundle/?branch=master)
![Tests](https://github.com/webfactory/WebfactoryPolyglotBundle/workflows/Tests/badge.svg)
![Dependencies](https://github.com/webfactory/WebfactoryPolyglotBundle/workflows/Dependencies/badge.svg)

A bundle to simplify translations for Doctrine entities.

Expand Down Expand Up @@ -263,7 +262,7 @@ this information in an attribute. This would allow each record to have its own p

## Credits, Copyright and License

Copyright 2012-2017 webfactory GmbH, Bonn. Code released under [the MIT license](LICENSE).
This Bundle was written by webfactory GmbH, Bonn, Germany. We're a software development agency with a focus on PHP (mostly [Symfony](http://github.com/symfony/symfony)). If you're a developer looking for new challenges, we'd like to hear from you!

- <https://www.webfactory.de>
- <https://twitter.com/webfactory>
17 changes: 12 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@
],

"autoload": {
"psr-0": { "Webfactory\\Bundle\\PolyglotBundle": "src" }
"psr-4": { "Webfactory\\Bundle\\PolyglotBundle\\": "src" }
},
"autoload-dev": {
"psr-4": { "Webfactory\\Bundle\\PolyglotBundle\\Tests\\": "tests" }
},

"require": {
"php": "^7.2",
"doctrine/annotations": "^1.11",
"doctrine/collections": "^1.0",
"doctrine/persistence": "^1.3.8",
"doctrine/orm": "~2.2",
"php": "^5.5|^7.0",
"psr/log": "^1.0",
"symfony/config": "^2.0|^3.0|^4.0",
"symfony/dependency-injection": "^2.0|^3.0|^4.0",
"symfony/event-dispatcher": "^2.0|^3.0|^4.0",
Expand All @@ -27,9 +34,9 @@

"require-dev": {
"phpunit/phpunit": "^5.7",
"symfony/debug": "^2.8|^3.0|^4.0",
"symfony/phpunit-bridge": "dev-master",
"webfactory/doctrine-orm-test-infrastructure": "~1.0"
"symfony/error-handler": "^4.4",
"symfony/phpunit-bridge": "*",
"webfactory/doctrine-orm-test-infrastructure": "^1.9"
},

"config": {
Expand Down
11 changes: 4 additions & 7 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/3.7/phpunit.xsd"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.7/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true">

<testsuites>
<testsuite name="Bundle Test Suite">
<directory>src/Webfactory/Bundle/PolyglotBundle/Tests</directory>
<directory>tests</directory>
</testsuite>
</testsuites>

<!-- Filter for code coverage -->
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src/</directory>
<directory suffix=".php">src</directory>
<exclude>
<directory>src/*/*Bundle/Resources</directory>
<directory>src/*/*Bundle/Tests</directory>
<directory>src/*/Bundle/*Bundle/Resources</directory>
<directory>src/*/Bundle/*Bundle/Tests</directory>
<directory>src/Resources</directory>
</exclude>
</whitelist>
</filter>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@

namespace Webfactory\Bundle\PolyglotBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

class WebfactoryPolyglotExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container)
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.xml');

$m = array("defaultLocale" => "de_DE");
$m = ['defaultLocale' => 'de_DE'];
foreach ($configs as $c) {
$m = array_merge($m, $c);
}
Expand Down
Loading

0 comments on commit d4183d8

Please sign in to comment.