diff --git a/DependencyInjection/BcBootstrapExtension.php b/DependencyInjection/BcBootstrapExtension.php index 85b151b0c09b3113b1b1ddfe23c84615f7985b46..602e48b2cc675755750a25b971444f7940ef71a8 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 0901ce4ced45e1bd9085511176435661a2dbdad5..7c5f5b148e4df5dd9046aec18ae3aa1d60737b43 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 f5140106e442630a9a7f5bab097f5b716dd097b1..6399fc7211740ab61d16923a82c309c89b5bb115 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 2d1aac1830a5e5c37aeb6d7ed798dd642ff2220c..a83b7f0c2fcd54b5cf93cb43a0da7265c12bf88c 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 c3a61ec403e44a4018da4261c0e7d5bb3c6cdc0f..e7f601cea974dc631b4552000dca62d53e09458b 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 644e2811f543045ce76f32523da1bc0b0bfd2146..e7eca6b5dd1e2005abec0b8372e7c84d44a6c569 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 83d354e2737d6781b98c5c337a8cfc14c59763ca..1c75857ff25a300165c986503401fb3fc4418d7a 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 d93cd869723a5958e211f334c6216fec70710a96..21de838b05a6bc7248b64b9efde2a22d93c39b6f 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": "" }