From c0b23d17a71447b4ad6be75ca17d8efd00ff953c Mon Sep 17 00:00:00 2001 From: Florian Eckerstorfer <florian@theroadtojoy.at> Date: Sun, 29 Sep 2013 21:23:51 +0200 Subject: [PATCH] Updated PHPDocs --- DependencyInjection/BcBootstrapExtension.php | 2 + Form/Extension/TypeSetterExtension.php | 22 +++++++++ Form/Type/BootstrapCollectionType.php | 39 +++++++++++----- Form/Type/MoneyType.php | 47 ++++++++++++++++---- LICENSE | 2 +- Twig/BootstrapFormExtension.php | 23 +++++++++- Twig/BootstrapIconExtension.php | 3 +- composer.json | 3 +- 8 files changed, 114 insertions(+), 27 deletions(-) diff --git a/DependencyInjection/BcBootstrapExtension.php b/DependencyInjection/BcBootstrapExtension.php index 85b151b..602e48b 100644 --- a/DependencyInjection/BcBootstrapExtension.php +++ b/DependencyInjection/BcBootstrapExtension.php @@ -184,6 +184,7 @@ class BcBootstrapExtension extends Extension implements PrependExtensionInterfac private function buildAsseticConfig(array $config) { $output = array(); + if ($config['less_filter'] !== 'none') { $output['bootstrap_css'] = $this->buildAsseticBootstrapCssWithLessConfig($config); } else { @@ -191,6 +192,7 @@ class BcBootstrapExtension extends Extension implements PrependExtensionInterfac } $output['bootstrap_js'] = $this->buildAsseticBootstrapJsConfig($config); $output['jquery'] = $this->buildAsseticJqueryConfig($config); + return $output; } diff --git a/Form/Extension/TypeSetterExtension.php b/Form/Extension/TypeSetterExtension.php index 0901ce4..7c5f5b1 100644 --- a/Form/Extension/TypeSetterExtension.php +++ b/Form/Extension/TypeSetterExtension.php @@ -1,4 +1,8 @@ <?php +/** + * This file is part of BcBootstrapBundle. + * (c) 2012-2013 by Florian Eckerstorfer + */ namespace Bc\Bundle\BootstrapBundle\Form\Extension; @@ -6,13 +10,31 @@ use Symfony\Component\Form\AbstractTypeExtension; use Symfony\Component\Form\FormView; use Symfony\Component\Form\FormInterface; +/** + * TypeSetterExtension + * + * @package BcBootstrapBundle + * @subpackage Form + * @author Florian Eckerstorfer <florian@eckerstorfer.co> + * @copyright 2012-2013 Florian Eckerstorfer + * @license http://opensource.org/licenses/MIT The MIT License + * @link http://bootstrap.braincrafted.com Bootstrap for Symfony2 + * + * @codeCoverageIgnore + */ class TypeSetterExtension extends AbstractTypeExtension { + /** + * {@inheritDoc} + */ public function buildView(FormView $view, FormInterface $form, array $options) { $view->vars['original_type'] = $form->getConfig()->getType()->getName(); } + /** + * {@inheritDoc} + */ public function getExtendedType() { return "form"; diff --git a/Form/Type/BootstrapCollectionType.php b/Form/Type/BootstrapCollectionType.php index f514010..6399fc7 100644 --- a/Form/Type/BootstrapCollectionType.php +++ b/Form/Type/BootstrapCollectionType.php @@ -1,4 +1,8 @@ <?php +/** + * This file is part of BcBootstrapBundle. + * (c) 2012-2013 by Florian Eckerstorfer + */ namespace Bc\Bundle\BootstrapBundle\Form\Type; @@ -10,6 +14,16 @@ use Symfony\Component\Form\Extension\Core\EventListener\ResizeFormListener; use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolverInterface; +/** + * MoneyType + * + * @package BcBootstrapBundle + * @subpackage Form + * @author Florian Eckerstorfer <florian@eckerstorfer.co> + * @copyright 2012-2013 Florian Eckerstorfer + * @license http://opensource.org/licenses/MIT The MIT License + * @link http://bootstrap.braincrafted.com Bootstrap for Symfony2 + */ class BootstrapCollectionType extends AbstractType { /** @@ -17,14 +31,17 @@ class BootstrapCollectionType extends AbstractType */ public function buildView(FormView $view, FormInterface $form, array $options) { - $view->vars = array_replace($view->vars, array( - 'allow_add' => $options['allow_add'], - 'allow_delete' => $options['allow_delete'], - 'add_button_text' => $options['add_button_text'], - 'delete_button_text' => $options['delete_button_text'], - 'widget_col' => $options['widget_col'], - 'button_col' => $options['button_col'] - )); + $view->vars = array_replace( + $view->vars, + array( + 'allow_add' => $options['allow_add'], + 'allow_delete' => $options['allow_delete'], + 'add_button_text' => $options['add_button_text'], + 'delete_button_text' => $options['delete_button_text'], + 'widget_col' => $options['widget_col'], + 'button_col' => $options['button_col'] + ) + ); if ($form->getConfig()->hasAttribute('prototype')) { $view->vars['prototype'] = $form->getConfig()->getAttribute('prototype')->createView($view); @@ -55,9 +72,7 @@ class BootstrapCollectionType extends AbstractType 'options' => array(), )); - $resolver->setNormalizers(array( - 'options' => $optionsNormalizer, - )); + $resolver->setNormalizers(array('options' => $optionsNormalizer)); } /** @@ -75,4 +90,4 @@ class BootstrapCollectionType extends AbstractType { return 'bc_collection'; } -} \ No newline at end of file +} diff --git a/Form/Type/MoneyType.php b/Form/Type/MoneyType.php index 2d1aac1..a83b7f0 100644 --- a/Form/Type/MoneyType.php +++ b/Form/Type/MoneyType.php @@ -1,4 +1,8 @@ <?php +/** + * This file is part of BcBootstrapBundle. + * (c) 2012-2013 by Florian Eckerstorfer + */ namespace Bc\Bundle\BootstrapBundle\Form\Type; @@ -10,6 +14,16 @@ use Symfony\Component\Form\Extension\Core\DataTransformer\MoneyToLocalizedString use Symfony\Component\Form\FormView; use Symfony\Component\OptionsResolver\OptionsResolverInterface; +/** + * MoneyType + * + * @package BcBootstrapBundle + * @subpackage Form + * @author Florian Eckerstorfer <florian@eckerstorfer.co> + * @copyright 2012-2013 Florian Eckerstorfer + * @license http://opensource.org/licenses/MIT The MIT License + * @link http://bootstrap.braincrafted.com Bootstrap for Symfony2 + */ class MoneyType extends BaseMoneyType { /** @@ -33,6 +47,10 @@ class MoneyType extends BaseMoneyType * * The pattern contains the placeholder "{{ widget }}" where the HTML tag should * be inserted + * + * @param string $currency + * + * @return string Returns the pattern */ protected static function getPattern($currency) { @@ -53,20 +71,33 @@ class MoneyType extends BaseMoneyType // the spacings between currency symbol and number are ignored, because // a single space leads to better readability in combination with input // fields - // the regex also considers non-break spaces (0xC2 or 0xA0 in UTF-8) preg_match('/^([^\s\xc2\xa0]*)[\s\xc2\xa0]*123(?:[,.]0+)?[\s\xc2\xa0]*([^\s\xc2\xa0]*)$/u', $pattern, $matches); - if (!empty($matches[1])) { - self::$patterns[$locale][$currency] = '{{ tag_start }}'.$matches[1].'{{ tag_end }} {{ widget }}'; - } elseif (!empty($matches[2])) { - self::$patterns[$locale][$currency] = '{{ widget }} {{ tag_start }}'.$matches[2].'{{ tag_end }}'; - } else { - self::$patterns[$locale][$currency] = '{{ widget }}'; - } + self::$patterns[$locale][$currency] = self::parsePatternMatches($matches); } return self::$patterns[$locale][$currency]; } + + /** + * Parses the given pattern matches array and returns the pattern string. + * + * @param array $matches Pattern matches + * + * @return string Pattern + */ + protected static function parsePatternMatches(array $matches) + { + if (!empty($matches[1])) { + return '{{ tag_start }}'.$matches[1].'{{ tag_end }} {{ widget }}'; + } + + if (!empty($matches[2])) { + return '{{ widget }} {{ tag_start }}'.$matches[2].'{{ tag_end }}'; + } + + return '{{ widget }}'; + } } diff --git a/LICENSE b/LICENSE index c3a61ec..e7f601c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2012 Florian Eckerstorfer +Copyright (c) 2012-2013 Florian Eckerstorfer Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/Twig/BootstrapFormExtension.php b/Twig/BootstrapFormExtension.php index 644e281..e7eca6b 100644 --- a/Twig/BootstrapFormExtension.php +++ b/Twig/BootstrapFormExtension.php @@ -1,4 +1,8 @@ <?php +/** + * This file is part of BcBootstrapBundle. + * (c) 2012-2013 by Florian Eckerstorfer + */ namespace Bc\Bundle\BootstrapBundle\Twig; @@ -7,9 +11,14 @@ use Symfony\Bridge\Twig\Form\TwigRendererInterface; use Symfony\Component\Form\Extension\Core\View\ChoiceView; /** - * BootstrapFormExtension extends Twig with form capabilities. + * BootstrapFormExtension * - * @author Florian Eckerstorfer <florian@eckerstorfer.co> + * @package BcBootstrapBundle + * @subpackage Twig + * @author Florian Eckerstorfer <florian@eckerstorfer.co> + * @copyright 2012-2013 Florian Eckerstorfer + * @license http://opensource.org/licenses/MIT The MIT License + * @link http://bootstrap.braincrafted.com Bootstrap for Symfony2 */ class BootstrapFormExtension extends \Twig_Extension { @@ -37,11 +46,21 @@ class BootstrapFormExtension extends \Twig_Extension return 'bootstrap_form'; } + /** + * Sets the style. + * + * @param string $style Name of the style + */ public function setStyle($style) { $this->style = $style; } + /** + * Returns the style. + * + * @return string Name of the style + */ public function getStyle() { return $this->style; diff --git a/Twig/BootstrapIconExtension.php b/Twig/BootstrapIconExtension.php index 83d354e..1c75857 100644 --- a/Twig/BootstrapIconExtension.php +++ b/Twig/BootstrapIconExtension.php @@ -1,7 +1,6 @@ <?php /** * This file is part of BcBootstrapBundle. - * * (c) 2012-2013 by Florian Eckerstorfer */ @@ -13,7 +12,6 @@ use Twig_Filter_Method; /** * BootstrapIconExtension * - * @category TwigExtension * @package BcBootstrapBundle * @subpackage Twig * @author Florian Eckerstorfer <florian@eckerstorfer.co> @@ -58,6 +56,7 @@ class BootstrapIconExtension extends Twig_Extension '/\.icon-([a-z0-9-]+)(\((white|black)\))?/', function ($matches) use ($color, $that) { $color = isset($matches[3]) ? $matches[3] : $color; + return $that->iconFilter($matches[1], $color); }, $text diff --git a/composer.json b/composer.json index d93cd86..21de838 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,5 @@ { "name": "braincrafted/bootstrap-bundle", - "version": "1.4.2", "description": "Twitter Bootstrap for Symfony2", "keywords": ["bootstrap"], "type": "symfony-bundle", @@ -31,7 +30,7 @@ "knplabs/knp-paginator-bundle": "BraincraftedBootstrapBundle styles the pagination provided by KnpPaginatorBundle.", "knplabs/knp-menu": "Required to use KnpMenuBundle.", "knplabs/knp-menu-bundle": "BraincraftedBootstrapBundle styles the menus provided by KnpMenuBundle.", - "twitter/bootstrap": "Twitter Bootstrap provides the assets (images, CSS and JS)" + "twbs/bootstrap": "Twitter Bootstrap provides the assets (images, CSS and JS)" }, "autoload": { "psr-0": { "Bc\\Bundle\\BootstrapBundle": "" } -- GitLab