Skip to content

Commit 20ad27b

Browse files
committed
initial import
0 parents  commit 20ad27b

16 files changed

+501
-0
lines changed

.github/workflows/linting.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: CI
2+
on:
3+
pull_request: null
4+
push:
5+
branches:
6+
- master
7+
jobs:
8+
tests:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
php: ['7.2','7.3','7.4']
13+
14+
name: Linting - PHP ${{ matrix.php }}
15+
steps:
16+
- uses: actions/checkout@v2
17+
- uses: shivammathur/setup-php@v1
18+
with:
19+
php-version: ${{ matrix.php }}
20+
coverage: none
21+
extensions: intl
22+
- run: composer install --no-progress
23+
- run: composer validate
24+
- run: composer codestyle-check
25+
- run: composer phpstan

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.idea
2+
.disabled
3+
/vendor/
4+
.php_cs.cache
5+
composer.lock

.php_cs.dist

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
<?php
2+
3+
$fileHeaderComment = <<<COMMENT
4+
This file is part of the "Invoice format fixation" plugin for Kimai 2.
5+
All rights reserved by Kevin Papst (www.kevinpapst.de).
6+
7+
For the full copyright and license information, please view the LICENSE
8+
file that was distributed with this source code.
9+
COMMENT;
10+
11+
return PhpCsFixer\Config::create()
12+
->setRiskyAllowed(true)
13+
->setRules([
14+
'encoding' => true,
15+
'full_opening_tag' => true,
16+
'blank_line_after_namespace' => true,
17+
'braces' => true,
18+
'class_definition' => true,
19+
'elseif' => true,
20+
'function_declaration' => true,
21+
'indentation_type' => true,
22+
'line_ending' => true,
23+
'lowercase_constants' => true,
24+
'lowercase_keywords' => true,
25+
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
26+
'header_comment' => ['header' => $fileHeaderComment, 'separate' => 'both'],
27+
'no_php4_constructor' => true,
28+
'ordered_imports' => true,
29+
'no_break_comment' => true,
30+
'no_closing_tag' => true,
31+
'no_spaces_after_function_name' => true,
32+
'no_spaces_inside_parenthesis' => true,
33+
'no_trailing_whitespace' => true,
34+
'no_trailing_whitespace_in_comment' => true,
35+
'single_blank_line_at_eof' => true,
36+
'single_class_element_per_statement' => ['elements' => ['property']],
37+
'single_import_per_statement' => true,
38+
'single_line_after_imports' => true,
39+
'switch_case_semicolon_to_colon' => true,
40+
'switch_case_space' => true,
41+
'array_syntax' => [
42+
'syntax' => 'short'
43+
],
44+
'binary_operator_spaces' => true,
45+
'blank_line_after_opening_tag' => true,
46+
'blank_line_before_statement' => [
47+
'statements' => ['return'],
48+
],
49+
'cast_spaces' => true,
50+
'class_attributes_separation' => ['elements' => ['method']],
51+
'concat_space' => ['spacing' => 'one'],
52+
'declare_equal_normalize' => true,
53+
'function_typehint_space' => true,
54+
'include' => true,
55+
'lowercase_cast' => true,
56+
'lowercase_static_reference' => true,
57+
'magic_constant_casing' => true,
58+
'native_function_casing' => true,
59+
'new_with_braces' => true,
60+
'no_blank_lines_after_class_opening' => true,
61+
'no_blank_lines_after_phpdoc' => true,
62+
'no_empty_comment' => true,
63+
'no_empty_phpdoc' => true,
64+
'no_empty_statement' => true,
65+
'no_extra_blank_lines' => ['tokens' => [
66+
'curly_brace_block',
67+
'extra',
68+
'parenthesis_brace_block',
69+
'square_brace_block',
70+
'throw',
71+
'use',
72+
]],
73+
'no_leading_import_slash' => true,
74+
'no_leading_namespace_whitespace' => true,
75+
'no_mixed_echo_print' => ['use' => 'echo'],
76+
'no_multiline_whitespace_around_double_arrow' => true,
77+
'no_short_bool_cast' => true,
78+
'no_singleline_whitespace_before_semicolons' => true,
79+
'no_spaces_around_offset' => true,
80+
'no_trailing_comma_in_list_call' => true,
81+
'no_trailing_comma_in_singleline_array' => true,
82+
'no_unneeded_curly_braces' => true,
83+
'no_unneeded_final_method' => true,
84+
'no_unused_imports' => true,
85+
'no_whitespace_before_comma_in_array' => true,
86+
'no_whitespace_in_blank_line' => true,
87+
'normalize_index_brace' => true,
88+
'object_operator_without_whitespace' => true,
89+
'php_unit_fqcn_annotation' => true,
90+
'phpdoc_align' => [
91+
'align' => 'left',
92+
'tags' => [
93+
'method',
94+
'param',
95+
'property',
96+
'return',
97+
'throws',
98+
'type',
99+
'var',
100+
],
101+
],
102+
'phpdoc_annotation_without_dot' => true,
103+
'phpdoc_indent' => true,
104+
'phpdoc_inline_tag' => true,
105+
'phpdoc_no_access' => true,
106+
'phpdoc_no_alias_tag' => true,
107+
'phpdoc_no_empty_return' => true,
108+
'phpdoc_no_package' => true,
109+
'phpdoc_no_useless_inheritdoc' => true,
110+
'phpdoc_return_self_reference' => true,
111+
'phpdoc_scalar' => true,
112+
'phpdoc_separation' => false,
113+
'phpdoc_single_line_var_spacing' => true,
114+
'phpdoc_summary' => false,
115+
'phpdoc_to_comment' => true,
116+
'phpdoc_trim' => true,
117+
'phpdoc_types' => true,
118+
'phpdoc_var_without_name' => true,
119+
'protected_to_private' => true,
120+
'return_type_declaration' => true,
121+
'semicolon_after_instruction' => true,
122+
'short_scalar_cast' => true,
123+
'single_blank_line_before_namespace' => true,
124+
'single_line_comment_style' => [
125+
'comment_types' => ['hash'],
126+
],
127+
'single_quote' => true,
128+
'space_after_semicolon' => [
129+
'remove_in_empty_for_expressions' => true,
130+
],
131+
'standardize_increment' => true,
132+
'standardize_not_equals' => true,
133+
'ternary_operator_spaces' => true,
134+
'trailing_comma_in_multiline_array' => false,
135+
'trim_array_spaces' => true,
136+
'unary_operator_spaces' => true,
137+
'whitespace_after_comma_in_array' => true,
138+
'yoda_style' => false,
139+
'ternary_to_null_coalescing' => true,
140+
'visibility_required' => ['elements' => [
141+
'const',
142+
'method',
143+
'property',
144+
]],
145+
])
146+
->setFinder(
147+
PhpCsFixer\Finder::create()
148+
->in([
149+
__DIR__
150+
])->exclude([
151+
__DIR__ . '/Resources/',
152+
__DIR__ . '/vendor/',
153+
])
154+
)
155+
->setFormat('checkstyle')
156+
;

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Changelog
2+
3+
## 0.1
4+
5+
- Initial version
6+
7+
Compatible with Kimai 1.11
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the "Invoice format fixation" plugin for Kimai 2.
5+
* All rights reserved by Kevin Papst (www.kevinpapst.de).
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
11+
namespace KimaiPlugin\InvoiceFormatFixationBundle\DependencyInjection;
12+
13+
use App\Plugin\AbstractPluginExtension;
14+
use Symfony\Component\Config\FileLocator;
15+
use Symfony\Component\DependencyInjection\ContainerBuilder;
16+
use Symfony\Component\DependencyInjection\Loader;
17+
18+
class InvoiceFormatFixationExtension extends AbstractPluginExtension
19+
{
20+
/**
21+
* @param array $configs
22+
* @param ContainerBuilder $container
23+
* @throws \Exception
24+
*/
25+
public function load(array $configs, ContainerBuilder $container)
26+
{
27+
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
28+
$loader->load('services.yaml');
29+
}
30+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the "Invoice format fixation" plugin for Kimai 2.
5+
* All rights reserved by Kevin Papst (www.kevinpapst.de).
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
11+
namespace KimaiPlugin\InvoiceFormatFixationBundle\EventSubscriber;
12+
13+
use App\Configuration\LanguageFormattings;
14+
use App\Configuration\SystemConfiguration;
15+
use App\Event\InvoicePreRenderEvent;
16+
use App\Invoice\DefaultInvoiceFormatter;
17+
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
18+
19+
class InvoicePreRenderSubscriber implements EventSubscriberInterface
20+
{
21+
/**
22+
* @var LanguageFormattings
23+
*/
24+
private $formatter;
25+
/**
26+
* @var SystemConfiguration
27+
*/
28+
private $configuration;
29+
30+
public function __construct(LanguageFormattings $formatter, SystemConfiguration $configuration)
31+
{
32+
$this->formatter = $formatter;
33+
$this->configuration = $configuration;
34+
}
35+
36+
public static function getSubscribedEvents(): array
37+
{
38+
return [
39+
InvoicePreRenderEvent::class => ['configureFormatter', 200],
40+
];
41+
}
42+
43+
public function configureFormatter(InvoicePreRenderEvent $event)
44+
{
45+
$language = $this->configuration->find('invoice.formatter_language');
46+
47+
if (empty($language)) {
48+
return;
49+
}
50+
51+
$formatter = new DefaultInvoiceFormatter($this->formatter, $language);
52+
53+
$event->getModel()->setFormatter($formatter);
54+
}
55+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the "Invoice format fixation" plugin for Kimai 2.
5+
* All rights reserved by Kevin Papst (www.kevinpapst.de).
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
11+
namespace KimaiPlugin\InvoiceFormatFixationBundle\EventSubscriber;
12+
13+
use App\Event\SystemConfigurationEvent;
14+
use App\Form\Model\Configuration;
15+
use App\Form\Model\SystemConfiguration as SystemConfigurationModel;
16+
use App\Form\Type\LanguageType;
17+
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
18+
19+
class SystemConfigurationSubscriber implements EventSubscriberInterface
20+
{
21+
public static function getSubscribedEvents()
22+
{
23+
return [
24+
SystemConfigurationEvent::class => ['onSystemConfiguration', 100],
25+
];
26+
}
27+
28+
public function onSystemConfiguration(SystemConfigurationEvent $event)
29+
{
30+
foreach ($event->getConfigurations() as $configuration) {
31+
if ($configuration->getSection() !== SystemConfigurationModel::SECTION_FORM_INVOICE) {
32+
continue;
33+
}
34+
$configuration->addConfiguration(
35+
(new Configuration())
36+
->setName('invoice.formatter_language')
37+
->setLabel('invoice.formatter_language')
38+
->setTranslationDomain('system-configuration')
39+
->setOptions(['help' => 'help.invoice.formatter_language'])
40+
->setRequired(false)
41+
->setType(LanguageType::class)
42+
);
43+
}
44+
}
45+
}

InvoiceFormatFixationBundle.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the "Invoice format fixation" plugin for Kimai 2.
5+
* All rights reserved by Kevin Papst (www.kevinpapst.de).
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
11+
namespace KimaiPlugin\InvoiceFormatFixationBundle;
12+
13+
use App\Plugin\PluginInterface;
14+
use Symfony\Component\HttpKernel\Bundle\Bundle;
15+
16+
class InvoiceFormatFixationBundle extends Bundle implements PluginInterface
17+
{
18+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) Kevin Papst - https://www.kevinpapst.de
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)