moved twig globals to dynamic compiler pass (#264)
This commit is contained in:
26
UPGRADING.md
26
UPGRADING.md
@@ -5,6 +5,32 @@ Database upgrades are currently ONLY provided for MySQL/MariaDB and SQLite.
|
||||
If you plan on using e.g. PostgreSQL, please read more about the `bin/console doctrine:migrations:diff` and
|
||||
`bin/console doctrine:migrations:migrate` commands and contact us, so we can integrate them into the official releases.
|
||||
|
||||
## 0.4 (not yet released)
|
||||
|
||||
In the time between 0.3 and 0.4 there was a release of composer that introduced a BC break,
|
||||
which leads to problems between Composer and Symfony Flex, resulting in an error like this when running it:
|
||||
|
||||
```
|
||||
[ErrorException]
|
||||
Declaration of Symfony\Flex\ParallelDownloader::getRemoteContents($originUrl, $fileUrl, $context) should be compatible with Composer\Util\RemoteFilesystem::getRemoteContents($originUrl, $fileUrl, $context, ?array &$responseHeaders = NULL)
|
||||
```
|
||||
|
||||
This can be fixed by updating composer before the Kimai update and running composer without the flex plugin:
|
||||
```
|
||||
composer self-update
|
||||
sudo -u www-data composer install --no-plugins
|
||||
```
|
||||
|
||||
So the full update goes like that:
|
||||
|
||||
```bash
|
||||
git pull origin master
|
||||
sudo -u www-data composer install --no-dev --optimize-autoloader --no-plugins
|
||||
sudo -u www-data bin/console cache:clear --env=prod
|
||||
sudo -u www-data bin/console cache:warmup --env=prod
|
||||
bin/console doctrine:migrations:migrate
|
||||
```
|
||||
|
||||
## [0.3](https://github.com/kevinpapst/kimai2/releases/tag/0.3) (2018-07-22)
|
||||
|
||||
**Update from 0.2:**
|
||||
|
||||
@@ -68,8 +68,10 @@ kimai:
|
||||
# id: 'de.german#holiday@group.v.calendar.google.com'
|
||||
# color: '#ccc'
|
||||
|
||||
twig:
|
||||
globals:
|
||||
kimai_context:
|
||||
box_color: "green" # a color for: TODO ??? find out ???
|
||||
active_warning: 3 # display a warning color if the user has at least X active recordings
|
||||
# theme related settings, will be available as twig settings
|
||||
theme:
|
||||
# display a warning color if the user has at least X active recordings
|
||||
active_warning: 3
|
||||
# fallback color for all widgets that don't have a dedicated color
|
||||
# possible options: blue, black, purple, yellow, red, green
|
||||
box_color: 'green'
|
||||
|
||||
@@ -36,6 +36,7 @@ class AppExtension extends Extension implements PrependExtensionInterface
|
||||
|
||||
$container->setParameter('kimai.languages', $config['languages']);
|
||||
$container->setParameter('kimai.calendar', $config['calendar']);
|
||||
$container->setParameter('kimai.theme', $config['theme']);
|
||||
|
||||
$this->createUserParameter($config, $container);
|
||||
$this->createTimesheetParameter($config, $container);
|
||||
@@ -98,6 +99,7 @@ class AppExtension extends Extension implements PrependExtensionInterface
|
||||
*/
|
||||
public function prepend(ContainerBuilder $container)
|
||||
{
|
||||
/*
|
||||
$configuration = new Configuration();
|
||||
$configs = $container->getExtensionConfig($this->getAlias());
|
||||
try {
|
||||
@@ -115,6 +117,7 @@ class AppExtension extends Extension implements PrependExtensionInterface
|
||||
],
|
||||
]
|
||||
);
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
33
src/DependencyInjection/Compiler/TwigContextCompilerPass.php
Normal file
33
src/DependencyInjection/Compiler/TwigContextCompilerPass.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Kimai time-tracking app.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace App\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
|
||||
/**
|
||||
* Dynamically adds twig globals.
|
||||
*/
|
||||
class TwigContextCompilerPass implements CompilerPassInterface
|
||||
{
|
||||
/**
|
||||
* @param ContainerBuilder $container
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
$twig = $container->getDefinition('twig');
|
||||
$theme = $container->getParameter('kimai.theme');
|
||||
$durationOnly = $container->getParameter('kimai.timesheet.duration_only');
|
||||
|
||||
$twig->addMethodCall('addGlobal', ['kimai_context', $theme]);
|
||||
$twig->addMethodCall('addGlobal', ['duration_only', $durationOnly]);
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,17 @@ class Configuration implements ConfigurationInterface
|
||||
|
||||
$rootNode
|
||||
->children()
|
||||
->arrayNode('theme')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->integerNode('active_warning')
|
||||
->defaultValue(3)
|
||||
->end()
|
||||
->scalarNode('box_color')
|
||||
->defaultValue('green')
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('user')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace App;
|
||||
|
||||
use App\DependencyInjection\AppExtension;
|
||||
use App\DependencyInjection\Compiler\DoctrineCompilerPass;
|
||||
use App\DependencyInjection\Compiler\TwigContextCompilerPass;
|
||||
use App\Timesheet\CalculatorInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
@@ -66,6 +67,7 @@ class Kernel extends BaseKernel
|
||||
$loader->load($confDir . '/services_' . $this->environment . self::CONFIG_EXTS, 'glob');
|
||||
|
||||
$container->addCompilerPass(new DoctrineCompilerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -1000);
|
||||
$container->addCompilerPass(new TwigContextCompilerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -1000);
|
||||
}
|
||||
|
||||
protected function configureRoutes(RouteCollectionBuilder $routes)
|
||||
|
||||
@@ -21,6 +21,7 @@ For the most part Kimai usage should be self-explanatory, so we will only cover
|
||||
- [FAQ](faq.md) - some answers to frequently asked questions
|
||||
- [Emails](emails.md) - transport configuration and handling of emails
|
||||
- [API](developers_api.md) - how to use the JSON API
|
||||
- [Translations](translations.md) - all about languages and translations
|
||||
|
||||
## Installation
|
||||
|
||||
|
||||
@@ -79,22 +79,9 @@ Be aware that this command will modify all files with violations in the director
|
||||
|
||||
Our code-styles are configured in [.php_cs.dist](../../.php_cs.dist).
|
||||
|
||||
|
||||
## Translations
|
||||
|
||||
We try to keep the number of language files small, in order to make it easier to identify the location of application messages and to unify the codebase.
|
||||
|
||||
- If you add a new key, you have to add it in every language file
|
||||
- Its very likely that you want to edit the file `messages` as it holds 90% of our application translations
|
||||
|
||||
The files in `translations/` as a quick overview:
|
||||
|
||||
- `exceptions` only holds translations of error pages and exception handlers
|
||||
- `flashmessages` hold all success and error messages, that will be shown as results from action calls after page reload
|
||||
- `messages` holds most of the visible application translations (like all the static UI elements and form translations)
|
||||
- `pagerfanta` includes the translations for the pagination component
|
||||
- `sidebar` holds all the translations of the right sidebar
|
||||
- `validators` only hold translations related to violations/validation of submitted form data (or API calls)
|
||||
Read more about [languages and translations](translations.md).
|
||||
|
||||
## Extending the navigation bar
|
||||
|
||||
|
||||
@@ -10,4 +10,4 @@ Internal documentation for project maintainers
|
||||
- Push a release branch and add it as last PR merge into master
|
||||
- Edit the release-draft and add the "Full changelog" link + everything from the "Merged pull requests" section from CHANGELOG.md
|
||||
- Create the release
|
||||
- Post a new issue at [YunoHost tracker for Kimai 2](https://github.com/YunoHost-Apps/kimai2_ynh)
|
||||
- Post a new issue at [YunoHost tracker for Kimai 2](https://github.com/YunoHost-Apps/kimai2_ynh)
|
||||
|
||||
43
var/docs/translations.md
Normal file
43
var/docs/translations.md
Normal file
@@ -0,0 +1,43 @@
|
||||
# Translations
|
||||
|
||||
We try to keep the number of language files small, in order to make it easier to identify the location of application messages and to unify the codebase.
|
||||
|
||||
- If you add a new key, you have to add it in every language file
|
||||
- Its very likely that you want to edit the file `messages` as it holds 90% of our application translations
|
||||
|
||||
The files in `translations/` as a quick overview:
|
||||
|
||||
- `exceptions` only holds translations of error pages and exception handlers
|
||||
- `flashmessages` hold all success and error messages, that will be shown as results from action calls after page reload
|
||||
- `messages` holds most of the visible application translations (like all the static UI elements and form translations)
|
||||
- `pagerfanta` includes the translations for the pagination component
|
||||
- `sidebar` holds all the translations of the right sidebar
|
||||
- `validators` only hold translations related to violations/validation of submitted form data (or API calls)
|
||||
|
||||
## Add a new language
|
||||
|
||||
As example I choose a new hypothetical language with the locale `xx`.
|
||||
|
||||
Copy each translation file from `translations/*.en.xliff` and rename them to `translations/*.xx.xliff`.
|
||||
|
||||
Adjust the `target-language` in the file header, as example for the new file `exceptions.xx.xliff`:
|
||||
```yml
|
||||
<file date="2018-08-01T20:00:00Z" source-language="en" target-language="xx" datatype="plaintext" original="exceptions.en.xliff">`
|
||||
```
|
||||
|
||||
Adjust the file `config/kimai.yaml` and add the language settings below the key `kimai.languages`:
|
||||
```yaml
|
||||
kimai:
|
||||
languages:
|
||||
xx:
|
||||
date_short: 'd.m.Y'
|
||||
```
|
||||
|
||||
Append the new locale in the file `config/services.yaml` at `parameters.app_locales` divided by a pipe:
|
||||
|
||||
```yaml
|
||||
parameters:
|
||||
locale: en
|
||||
app_locales: en|de|ru|it|xx
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user