-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1 MemberView extended. Boolean attributes rendered
- Loading branch information
Showing
8 changed files
with
180 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace DMKClub\Bundle\BasicsBundle; | ||
|
||
use Symfony\Component\HttpKernel\Bundle\Bundle; | ||
|
||
class DMKClubBasicsBundle extends Bundle | ||
{ | ||
} |
29 changes: 29 additions & 0 deletions
29
src/DMKClub/Bundle/BasicsBundle/DependencyInjection/Configuration.php
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,29 @@ | ||
<?php | ||
|
||
namespace DMKClub\Bundle\BasicsBundle\DependencyInjection; | ||
|
||
use Symfony\Component\Config\Definition\Builder\TreeBuilder; | ||
use Symfony\Component\Config\Definition\ConfigurationInterface; | ||
|
||
/** | ||
* This is the class that validates and merges configuration from your app/config files | ||
* | ||
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class} | ||
*/ | ||
class Configuration implements ConfigurationInterface | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getConfigTreeBuilder() | ||
{ | ||
$treeBuilder = new TreeBuilder(); | ||
$rootNode = $treeBuilder->root('dmk_club_basics'); | ||
|
||
// Here you should define the parameters that are allowed to | ||
// configure your bundle. See the documentation linked above for | ||
// more information on that topic. | ||
|
||
return $treeBuilder; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/DMKClub/Bundle/BasicsBundle/DependencyInjection/DMKClubBasicsExtension.php
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,29 @@ | ||
<?php | ||
|
||
namespace DMKClub\Bundle\BasicsBundle\DependencyInjection; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\Config\FileLocator; | ||
use Symfony\Component\HttpKernel\DependencyInjection\Extension; | ||
use Symfony\Component\DependencyInjection\Loader; | ||
|
||
/** | ||
* This is the class that loads and manages your bundle configuration | ||
* | ||
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} | ||
*/ | ||
class DMKClubBasicsExtension extends Extension | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function load(array $configs, ContainerBuilder $container) | ||
{ | ||
$configuration = new Configuration(); | ||
$config = $this->processConfiguration($configuration, $configs); | ||
|
||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); | ||
// $loader->load('services.yml'); | ||
// $loader->load('form.yml'); | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
src/DMKClub/Bundle/BasicsBundle/Resources/config/oro/bundles.yml
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,2 @@ | ||
bundles: | ||
- { name: DMKClub\Bundle\BasicsBundle\DMKClubBasicsBundle, priority: 160 } |
2 changes: 2 additions & 0 deletions
2
src/DMKClub/Bundle/BasicsBundle/Resources/translations/messages.de.yml
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,2 @@ | ||
dmkclub.basics.label.yes: Ja | ||
dmkclub.basics.label.no: Nein |
2 changes: 2 additions & 0 deletions
2
src/DMKClub/Bundle/BasicsBundle/Resources/translations/messages.en.yml
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,2 @@ | ||
dmkclub.basics.label.yes: Yes | ||
dmkclub.basics.label.no: No |
103 changes: 103 additions & 0 deletions
103
src/DMKClub/Bundle/BasicsBundle/Resources/views/macros.html.twig
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,103 @@ | ||
|
||
{# | ||
Alias für attibuteRow (fehlendes "r") | ||
#} | ||
{% macro attributeRow(title, value, additionalData) %} | ||
{% import 'OroUIBundle::macros.html.twig' as UI %} | ||
{{ UI.attibuteRow(title, value, additionalData) }} | ||
{% endmacro %} | ||
|
||
{# | ||
Render row with boolean attribute | ||
#} | ||
{% macro attributeRowBoolean(title, value, additionalData) %} | ||
{% macro value_bool(value) %} | ||
{% if value %} | ||
<i class="icon-ok">{{ 'dmkclub.basics.label.yes'|trans }}</i> | ||
{% else %} | ||
<i class="icon-ban-circle">{{ 'dmkclub.basics.label.no'|trans }}</i> | ||
{% endif %} | ||
{% endmacro %} | ||
|
||
{% import 'OroUIBundle::macros.html.twig' as UI %} | ||
{{ UI.attibuteRow(title, _self.value_bool(value), additionalData) }} | ||
{% endmacro %} | ||
|
||
{# | ||
Render property with boolean attribute | ||
#} | ||
{% macro renderPropertyBoolean(title, value) %} | ||
{% macro value_bool(value) %} | ||
{% if value %} | ||
<i class="icon-ok"> {{ 'dmkclub.basics.label.yes'|trans }}</i> | ||
{% else %} | ||
<i class="icon-ban-circle"> {{ 'dmkclub.basics.label.no'|trans }}</i> | ||
{% endif %} | ||
{% endmacro %} | ||
|
||
{% import 'OroUIBundle::macros.html.twig' as UI %} | ||
{{ UI.renderHtmlProperty(title, _self.value_bool(value)|raw) }} | ||
{% endmacro %} | ||
|
||
|
||
{% macro attributeInEuro(title, value, additionalData) %} | ||
{% import 'OroUIBundle::macros.html.twig' as UI %} | ||
{{ UI.attibuteRow(title, [value|number_format(2, ',', '.')]|merge([' €'])|join, additionalData) }} | ||
{% endmacro %} | ||
|
||
{% macro attributeInPercent(title, value, additionalData) %} | ||
{% import 'OroUIBundle::macros.html.twig' as UI %} | ||
{{ UI.attibuteRow(title, [value|number_format(4, ',', '.')]|merge([' %'])|join, additionalData) }} | ||
{% endmacro %} | ||
|
||
{% macro attributeInDays(title, value, additionalData) %} | ||
{% import 'OroUIBundle::macros.html.twig' as UI %} | ||
{{ UI.attibuteRow(title, [value|number_format(0, ',', '.')]|merge(['Days'|trans])|join(' '), additionalData) }} | ||
{% endmacro %} | ||
|
||
{% macro attributeWithText(title, value, text, additionalData) %} | ||
{% import 'OroUIBundle::macros.html.twig' as UI %} | ||
{{ UI.attibuteRow(title, [value]|merge([text])|join(' '), additionalData) }} | ||
{% endmacro %} | ||
|
||
{# | ||
Zahlen werden absolut angezeigt | ||
negative Werte werden rot positive grün dargestellt, Rest inherited | ||
#} | ||
{% macro coloredNumber(number) %} | ||
{% set classNumber = number < 0 | ||
? 'text-error' | ||
: number > 0 | ||
? 'text-success' | ||
: '' | ||
%} | ||
|
||
<span class="{{ classNumber }}"> | ||
{{ number|abs }} | ||
</span> | ||
{% endmacro %} | ||
|
||
{# | ||
Renders a given file size value in Byte to a human readable format | ||
#} | ||
{% macro bytesToSize(bytes) %} | ||
{% spaceless %} | ||
{% set kilobyte = 1024 %} | ||
{% set megabyte = kilobyte * 1024 %} | ||
{% set gigabyte = megabyte * 1024 %} | ||
{% set terabyte = gigabyte * 1024 %} | ||
|
||
{% if bytes < kilobyte %} | ||
{{ bytes ~ ' B' }} | ||
{% elseif bytes < megabyte %} | ||
{{ (bytes / kilobyte)|number_format(2, '.') ~ ' KB' }} | ||
{% elseif bytes < gigabyte %} | ||
{{ (bytes / megabyte)|number_format(2, '.') ~ ' MB' }} | ||
{% elseif bytes < terabyte %} | ||
{{ (bytes / gigabyte)|number_format(2, '.') ~ ' GB' }} | ||
{% else %} | ||
{{ (bytes / terabyte)|number_format(2, '.') ~ ' TB' }} | ||
{% endif %} | ||
{% endspaceless %} | ||
{% endmacro %} | ||
|
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