parent
f7b094cb7f
commit
43efa113d7
@ -1,7 +0,0 @@ |
|||||||
/build/ |
|
||||||
/vendor/ |
|
||||||
/Resources/docs/code-coverage |
|
||||||
/phpunit.xml |
|
||||||
/composer.lock |
|
||||||
*.sublime-project |
|
||||||
*.sublime-workspace |
|
||||||
@ -1,44 +0,0 @@ |
|||||||
filter: |
|
||||||
excluded_paths: |
|
||||||
- 'vendor/*' |
|
||||||
- 'app/*' |
|
||||||
- 'web/*' |
|
||||||
- 'Tests/*' |
|
||||||
before_commands: |
|
||||||
- 'composer --prefer-source --dev install' |
|
||||||
- 'cp phpunit.xml.dist phpunit.xml' |
|
||||||
tools: |
|
||||||
php_mess_detector: |
|
||||||
config: |
|
||||||
naming_rules: { boolean_method_name: true } |
|
||||||
controversial_rules: { camel_case_class_name: true, camel_case_property_name: true, camel_case_method_name: true, camel_case_parameter_name: true, camel_case_variable_name: true } |
|
||||||
php_analyzer: |
|
||||||
config: |
|
||||||
parameter_reference_check: { enabled: false } |
|
||||||
checkstyle: { enabled: true, no_trailing_whitespace: true, naming: { enabled: true, local_variable: '^[a-z][a-zA-Z0-9]*$', abstract_class_name: ^Abstract|Factory$, utility_class_name: 'Utils?$', constant_name: '^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$', property_name: '^[a-z][a-zA-Z0-9]*$', method_name: '^(?:[a-z]|__)[a-zA-Z0-9]*$', parameter_name: '^[a-z][a-zA-Z0-9]*$', interface_name: '^[A-Z][a-zA-Z0-9]*Interface$', type_name: '^[A-Z][a-zA-Z0-9]*$', exception_name: '^[A-Z][a-zA-Z0-9]*Exception$', isser_method_name: '^(?:is|has|should|may|supports)' } } |
|
||||||
unreachable_code: { enabled: true } |
|
||||||
check_access_control: { enabled: false } |
|
||||||
typo_checks: { enabled: true } |
|
||||||
check_variables: { enabled: true } |
|
||||||
suspicious_code: { enabled: false, overriding_parameter: false, overriding_closure_use: false, parameter_closure_use_conflict: false, parameter_multiple_times: false, non_existent_class_in_instanceof_check: false, non_existent_class_in_catch_clause: false, assignment_of_null_return: false, non_commented_switch_fallthrough: false, non_commented_empty_catch_block: false, overriding_private_members: false, use_statement_alias_conflict: false, precedence_in_condition_assignment: false } |
|
||||||
dead_assignments: { enabled: true } |
|
||||||
verify_php_doc_comments: { enabled: true, parameters: true, return: true, suggest_more_specific_types: true, ask_for_return_if_not_inferrable: true, ask_for_param_type_annotation: true } |
|
||||||
loops_must_use_braces: { enabled: true } |
|
||||||
check_usage_context: { enabled: true, method_call_on_non_object: { enabled: true, ignore_null_pointer: true }, foreach: { value_as_reference: true, traversable: true }, missing_argument: true, argument_type_checks: lenient } |
|
||||||
simplify_boolean_return: { enabled: true } |
|
||||||
phpunit_checks: { enabled: true } |
|
||||||
reflection_checks: { enabled: false } |
|
||||||
precedence_checks: { enabled: true, assignment_in_condition: true, comparison_of_bit_result: true } |
|
||||||
basic_semantic_checks: { enabled: true } |
|
||||||
doc_comment_fixes: { enabled: true } |
|
||||||
reflection_fixes: { enabled: false } |
|
||||||
use_statement_fixes: { enabled: true, remove_unused: true, preserve_multiple: false, order_alphabetically: false } |
|
||||||
php_code_sniffer: |
|
||||||
config: |
|
||||||
standard: PSR2 |
|
||||||
sensiolabs_security_checker: true |
|
||||||
php_code_coverage: |
|
||||||
config_path: phpunit.xml.dist |
|
||||||
php_cpd: true |
|
||||||
php_loc: true |
|
||||||
php_pdepend: true |
|
||||||
@ -1,15 +0,0 @@ |
|||||||
language: php |
|
||||||
|
|
||||||
php: |
|
||||||
- 5.3.3 |
|
||||||
- 5.3 |
|
||||||
- 5.4 |
|
||||||
- 5.5 |
|
||||||
|
|
||||||
before_script: |
|
||||||
- wget http://getcomposer.org/composer.phar |
|
||||||
- php composer.phar --prefer-source --dev install |
|
||||||
- cp phpunit.xml.dist phpunit.xml |
|
||||||
|
|
||||||
script: |
|
||||||
- phpunit |
|
||||||
@ -1,24 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
/** |
|
||||||
* This file is part of BraincraftedBootstrapBundle. |
|
||||||
* |
|
||||||
* (c) 2012-2013 by Florian Eckerstorfer |
|
||||||
*/ |
|
||||||
|
|
||||||
namespace Braincrafted\Bundle\BootstrapBundle; |
|
||||||
|
|
||||||
use Symfony\Component\HttpKernel\Bundle\Bundle; |
|
||||||
|
|
||||||
/** |
|
||||||
* BraincraftedBootstrapBundle |
|
||||||
* |
|
||||||
* @package BraincraftedBootstrapBundle |
|
||||||
* @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 BraincraftedBootstrapBundle extends Bundle |
|
||||||
{ |
|
||||||
} |
|
||||||
@ -1,7 +0,0 @@ |
|||||||
Changelog BraincraftedBootstrapBunde |
|
||||||
==================================== |
|
||||||
|
|
||||||
Version 1.2.0 |
|
||||||
------------- |
|
||||||
|
|
||||||
- Added support for Assetic |
|
||||||
@ -1,29 +0,0 @@ |
|||||||
Contributing |
|
||||||
============ |
|
||||||
|
|
||||||
Thank you for contributing to BraincraftedBootstrapBundle. |
|
||||||
|
|
||||||
Here are a few rules to make code reviews and merging your code into the repository easier. |
|
||||||
|
|
||||||
You MUST follow the [PSR-1](http://www.php-fig.org/psr/1/) and |
|
||||||
[PSR-2](http://www.php-fig.org/psr/2/). If you don't know about them, read the recommendations. You can use |
|
||||||
[PHP-CS-Fixer tool](http://cs.sensiolabs.org/) to find errors in your code. |
|
||||||
|
|
||||||
You MUST run the test suite. |
|
||||||
|
|
||||||
You MUST write (or update) unit tests. |
|
||||||
|
|
||||||
You SHOULD write documentation. |
|
||||||
|
|
||||||
Please, write [commit messages that make |
|
||||||
sense](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html), |
|
||||||
and [rebase your branch](http://git-scm.com/book/en/Git-Branching-Rebasing) |
|
||||||
before submitting your Pull Request. |
|
||||||
|
|
||||||
If asked, [squash your |
|
||||||
commits](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html). This is used to "clean" your Pull |
|
||||||
Request before merging it (we don't want commits such as `fix tests`, `fix 2`, `fix 3`, etc.). |
|
||||||
|
|
||||||
Thank you! |
|
||||||
|
|
||||||
This document is based on an article by [William Durand](http://williamdurand.fr/2013/11/20/on-creating-pull-requests/). |
|
||||||
@ -1,113 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
/** |
|
||||||
* This file is part of BraincraftedBootstrapBundle. |
|
||||||
* |
|
||||||
* (c) 2012-2013 by Florian Eckerstorfer |
|
||||||
*/ |
|
||||||
|
|
||||||
namespace Braincrafted\Bundle\BootstrapBundle\Command; |
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
|
||||||
use Symfony\Component\Console\Input\InputInterface; |
|
||||||
use Symfony\Component\Console\Output\OutputInterface; |
|
||||||
|
|
||||||
use Braincrafted\Bundle\BootstrapBundle\Util\PathUtil; |
|
||||||
|
|
||||||
/** |
|
||||||
* GenerateCommand |
|
||||||
* |
|
||||||
* @package BraincraftedBootstrapBundle |
|
||||||
* @subpackage Command |
|
||||||
* @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 BraincraftedBootstrapBundle |
|
||||||
*/ |
|
||||||
class GenerateCommand extends ContainerAwareCommand |
|
||||||
{ |
|
||||||
/** @var PathUtil */ |
|
||||||
private $pathUtil; |
|
||||||
|
|
||||||
/** |
|
||||||
* {@inheritDoc} |
|
||||||
*/ |
|
||||||
public function __construct($name = null) |
|
||||||
{ |
|
||||||
$this->pathUtil = new PathUtil; |
|
||||||
|
|
||||||
parent::__construct($name); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* {@inheritDoc} |
|
||||||
* |
|
||||||
* @codeCoverageIgnore |
|
||||||
*/ |
|
||||||
protected function configure() |
|
||||||
{ |
|
||||||
$this |
|
||||||
->setName('braincrafted:bootstrap:generate') |
|
||||||
->setDescription('Generates a custom bootstrap.less') |
|
||||||
; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* {@inheritDoc} |
|
||||||
*/ |
|
||||||
protected function execute(InputInterface $input, OutputInterface $output) |
|
||||||
{ |
|
||||||
$config = $this->getContainer()->getParameter('braincrafted_bootstrap.customize'); |
|
||||||
|
|
||||||
if (false === isset($config['variables_file']) || null === $config['variables_file']) { |
|
||||||
$output->writeln('<error>Found no custom variables.less file.</error>'); |
|
||||||
|
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
$filter = $this->getContainer()->getParameter('braincrafted_bootstrap.less_filter'); |
|
||||||
if ('less' !== $filter && 'lessphp' !== $filter) { |
|
||||||
$output->writeln( |
|
||||||
'<error>Bundle must be configured with "less" or "lessphp" to generated bootstrap.less</error>' |
|
||||||
); |
|
||||||
|
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
$output->writeln('<comment>Found custom variables file. Generating...</comment>'); |
|
||||||
$this->executeGenerateBootstrap($config); |
|
||||||
$output->writeln(sprintf('Saved to <info>%s</info>', $config['bootstrap_output'])); |
|
||||||
} |
|
||||||
|
|
||||||
protected function executeGenerateBootstrap(array $config) |
|
||||||
{ |
|
||||||
// In the template for bootstrap.less we need the path where Bootstraps .less files are stored and the path |
|
||||||
// to the variables.less file. |
|
||||||
// Absolute path do not work in LESSs import statement, we have to calculate the relative ones |
|
||||||
|
|
||||||
$lessDir = $this->pathUtil->getRelativePath( |
|
||||||
dirname($config['bootstrap_output']), |
|
||||||
$this->getContainer()->getParameter('braincrafted_bootstrap.assets_dir') |
|
||||||
); |
|
||||||
$variablesDir = $this->pathUtil->getRelativePath( |
|
||||||
dirname($config['bootstrap_output']), |
|
||||||
dirname($config['variables_file']) |
|
||||||
); |
|
||||||
$variablesFile = sprintf( |
|
||||||
'%s%s%s', |
|
||||||
$variablesDir, |
|
||||||
strlen($variablesDir) > 0 ? '/' : '', |
|
||||||
basename($config['variables_file']) |
|
||||||
); |
|
||||||
|
|
||||||
// We can now use Twig to render the bootstrap.less file and save it |
|
||||||
$content = $this->getContainer()->get('twig')->render( |
|
||||||
$config['bootstrap_template'], |
|
||||||
array( |
|
||||||
'variables_file' => $variablesFile, |
|
||||||
'assets_dir' => $lessDir |
|
||||||
) |
|
||||||
); |
|
||||||
file_put_contents($config['bootstrap_output'], $content); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,91 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
namespace Braincrafted\Bundle\BootstrapBundle\Command; |
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
|
||||||
use Symfony\Component\Console\Input\InputInterface; |
|
||||||
use Symfony\Component\Console\Output\OutputInterface; |
|
||||||
use Symfony\Component\Finder\Finder; |
|
||||||
use Symfony\Component\Filesystem\Filesystem; |
|
||||||
use Symfony\Component\Filesystem\Exception\IOException; |
|
||||||
|
|
||||||
class InstallCommand extends ContainerAwareCommand |
|
||||||
{ |
|
||||||
/** |
|
||||||
* {@inheritDoc} |
|
||||||
*/ |
|
||||||
protected function configure() |
|
||||||
{ |
|
||||||
$this->setName('braincrafted:bootstrap:install') |
|
||||||
->setDescription('Installs the icon font'); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* {@inheritDoc} |
|
||||||
*/ |
|
||||||
protected function execute(InputInterface $input, OutputInterface $output) |
|
||||||
{ |
|
||||||
$destDir = $this->getDestDir(); |
|
||||||
|
|
||||||
$finder = new Finder; |
|
||||||
$fs = new Filesystem; |
|
||||||
|
|
||||||
try { |
|
||||||
$fs->mkdir($destDir); |
|
||||||
} catch (IOException $e) { |
|
||||||
$output->writeln(sprintf('<error>Could not create directory %s.</error>', $destDir)); |
|
||||||
|
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
$srcDir = $this->getSrcDir(); |
|
||||||
if (false === file_exists($srcDir)) { |
|
||||||
$output->writeln(sprintf( |
|
||||||
'<error>Fonts directory "%s" does not exist. Did you install twbs/bootstrap? '. |
|
||||||
'If you used something other than Compoer you need to manually change the path in '. |
|
||||||
'"braincrafted_bootstrap.assets_dir".</error>', |
|
||||||
$srcDir |
|
||||||
)); |
|
||||||
|
|
||||||
return; |
|
||||||
} |
|
||||||
$finder->files()->in($srcDir); |
|
||||||
|
|
||||||
foreach ($finder as $file) { |
|
||||||
$dest = sprintf('%s/%s', $destDir, $file->getBaseName()); |
|
||||||
try { |
|
||||||
$fs->copy($file, $dest); |
|
||||||
} catch (IOException $e) { |
|
||||||
$output->writeln(sprintf('<error>Could not copy %s</error>', $file->getBaseName())); |
|
||||||
return; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
$output->writeln(sprintf('Copied Glyphicon fonts to <comment>%s</comment>.', $destDir)); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @return string |
|
||||||
*/ |
|
||||||
protected function getSrcDir() |
|
||||||
{ |
|
||||||
return sprintf('%s/fonts', $this->getContainer()->getParameter('braincrafted_bootstrap.assets_dir')); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @return string |
|
||||||
*/ |
|
||||||
protected function getDestDir() |
|
||||||
{ |
|
||||||
$outputDir = $this->getContainer()->getParameter('braincrafted_bootstrap.output_dir'); |
|
||||||
if (strlen($outputDir) > 0 && '/' !== substr($outputDir, -1)) { |
|
||||||
$outputDir .= '/'; |
|
||||||
} |
|
||||||
|
|
||||||
return sprintf( |
|
||||||
'%s/../web/%sfonts', |
|
||||||
$this->getContainer()->getParameter('kernel.root_dir'), |
|
||||||
$outputDir |
|
||||||
); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,98 +0,0 @@ |
|||||||
<?php |
|
||||||
/** |
|
||||||
* This file is part of BraincraftedBootstrapBundle. |
|
||||||
* |
|
||||||
* (c) 2013 Florian Eckerstorfer <florian@eckerstorfer.co> |
|
||||||
* |
|
||||||
* This source file is subject to the MIT license that is bundled |
|
||||||
* with this source code in the file LICENSE. |
|
||||||
*/ |
|
||||||
|
|
||||||
namespace Braincrafted\Bundle\BootstrapBundle\Composer; |
|
||||||
|
|
||||||
use Symfony\Component\Process\Process; |
|
||||||
use Symfony\Component\Process\PhpExecutableFinder; |
|
||||||
use Composer\Script\CommandEvent; |
|
||||||
|
|
||||||
/** |
|
||||||
* ScriptHandler |
|
||||||
* |
|
||||||
* @package BraincraftedBootstrapBundle |
|
||||||
* @subpackage Composer |
|
||||||
* @author Florian Eckerstorfer <florian@eckerstorfer.co> |
|
||||||
* @copyright 2013 Florian Eckerstorfer |
|
||||||
* @license http://opensource.org/licenses/MIT The MIT License |
|
||||||
* |
|
||||||
* @codeCoverageIgnore |
|
||||||
*/ |
|
||||||
class ScriptHandler |
|
||||||
{ |
|
||||||
/** |
|
||||||
* @param CommandEvent $event |
|
||||||
*/ |
|
||||||
public static function install(CommandEvent $event) |
|
||||||
{ |
|
||||||
$options = self::getOptions($event); |
|
||||||
$appDir = $options['symfony-app-dir']; |
|
||||||
|
|
||||||
if (!is_dir($appDir)) { |
|
||||||
printf( |
|
||||||
'The symfony-app-dir (%s) specified in composer.json was not found in %s, can not build bootstrap '. |
|
||||||
'file.%s', |
|
||||||
$appDir, |
|
||||||
getcwd(), |
|
||||||
PHP_EOL |
|
||||||
); |
|
||||||
|
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
static::executeCommand($event, $appDir, 'braincrafted:bootstrap:install', $options['process-timeout']); |
|
||||||
} |
|
||||||
|
|
||||||
protected static function executeCommand(CommandEvent $event, $appDir, $cmd, $timeout = 300) |
|
||||||
{ |
|
||||||
$php = escapeshellarg(self::getPhp()); |
|
||||||
$console = escapeshellarg($appDir.'/console'); |
|
||||||
if ($event->getIO()->isDecorated()) { |
|
||||||
$console .= ' --ansi'; |
|
||||||
} |
|
||||||
|
|
||||||
$process = new Process($php.' '.$console.' '.$cmd, null, null, null, $timeout); |
|
||||||
$process->run(function ($type, $buffer) { |
|
||||||
echo $buffer; |
|
||||||
}); |
|
||||||
if (!$process->isSuccessful()) { |
|
||||||
throw new \RuntimeException( |
|
||||||
sprintf('An error occurred when executing the "%s" command.', escapeshellarg($cmd)) |
|
||||||
); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
protected static function getOptions(CommandEvent $event) |
|
||||||
{ |
|
||||||
$options = array_merge(array( |
|
||||||
'symfony-app-dir' => 'app', |
|
||||||
'symfony-web-dir' => 'web', |
|
||||||
'symfony-assets-install' => 'hard' |
|
||||||
), $event->getComposer()->getPackage()->getExtra()); |
|
||||||
|
|
||||||
$options['symfony-assets-install'] = getenv('SYMFONY_ASSETS_INSTALL') ?: $options['symfony-assets-install']; |
|
||||||
|
|
||||||
$options['process-timeout'] = $event->getComposer()->getConfig()->get('process-timeout'); |
|
||||||
|
|
||||||
return $options; |
|
||||||
} |
|
||||||
|
|
||||||
protected static function getPhp() |
|
||||||
{ |
|
||||||
$phpFinder = new PhpExecutableFinder; |
|
||||||
if (!$phpPath = $phpFinder->find()) { |
|
||||||
throw new \RuntimeException( |
|
||||||
'The php executable could not be found, add it to your PATH environment variable and try again' |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
return $phpPath; |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,132 +0,0 @@ |
|||||||
<?php |
|
||||||
/** |
|
||||||
* This file is part of BraincraftedBootstrapBundle. |
|
||||||
* |
|
||||||
* (c) 2012-2013 by Florian Eckerstorfer |
|
||||||
*/ |
|
||||||
|
|
||||||
namespace Braincrafted\Bundle\BootstrapBundle\DependencyInjection; |
|
||||||
|
|
||||||
/** |
|
||||||
* AsseticConfiguration |
|
||||||
* |
|
||||||
* @package BraincraftedBootstrapBundle |
|
||||||
* @subpackage DependencyInjection |
|
||||||
* @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 AsseticConfiguration |
|
||||||
{ |
|
||||||
/** |
|
||||||
* Builds the assetic configuration. |
|
||||||
* |
|
||||||
* @param array $config |
|
||||||
* |
|
||||||
* @return array |
|
||||||
*/ |
|
||||||
public function build(array $config) |
|
||||||
{ |
|
||||||
$output = array(); |
|
||||||
|
|
||||||
// Fix path in output dir |
|
||||||
if ('/' !== substr($config['output_dir'], -1) && strlen($config['output_dir']) > 0) { |
|
||||||
$config['output_dir'] .= '/'; |
|
||||||
} |
|
||||||
|
|
||||||
if ('none' !== $config['less_filter']) { |
|
||||||
$output['bootstrap_css'] = $this->buildCssWithLess($config); |
|
||||||
} else { |
|
||||||
$output['bootstrap_css'] = $this->buildCssWithoutLess($config); |
|
||||||
} |
|
||||||
|
|
||||||
$output['bootstrap_js'] = $this->buildJs($config); |
|
||||||
$output['jquery'] = $this->buildJquery($config); |
|
||||||
|
|
||||||
return $output; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @param array $config |
|
||||||
* |
|
||||||
* @return array |
|
||||||
*/ |
|
||||||
protected function buildCssWithoutLess(array $config) |
|
||||||
{ |
|
||||||
$inputs = array( |
|
||||||
$config['assets_dir'].'/dist/css/bootstrap.css', |
|
||||||
); |
|
||||||
|
|
||||||
return array( |
|
||||||
'inputs' => $inputs, |
|
||||||
'filters' => array('cssrewrite'), |
|
||||||
'output' => $config['output_dir'].'css/bootstrap.css' |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @param array $config |
|
||||||
* |
|
||||||
* @return array |
|
||||||
*/ |
|
||||||
protected function buildCssWithLess(array $config) |
|
||||||
{ |
|
||||||
$bootstrapFile = $config['assets_dir'].'/less/bootstrap.less'; |
|
||||||
if (true === isset($config['customize']['variables_file']) && |
|
||||||
null !== $config['customize']['variables_file']) { |
|
||||||
$bootstrapFile = $config['customize']['bootstrap_output']; |
|
||||||
} |
|
||||||
|
|
||||||
$inputs = array( |
|
||||||
$bootstrapFile, |
|
||||||
__DIR__.'/../Resources/less/form.less' |
|
||||||
); |
|
||||||
|
|
||||||
return array( |
|
||||||
'inputs' => $inputs, |
|
||||||
'filters' => array($config['less_filter']), |
|
||||||
'output' => $config['output_dir'].'css/bootstrap.css' |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @param array $config |
|
||||||
* |
|
||||||
* @return array |
|
||||||
*/ |
|
||||||
protected function buildJs(array $config) |
|
||||||
{ |
|
||||||
return array( |
|
||||||
'inputs' => array( |
|
||||||
$config['assets_dir'].'/js/transition.js', |
|
||||||
$config['assets_dir'].'/js/alert.js', |
|
||||||
$config['assets_dir'].'/js/button.js', |
|
||||||
$config['assets_dir'].'/js/carousel.js', |
|
||||||
$config['assets_dir'].'/js/collapse.js', |
|
||||||
$config['assets_dir'].'/js/dropdown.js', |
|
||||||
$config['assets_dir'].'/js/modal.js', |
|
||||||
$config['assets_dir'].'/js/tooltip.js', |
|
||||||
$config['assets_dir'].'/js/popover.js', |
|
||||||
$config['assets_dir'].'/js/scrollspy.js', |
|
||||||
$config['assets_dir'].'/js/tab.js', |
|
||||||
$config['assets_dir'].'/js/affix.js', |
|
||||||
__DIR__.'/../Resources/js/bc-bootstrap-collection.js' |
|
||||||
), |
|
||||||
'output' => $config['output_dir'].'js/bootstrap.js' |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @param array $config |
|
||||||
* |
|
||||||
* @return array |
|
||||||
*/ |
|
||||||
protected function buildJquery(array $config) |
|
||||||
{ |
|
||||||
return array( |
|
||||||
'inputs' => array($config['jquery_path']), |
|
||||||
'output' => $config['output_dir'].'js/jquery.js' |
|
||||||
); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,179 +0,0 @@ |
|||||||
<?php |
|
||||||
/** |
|
||||||
* This file is part of BraincraftedBootstrapBundle. |
|
||||||
* |
|
||||||
* (c) 2012-2013 by Florian Eckerstorfer |
|
||||||
*/ |
|
||||||
|
|
||||||
namespace Braincrafted\Bundle\BootstrapBundle\DependencyInjection; |
|
||||||
|
|
||||||
use Symfony\Component\Config\FileLocator; |
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
||||||
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; |
|
||||||
use Symfony\Component\DependencyInjection\Loader; |
|
||||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
|
||||||
|
|
||||||
use Braincrafted\Bundle\BootstrapBundle\DependencyInjection\AsseticConfiguration; |
|
||||||
|
|
||||||
/** |
|
||||||
* BraincraftedBootstrapExtension |
|
||||||
* |
|
||||||
* @package BraincraftedBootstrapBundle |
|
||||||
* @subpackage DependencyInjection |
|
||||||
* @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 BraincraftedBootstrapExtension extends Extension implements PrependExtensionInterface |
|
||||||
{ |
|
||||||
/** @var string */ |
|
||||||
protected $formTemplate = 'BraincraftedBootstrapBundle:Form:bootstrap.html.twig'; |
|
||||||
|
|
||||||
/** @var string */ |
|
||||||
protected $menuTemplate = 'BraincraftedBootstrapBundle:Menu:bootstrap.html.twig'; |
|
||||||
|
|
||||||
/** @var string */ |
|
||||||
protected $paginationTemplate = 'BraincraftedBootstrapBundle:Pagination:bootstrap.html.twig'; |
|
||||||
|
|
||||||
/** |
|
||||||
* {@inheritDoc} |
|
||||||
*/ |
|
||||||
public function load(array $configs, ContainerBuilder $container) |
|
||||||
{ |
|
||||||
$configuration = new Configuration(); |
|
||||||
$config = $this->processConfiguration($configuration, $configs); |
|
||||||
|
|
||||||
$loader = new Loader\XmlFileLoader( |
|
||||||
$container, |
|
||||||
new FileLocator(__DIR__.'/../Resources/config') |
|
||||||
); |
|
||||||
$loader->load('services/form.xml'); |
|
||||||
$loader->load('services/twig.xml'); |
|
||||||
$loader->load('services/session.xml'); |
|
||||||
|
|
||||||
if (true === isset($config['customize'])) { |
|
||||||
$container->setParameter('braincrafted_bootstrap.customize', $config['customize']); |
|
||||||
} |
|
||||||
$container->setParameter('braincrafted_bootstrap.assets_dir', $config['assets_dir']); |
|
||||||
$container->setParameter('braincrafted_bootstrap.output_dir', $config['output_dir']); |
|
||||||
$container->setParameter('braincrafted_bootstrap.less_filter', $config['less_filter']); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* {@inheritDoc} |
|
||||||
*/ |
|
||||||
public function prepend(ContainerBuilder $container) |
|
||||||
{ |
|
||||||
$bundles = $container->getParameter('kernel.bundles'); |
|
||||||
|
|
||||||
$configs = $container->getExtensionConfig($this->getAlias()); |
|
||||||
$config = $this->processConfiguration(new Configuration(), $configs); |
|
||||||
|
|
||||||
// Configure Assetic if AsseticBundle is activated and the option |
|
||||||
// "braincrafted_bootstrap.auto_configure.assetic" is set to TRUE (default value). |
|
||||||
if (true === isset($bundles['AsseticBundle']) && true === $config['auto_configure']['assetic']) { |
|
||||||
$this->configureAsseticBundle($container, $config); |
|
||||||
} |
|
||||||
|
|
||||||
// Configure Twig if TwigBundle is activated and the option |
|
||||||
// "braincrafted_bootstrap.auto_configure.twig" is set to TRUE (default value). |
|
||||||
if (true === isset($bundles['TwigBundle']) && true === $config['auto_configure']['twig']) { |
|
||||||
$this->configureTwigBundle($container); |
|
||||||
} |
|
||||||
|
|
||||||
// Configure KnpMenu if KnpMenuBundle and TwigBundle are activated and the option |
|
||||||
// "braincrafted_bootstrap.auto_configure.knp_menu" is set to TRUE (default value). |
|
||||||
if (true === isset($bundles['TwigBundle']) && |
|
||||||
true === isset($bundles['KnpMenuBundle']) && |
|
||||||
true === $config['auto_configure']['knp_menu']) { |
|
||||||
$this->configureKnpMenuBundle($container); |
|
||||||
} |
|
||||||
|
|
||||||
// Configure KnpPaginiator if KnpPaginatorBundle and TwigBundle are activated and the option |
|
||||||
// "braincrafted_bootstrap.auto_configure.knp_paginator" is set to TRUE (default value). |
|
||||||
if (true === isset($bundles['TwigBundle']) && |
|
||||||
true === isset($bundles['KnpPaginatorBundle']) && |
|
||||||
true === $config['auto_configure']['knp_paginator']) { |
|
||||||
$this->configureKnpPaginatorBundle($container); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @param ContainerBuilder $container The service container |
|
||||||
* @param array $config The bundle configuration |
|
||||||
* |
|
||||||
* @return void |
|
||||||
*/ |
|
||||||
protected function configureAsseticBundle(ContainerBuilder $container, array $config) |
|
||||||
{ |
|
||||||
foreach (array_keys($container->getExtensions()) as $name) { |
|
||||||
switch ($name) { |
|
||||||
case 'assetic': |
|
||||||
$asseticConfig = new AsseticConfiguration; |
|
||||||
$container->prependExtensionConfig( |
|
||||||
$name, |
|
||||||
array('assets' => $asseticConfig->build($config)) |
|
||||||
); |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @param ContainerBuilder $container The service container |
|
||||||
* |
|
||||||
* @return void |
|
||||||
*/ |
|
||||||
protected function configureTwigBundle(ContainerBuilder $container) |
|
||||||
{ |
|
||||||
foreach (array_keys($container->getExtensions()) as $name) { |
|
||||||
switch ($name) { |
|
||||||
case 'twig': |
|
||||||
$container->prependExtensionConfig( |
|
||||||
$name, |
|
||||||
array('form' => array('resources' => array($this->formTemplate))) |
|
||||||
); |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @param ContainerBuilder $container The service container |
|
||||||
* |
|
||||||
* @return void |
|
||||||
*/ |
|
||||||
protected function configureKnpMenuBundle(ContainerBuilder $container) |
|
||||||
{ |
|
||||||
foreach (array_keys($container->getExtensions()) as $name) { |
|
||||||
switch ($name) { |
|
||||||
case 'knp_menu': |
|
||||||
$container->prependExtensionConfig( |
|
||||||
$name, |
|
||||||
array('twig' => array('template' => $this->menuTemplate)) |
|
||||||
); |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @param ContainerBuilder $container The service container |
|
||||||
* |
|
||||||
* @return void |
|
||||||
*/ |
|
||||||
protected function configureKnpPaginatorBundle(ContainerBuilder $container) |
|
||||||
{ |
|
||||||
foreach (array_keys($container->getExtensions()) as $name) { |
|
||||||
switch ($name) { |
|
||||||
case 'knp_paginator': |
|
||||||
$container->prependExtensionConfig( |
|
||||||
$name, |
|
||||||
array('template' => array('pagination' => $this->paginationTemplate)) |
|
||||||
); |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,79 +0,0 @@ |
|||||||
<?php |
|
||||||
/** |
|
||||||
* This file is part of BraincraftedBootstrapBundle. |
|
||||||
* |
|
||||||
* (c) 2012-2013 by Florian Eckerstorfer |
|
||||||
*/ |
|
||||||
|
|
||||||
namespace Braincrafted\Bundle\BootstrapBundle\DependencyInjection; |
|
||||||
|
|
||||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
|
||||||
use Symfony\Component\Config\Definition\ConfigurationInterface; |
|
||||||
|
|
||||||
/** |
|
||||||
* Configuration |
|
||||||
* |
|
||||||
* @package BraincraftedBootstrapBundle |
|
||||||
* @subpackage DependencyInjection |
|
||||||
* @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 Configuration implements ConfigurationInterface |
|
||||||
{ |
|
||||||
/** |
|
||||||
* {@inheritDoc} |
|
||||||
*/ |
|
||||||
public function getConfigTreeBuilder() |
|
||||||
{ |
|
||||||
return $this->buildConfigTree(); |
|
||||||
} |
|
||||||
|
|
||||||
private function buildConfigTree() |
|
||||||
{ |
|
||||||
$treeBuilder = new TreeBuilder(); |
|
||||||
$rootNode = $treeBuilder->root('braincrafted_bootstrap'); |
|
||||||
|
|
||||||
$rootNode |
|
||||||
->children() |
|
||||||
->scalarNode('output_dir')->defaultValue('')->end() |
|
||||||
->scalarNode('assets_dir') |
|
||||||
->defaultValue('%kernel.root_dir%/../vendor/twbs/bootstrap') |
|
||||||
->end() |
|
||||||
->scalarNode('jquery_path') |
|
||||||
->defaultValue('%kernel.root_dir%/../vendor/jquery/jquery/jquery-1.10.2.js') |
|
||||||
->end() |
|
||||||
->scalarNode('less_filter') |
|
||||||
->defaultValue('less') |
|
||||||
->validate() |
|
||||||
->ifNotInArray(array('less', 'lessphp', 'none')) |
|
||||||
->thenInvalid('Invalid less filter "%s"') |
|
||||||
->end() |
|
||||||
->end() |
|
||||||
->arrayNode('customize') |
|
||||||
->addDefaultsIfNotSet() |
|
||||||
->children() |
|
||||||
->scalarNode('variables_file')->end() |
|
||||||
->scalarNode('bootstrap_output') |
|
||||||
->defaultValue('%kernel.root_dir%/Resources/less/bootstrap.less') |
|
||||||
->end() |
|
||||||
->scalarNode('bootstrap_template') |
|
||||||
->defaultValue('BraincraftedBootstrapBundle:Bootstrap:bootstrap.less.twig') |
|
||||||
->end() |
|
||||||
->end() |
|
||||||
->end() |
|
||||||
->arrayNode('auto_configure') |
|
||||||
->addDefaultsIfNotSet() |
|
||||||
->children() |
|
||||||
->booleanNode('assetic')->defaultValue(true)->end() |
|
||||||
->booleanNode('twig')->defaultValue(true)->end() |
|
||||||
->booleanNode('knp_menu')->defaultValue(true)->end() |
|
||||||
->booleanNode('knp_paginator')->defaultValue(true)->end() |
|
||||||
->end() |
|
||||||
->end() |
|
||||||
->end(); |
|
||||||
|
|
||||||
return $treeBuilder; |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,40 +0,0 @@ |
|||||||
<?php |
|
||||||
/** |
|
||||||
* This file is part of BraincraftedBootstrapBundle. |
|
||||||
* (c) 2012-2013 by Florian Eckerstorfer |
|
||||||
*/ |
|
||||||
|
|
||||||
namespace Braincrafted\Bundle\BootstrapBundle\Form\Extension; |
|
||||||
|
|
||||||
use Symfony\Component\Form\AbstractTypeExtension; |
|
||||||
use Symfony\Component\Form\FormView; |
|
||||||
use Symfony\Component\Form\FormInterface; |
|
||||||
|
|
||||||
/** |
|
||||||
* TypeSetterExtension |
|
||||||
* |
|
||||||
* @package BraincraftedBootstrapBundle |
|
||||||
* @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 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"; |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,98 +0,0 @@ |
|||||||
<?php |
|
||||||
/** |
|
||||||
* This file is part of BraincraftedBootstrapBundle. |
|
||||||
* (c) 2012-2013 by Florian Eckerstorfer |
|
||||||
*/ |
|
||||||
|
|
||||||
namespace Braincrafted\Bundle\BootstrapBundle\Form\Type; |
|
||||||
|
|
||||||
use Symfony\Component\Form\AbstractType; |
|
||||||
use Symfony\Component\Form\FormView; |
|
||||||
use Symfony\Component\Form\FormInterface; |
|
||||||
use Symfony\Component\OptionsResolver\Options; |
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolverInterface; |
|
||||||
|
|
||||||
/** |
|
||||||
* BootstrapCollectionType |
|
||||||
* |
|
||||||
* @package BraincraftedBootstrapBundle |
|
||||||
* @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 |
|
||||||
{ |
|
||||||
/** |
|
||||||
* {@inheritdoc} |
|
||||||
*/ |
|
||||||
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'], |
|
||||||
'sub_widget_col' => $options['sub_widget_col'], |
|
||||||
'button_col' => $options['button_col'], |
|
||||||
'prototype_name' => $options['prototype_name'] |
|
||||||
) |
|
||||||
); |
|
||||||
|
|
||||||
if (false === $view->vars['allow_delete']) { |
|
||||||
$view->vars['sub_widget_col'] += $view->vars['button_col']; |
|
||||||
} |
|
||||||
|
|
||||||
if ($form->getConfig()->hasAttribute('prototype')) { |
|
||||||
$view->vars['prototype'] = $form->getConfig()->getAttribute('prototype')->createView($view); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* {@inheritDoc} |
|
||||||
*/ |
|
||||||
public function setDefaultOptions(OptionsResolverInterface $resolver) |
|
||||||
{ |
|
||||||
$optionsNormalizer = function (Options $options, $value) { |
|
||||||
// @codeCoverageIgnoreStart |
|
||||||
$value['block_name'] = 'entry'; |
|
||||||
|
|
||||||
return $value; |
|
||||||
// @codeCoverageIgnoreEnd |
|
||||||
}; |
|
||||||
|
|
||||||
$resolver->setDefaults(array( |
|
||||||
'allow_add' => false, |
|
||||||
'allow_delete' => false, |
|
||||||
'prototype' => true, |
|
||||||
'prototype_name' => '__name__', |
|
||||||
'type' => 'text', |
|
||||||
'add_button_text' => 'Add', |
|
||||||
'delete_button_text' => 'Delete', |
|
||||||
'sub_widget_col' => 10, |
|
||||||
'button_col' => 2, |
|
||||||
'options' => array(), |
|
||||||
)); |
|
||||||
|
|
||||||
$resolver->setNormalizers(array('options' => $optionsNormalizer)); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* {@inheritDoc} |
|
||||||
*/ |
|
||||||
public function getParent() |
|
||||||
{ |
|
||||||
return 'collection'; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* {@inheritDoc} |
|
||||||
*/ |
|
||||||
public function getName() |
|
||||||
{ |
|
||||||
return 'bootstrap_collection'; |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,97 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
namespace Braincrafted\Bundle\BootstrapBundle\Form\Type; |
|
||||||
|
|
||||||
use Symfony\Component\Form\AbstractType; |
|
||||||
use Symfony\Component\Form\Button; |
|
||||||
use Symfony\Component\Form\ButtonBuilder; |
|
||||||
use Symfony\Component\Form\FormBuilderInterface; |
|
||||||
use Symfony\Component\Form\FormInterface; |
|
||||||
use Symfony\Component\Form\FormView; |
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolverInterface; |
|
||||||
|
|
||||||
/** |
|
||||||
* Class FormActionsType |
|
||||||
* |
|
||||||
* Adds support for form actions, printing buttons in a single line, and correctly offset. |
|
||||||
* |
|
||||||
* @package Braincrafted\Bundle\BootstrapBundle\Form\Type |
|
||||||
* |
|
||||||
* @author Rafael Dohms <code@doh.ms> |
|
||||||
*/ |
|
||||||
class FormActionsType extends AbstractType |
|
||||||
{ |
|
||||||
/** |
|
||||||
* {@inheritdoc} |
|
||||||
*/ |
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options) |
|
||||||
{ |
|
||||||
foreach ($options['buttons'] as $name => $config) { |
|
||||||
$this->addButton($builder, $name, $config); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* {@inheritdoc} |
|
||||||
* |
|
||||||
* @param FormView $view |
|
||||||
* @param FormInterface $form |
|
||||||
* @param array $options |
|
||||||
*/ |
|
||||||
public function buildView(FormView $view, FormInterface $form, array $options) |
|
||||||
{ |
|
||||||
if ($form->count() == 0) { |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
array_map(array($this, 'validateButton'), $form->all()); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Adds a button |
|
||||||
* |
|
||||||
* @param FormBuilderInterface $builder |
|
||||||
* @param $name |
|
||||||
* @param $config |
|
||||||
* @throws \InvalidArgumentException |
|
||||||
* @return ButtonBuilder |
|
||||||
*/ |
|
||||||
protected function addButton($builder, $name, $config) |
|
||||||
{ |
|
||||||
$options = (isset($config['options']))? $config['options'] : array(); |
|
||||||
$builder->add($name, $config['type'], $options); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Validates if child is a Button |
|
||||||
* |
|
||||||
* @param FormInterface $field |
|
||||||
* @throws \InvalidArgumentException |
|
||||||
*/ |
|
||||||
protected function validateButton(FormInterface $field) |
|
||||||
{ |
|
||||||
if (!$field instanceof Button) { |
|
||||||
throw new \InvalidArgumentException("Children of FormActionsType must be instances of the Button class"); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* {@inheritdoc} |
|
||||||
*/ |
|
||||||
public function setDefaultOptions(OptionsResolverInterface $resolver) |
|
||||||
{ |
|
||||||
$resolver->setDefaults(array( |
|
||||||
'buttons' => array(), |
|
||||||
'options' => array(), |
|
||||||
'mapped' => false, |
|
||||||
)); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* {@inheritdoc} |
|
||||||
*/ |
|
||||||
public function getName() |
|
||||||
{ |
|
||||||
return 'form_actions'; |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,105 +0,0 @@ |
|||||||
<?php |
|
||||||
/** |
|
||||||
* This file is part of BraincraftedBootstrapBundle. |
|
||||||
* (c) 2012-2013 by Florian Eckerstorfer |
|
||||||
*/ |
|
||||||
|
|
||||||
namespace Braincrafted\Bundle\BootstrapBundle\Form\Type; |
|
||||||
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type\MoneyType as BaseMoneyType; |
|
||||||
use Symfony\Component\Form\FormInterface; |
|
||||||
use Symfony\Component\Form\FormView; |
|
||||||
|
|
||||||
/** |
|
||||||
* MoneyType |
|
||||||
* |
|
||||||
* @package BraincraftedBootstrapBundle |
|
||||||
* @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 |
|
||||||
{ |
|
||||||
/** |
|
||||||
* {@inheritdoc} |
|
||||||
*/ |
|
||||||
public function buildView(FormView $view, FormInterface $form, array $options) |
|
||||||
{ |
|
||||||
$view->vars['money_pattern'] = self::getPattern($options['currency']); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* {@inheritdoc} |
|
||||||
*/ |
|
||||||
public function getName() |
|
||||||
{ |
|
||||||
return 'money'; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Returns the pattern for this locale |
|
||||||
* |
|
||||||
* 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) |
|
||||||
{ |
|
||||||
if (!$currency) { |
|
||||||
return '{{ widget }}'; |
|
||||||
} |
|
||||||
|
|
||||||
$locale = \Locale::getDefault(); |
|
||||||
|
|
||||||
if (!isset(self::$patterns[$locale])) { |
|
||||||
self::$patterns[$locale] = array(); |
|
||||||
} |
|
||||||
|
|
||||||
if (!isset(self::$patterns[$locale][$currency])) { |
|
||||||
$format = new \NumberFormatter($locale, \NumberFormatter::CURRENCY); |
|
||||||
$pattern = $format->formatCurrency('123', $currency); |
|
||||||
|
|
||||||
// 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 |
|
||||||
); |
|
||||||
|
|
||||||
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 }}'; |
|
||||||
} |
|
||||||
|
|
||||||
// @codeCoverageIgnoreStart |
|
||||||
return '{{ widget }}'; |
|
||||||
// @codeCoverageIgnoreEnd |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,9 +0,0 @@ |
|||||||
The MIT License (MIT) |
|
||||||
|
|
||||||
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: |
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
||||||
@ -1,217 +0,0 @@ |
|||||||
[BraincraftedBootstrapBundle](http://bootstrap.braincrafted.com) |
|
||||||
================= |
|
||||||
|
|
||||||
BraincraftedBootstrapBundle helps you integrate [Bootstrap](http://getbootstrap.com) in your [Symfony2](http://symfony.com) project. |
|
||||||
|
|
||||||
[](http://travis-ci.org/braincrafted/bootstrap-bundle) |
|
||||||
[](https://scrutinizer-ci.com/g/braincrafted/bootstrap-bundle/) |
|
||||||
[](https://scrutinizer-ci.com/g/braincrafted/bootstrap-bundle/) |
|
||||||
|
|
||||||
[](https://packagist.org/packages/braincrafted/bootstrap-bundle) |
|
||||||
[](https://packagist.org/packages/braincrafted/bootstrap-bundle) |
|
||||||
|
|
||||||
Developed by [Florian Eckerstorfer](http://florian.ec) and many amazing [contributors](https://github.com/braincrafted/bootstrap-bundle/contributors). |
|
||||||
|
|
||||||
|
|
||||||
Installation |
|
||||||
------------ |
|
||||||
|
|
||||||
First you need to add `braincrafted/bootstrap-bundle` to `composer.json`: |
|
||||||
|
|
||||||
```json |
|
||||||
{ |
|
||||||
"require": { |
|
||||||
"braincrafted/bootstrap-bundle": "dev-master" |
|
||||||
} |
|
||||||
} |
|
||||||
``` |
|
||||||
|
|
||||||
Please note that `dev-master` points to the latest release. If you want to use the latest development version please use `dev-develop`. Of course you can also use an explicit version number, e.g., `2.0.*`. |
|
||||||
|
|
||||||
You also have to add `BraincraftedBootstrapBundle` to your `AppKernel.php`: |
|
||||||
|
|
||||||
```php |
|
||||||
// app/AppKernel.php |
|
||||||
//... |
|
||||||
class AppKernel extends Kernel |
|
||||||
{ |
|
||||||
//... |
|
||||||
public function registerBundles() |
|
||||||
{ |
|
||||||
$bundles = array( |
|
||||||
... |
|
||||||
new Braincrafted\Bundle\BootstrapBundle\BraincraftedBootstrapBundle() |
|
||||||
); |
|
||||||
//... |
|
||||||
|
|
||||||
return $bundles; |
|
||||||
} |
|
||||||
//... |
|
||||||
} |
|
||||||
``` |
|
||||||
Additionally you have to install Bootstrap and jQuery as dependencies and configure Assetic to compile the LESS files. You can find more information in the [Getting Started](http://bootstrap.braincrafted.com/getting-started.html) section of the documentation. |
|
||||||
|
|
||||||
|
|
||||||
Compatibility |
|
||||||
------------- |
|
||||||
|
|
||||||
This bundle has two main dependencies, Symfony and Bootstrap. The following table shows which version of BraincraftedBootstrapBundle is compatible with which version of Symfony and Bootstrap. |
|
||||||
|
|
||||||
<table> |
|
||||||
<thead> |
|
||||||
<tr> |
|
||||||
<th>BootstrapBundle</th> |
|
||||||
<th>Symfony</th> |
|
||||||
<th>Bootstrap</th> |
|
||||||
<th>jQuery</th> |
|
||||||
</tr> |
|
||||||
</thead> |
|
||||||
<tbody> |
|
||||||
<tr> |
|
||||||
<td><strong>v1.3.*</strong></td> |
|
||||||
<td>v2.2.*</td> |
|
||||||
<td>v2.3.*</td> |
|
||||||
<td>v1.9.*</td> |
|
||||||
</tr> |
|
||||||
<tr> |
|
||||||
<td><strong>v1.4.*</strong></td> |
|
||||||
<td>v2.2.*</td> |
|
||||||
<td>v2.3.*</td> |
|
||||||
<td>v1.9.*</td> |
|
||||||
</tr> |
|
||||||
<tr> |
|
||||||
<td><strong>v1.5.*</strong></td> |
|
||||||
<td>v2.2.*</td> |
|
||||||
<td>v2.3.*</td> |
|
||||||
<td>v1.9.*</td> |
|
||||||
</tr> |
|
||||||
<tr> |
|
||||||
<td><strong>v2.0.*</strong></td> |
|
||||||
<td>v2.3.*<br>v2.4.*</td> |
|
||||||
<td>v3.0.*<br>v3.1.*</td> |
|
||||||
<td>v1.10.*<br>v1.11.*</td> |
|
||||||
</tr> |
|
||||||
</tbody> |
|
||||||
</table> |
|
||||||
|
|
||||||
|
|
||||||
Changelog |
|
||||||
--------- |
|
||||||
|
|
||||||
### Version 2.0.1 (3 April 2014) |
|
||||||
|
|
||||||
- #168 Removed CSS class `row` from form-group |
|
||||||
- #182 Added support for form actions (row with multiple buttons) (by [rdohms](https://github.com/rdohms)) |
|
||||||
- #187 Made default button class changable (by [sandello-alkr](https://github.com/sandello-alkr)) |
|
||||||
- #188 Added icons to form buttons (by [mvrhov](https://github.com/mvrhov)) |
|
||||||
- #190 Added support for stacked tabs (by [aur1mas](https://github.com/aur1mas)) |
|
||||||
- #192 Added method to reset flash bag (by [JulienRamel](https://github.com/JulienRamel)) |
|
||||||
- #196 Removed CSS class `nav` from child elements (by [dylanschoenmakers](https://github.com/dylanschoenmakers)) |
|
||||||
- #198 Added parsing of icons in prepend and append input groups (by [yvh](https://github.com/yvh)) |
|
||||||
- Fixed `file` form type (by [hsz](https://github.com/hsz)) |
|
||||||
|
|
||||||
### Version 2.0.0-alpha1 |
|
||||||
|
|
||||||
- Updated to Symfony v2.3.6 |
|
||||||
- Updated to Bootstrap v3.0.1 |
|
||||||
- Updated to jQuery v1.10.2 |
|
||||||
- Remove `include_responsive` option because Bootstrap 3.0 no longer has a non responsive version |
|
||||||
- Added `boostrap_money` form type that uses Bootstraps prepend or append style to display the currency |
|
||||||
- `percent` form type uses Bootstraps append style to display the percent sign |
|
||||||
- Changed namespace back to `Braincrafted\Bundle\BootstrapBundle` |
|
||||||
- Support for custom `variables.less` |
|
||||||
- Several Twig filters are now functions |
|
||||||
- Added `bootstrap_set_style` and `bootstrap_get_style` Twig functions to globally set the style of forms |
|
||||||
- Added command to generate custom `bootstrap.less` file |
|
||||||
- Added command to copy icon fonts into `web/` directory |
|
||||||
- Added Composer script handler for copying icon fonts |
|
||||||
- Pagination now supports disabled links |
|
||||||
- Added Twig function `badge` |
|
||||||
- Removed Twig filters `badge_*` (Bootstrap v3.0 does not include multiply badge styles) |
|
||||||
- Twig filters `label_*` are now Twig functions |
|
||||||
- Twig filter `icon` is now a Twig function |
|
||||||
- Added `braincrafted_collection` form type |
|
||||||
|
|
||||||
#### Version 2.0.0-alpha2 |
|
||||||
|
|
||||||
- Fixed compatibility with PHP 5.3 (Fixes [#111](https://github.com/braincrafted/bootstrap-bundle/issues/111)) |
|
||||||
- Renamed `braincrafted_collection` to `bootstrap_collection` |
|
||||||
- `widget_col`, `label_col` and `simple_col` can be defined in form builder (Fixes [#113](https://github.com/braincrafted/bootstrap-bundle/issues/113)) |
|
||||||
- Add support for input groups |
|
||||||
- Fix bug with inline forms when no placeholder is defined |
|
||||||
|
|
||||||
#### Version 2.0.0-alpha3 |
|
||||||
|
|
||||||
- Fixed configuration of input groups in form builder (Fixes [#115](https://github.com/braincrafted/bootstrap-bundle/issues/115)) |
|
||||||
- Fixed trailing slash in `braincrafted_bootstrap.output_dir` option |
|
||||||
- Fixed undefined variable in pagination template |
|
||||||
- Better tested |
|
||||||
|
|
||||||
#### Version 2.0.0-beta1 |
|
||||||
|
|
||||||
- Fixed duplicate `div.form-group` in `choice_widget_expanded` (Fixes [#131](https://github.com/braincrafted/bootstrap-bundle/issues/131)) |
|
||||||
- Use correct assets when not using LESS (Fixes [#128](https://github.com/braincrafted/bootstrap-bundle/issues/128)) [[amcgowanca](https://github.com/amcgowanca)] |
|
||||||
- Add `col_size` option to set the column size for form widgets (Fixes [#127](https://github.com/braincrafted/bootstrap-bundle/issues/127)) |
|
||||||
- Add support for `simple_col` options in `textarea_widget` |
|
||||||
- Renamed views |
|
||||||
- Add error messages in `checkbox_row` and `radio_widget` (Fixes [#118](https://github.com/braincrafted/bootstrap-bundle/issues/118)) |
|
||||||
|
|
||||||
#### Version 2.0.0-beta2 (9 December 2013) |
|
||||||
|
|
||||||
- #133: Fix `label_col`, `widget_col`, `col_size` and `simple_col` options in collection widgets |
|
||||||
- #136: Added translation to `bootstrap_collection` widget |
|
||||||
- #137: Removed `cssrewrite` filter from default Assetic configuration |
|
||||||
- #139: Fix JavaScript for nested `bootstrap_collection` widgets (by [wizart](https://github.com/wizart)) |
|
||||||
- #140: Improved dependency list in `composer.json` (by [hason](https://github.com/hason)) |
|
||||||
- #142: Added translation for help block and error messages |
|
||||||
- #143: Added translation to flash message template (by [rdohms](https://github.com/rdohms)) |
|
||||||
- #144: Fix class attribute for checkbox widget (by [squaye85](https://github.com/squaye85)) |
|
||||||
- #145: Added possibility to style global error messages |
|
||||||
- Renamed `customize_variables` configuration option into `customize` |
|
||||||
|
|
||||||
#### Version 2.0.0-stable (2 January 2014) |
|
||||||
|
|
||||||
- #152: Add form name attribute (by [nonlux](https://github.com/nonlux)) |
|
||||||
- #154: Fix Bootstrap Collection form type for nested types |
|
||||||
- #155: Use `braincrafted_bootstrap.output_dir` option when installing icon font |
|
||||||
- #52: Add class option for pagination |
|
||||||
- #148: Add `label_col` and `widget_col` option for the whole form (by [florianeckerstorfer](https://github.com/florianeckerstorfer) and [dirkluijk](https://github.com/dirkluijk)) |
|
||||||
- #156: Add support for error messages with parameters (by [thanosp](https://github.com/thanosp)) |
|
||||||
- #157: Use print shiv instead of standard shiv (by [mvrhov](https://github.com/mvrhov)) |
|
||||||
- #161: Set `style` option in FormBuilder |
|
||||||
- #162: Set depth of navigation. |
|
||||||
|
|
||||||
### Version 1.5.0 |
|
||||||
|
|
||||||
- Works with new Bootstrap repository `twbs/bootstrap` |
|
||||||
- Basic support for Bootstrap v3.0 |
|
||||||
- Allow override options in menus |
|
||||||
- Extend from base form layout |
|
||||||
- Fixed problems with removing elemnts in JavaScript collection form type |
|
||||||
- Various other bugfixes |
|
||||||
|
|
||||||
### Version 1.4.0 |
|
||||||
|
|
||||||
- Changed namespace to `Bc\Bundle\BootstrapBundle` |
|
||||||
- Automatically configure Twig |
|
||||||
- Automatically configure KnpMenuBundle |
|
||||||
- Automatically configure KnpPaginatorBundle |
|
||||||
- Automatically configure Assetic |
|
||||||
- Improved layout of error messages in compound fields |
|
||||||
- Improved code style (usage of PHP_CodeSniffer and PHPMD) |
|
||||||
- Support for `data-prototype` option in collection fields |
|
||||||
- Helper and template for flash messages |
|
||||||
|
|
||||||
### Version 1.2.0 |
|
||||||
|
|
||||||
- Added support for Assetic |
|
||||||
|
|
||||||
|
|
||||||
License |
|
||||||
------- |
|
||||||
|
|
||||||
- The bundle is licensed under the [MIT License](http://opensource.org/licenses/MIT) |
|
||||||
- The CSS and Javascript from the Twitter Bootstrap are licensed under the [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0) |
|
||||||
|
|
||||||
|
|
||||||
[](https://bitdeli.com/free "Bitdeli Badge") |
|
||||||
@ -1,32 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8" ?> |
|
||||||
<container xmlns="http://symfony.com/schema/dic/services" |
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
||||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> |
|
||||||
|
|
||||||
<parameters> |
|
||||||
<parameter key="braincrafted_bootstrap.form.type.collection.class">Braincrafted\Bundle\BootstrapBundle\Form\Type\BootstrapCollectionType</parameter> |
|
||||||
<parameter key="braincrafted_bootstrap.form.type.money.class">Braincrafted\Bundle\BootstrapBundle\Form\Type\MoneyType</parameter> |
|
||||||
<parameter key="braincrafted_bootstrap.form.type.form_actions.class">Braincrafted\Bundle\BootstrapBundle\Form\Type\FormActionsType</parameter> |
|
||||||
<parameter key="braincrafted_bootstrap.form.extension.typesetter_extension.class">Braincrafted\Bundle\BootstrapBundle\Form\Extension\TypeSetterExtension</parameter> |
|
||||||
</parameters> |
|
||||||
|
|
||||||
<services> |
|
||||||
|
|
||||||
<service id="braincrafted_bootstrap.form.type.collection" class="%braincrafted_bootstrap.form.type.collection.class%"> |
|
||||||
<tag name="form.type" alias="bootstrap_collection" /> |
|
||||||
</service> |
|
||||||
|
|
||||||
<service id="braincrafted_bootstrap.form.type.money" class="%braincrafted_bootstrap.form.type.money.class%"> |
|
||||||
<tag name="form.type" alias="money" /> |
|
||||||
</service> |
|
||||||
|
|
||||||
<service id="braincrafted_bootstrap.form.type.form_actions" class="%braincrafted_bootstrap.form.type.form_actions.class%"> |
|
||||||
<tag name="form.type" alias="form_actions" /> |
|
||||||
</service> |
|
||||||
|
|
||||||
<service id="braincrafted_bootstrap.form.extension.typesetter_extension" class="%braincrafted_bootstrap.form.extension.typesetter_extension.class%"> |
|
||||||
<tag name="form.type_extension" alias="form" /> |
|
||||||
</service> |
|
||||||
|
|
||||||
</services> |
|
||||||
</container> |
|
||||||
@ -1,17 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8" ?> |
|
||||||
<container xmlns="http://symfony.com/schema/dic/services" |
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
||||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> |
|
||||||
|
|
||||||
<parameters> |
|
||||||
<parameter key="braincrafted_bootstrap.flash.class">Braincrafted\Bundle\BootstrapBundle\Session\FlashMessage</parameter> |
|
||||||
</parameters> |
|
||||||
|
|
||||||
<services> |
|
||||||
|
|
||||||
<service id="braincrafted_bootstrap.flash" class="%braincrafted_bootstrap.flash.class%"> |
|
||||||
<argument type="service" id="session" /> |
|
||||||
</service> |
|
||||||
|
|
||||||
</services> |
|
||||||
</container> |
|
||||||
@ -1,32 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8" ?> |
|
||||||
<container xmlns="http://symfony.com/schema/dic/services" |
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
||||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> |
|
||||||
|
|
||||||
<parameters> |
|
||||||
<parameter key="braincrafted_bootstrap.twig.icon_extension.class">Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapIconExtension</parameter> |
|
||||||
<parameter key="braincrafted_bootstrap.twig.label_extension.class">Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapLabelExtension</parameter> |
|
||||||
<parameter key="braincrafted_bootstrap.twig.badge_extension.class">Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapBadgeExtension</parameter> |
|
||||||
<parameter key="braincrafted_bootstrap.twig.form_extension.class">Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapFormExtension</parameter> |
|
||||||
</parameters> |
|
||||||
|
|
||||||
<services> |
|
||||||
|
|
||||||
<service id="braincrafted_bootstrap.twig.icon_extension" class="%braincrafted_bootstrap.twig.icon_extension.class%"> |
|
||||||
<tag name="twig.extension" /> |
|
||||||
</service> |
|
||||||
|
|
||||||
<service id="braincrafted_bootstrap.twig.label_extension" class="%braincrafted_bootstrap.twig.label_extension.class%"> |
|
||||||
<tag name="twig.extension" /> |
|
||||||
</service> |
|
||||||
|
|
||||||
<service id="braincrafted_bootstrap.twig.badge_extension" class="%braincrafted_bootstrap.twig.badge_extension.class%"> |
|
||||||
<tag name="twig.extension" /> |
|
||||||
</service> |
|
||||||
|
|
||||||
<service id="braincrafted_bootstrap.twig.form_extension" class="%braincrafted_bootstrap.twig.form_extension.class%"> |
|
||||||
<tag name="twig.extension" /> |
|
||||||
</service> |
|
||||||
|
|
||||||
</services> |
|
||||||
</container> |
|
||||||
@ -1,123 +0,0 @@ |
|||||||
/* ========================================================== |
|
||||||
* bc-bootstrap-collection.js |
|
||||||
* http://bootstrap.braincrafted.com
|
|
||||||
* ========================================================== |
|
||||||
* Copyright 2013 Florian Eckerstorfer |
|
||||||
* |
|
||||||
* ========================================================== */ |
|
||||||
|
|
||||||
|
|
||||||
!function ($) { |
|
||||||
|
|
||||||
"use strict"; // jshint ;_;
|
|
||||||
|
|
||||||
/* COLLECTION CLASS DEFINITION |
|
||||||
* ====================== */ |
|
||||||
|
|
||||||
var addField = '[data-addfield="collection"]', |
|
||||||
removeField = '[data-removefield="collection"]', |
|
||||||
CollectionAdd = function (el) { |
|
||||||
$(el).on('click', addField, this.addField); |
|
||||||
}, |
|
||||||
CollectionRemove = function (el) { |
|
||||||
$(el).on('click', removeField, this.removeField); |
|
||||||
} |
|
||||||
; |
|
||||||
|
|
||||||
CollectionAdd.prototype.addField = function (e) { |
|
||||||
var $this = $(this), |
|
||||||
selector = $this.attr('data-collection'), |
|
||||||
prototypeName = $this.attr('data-prototype-name') |
|
||||||
; |
|
||||||
|
|
||||||
e && e.preventDefault(); |
|
||||||
|
|
||||||
var collection = $('#'+selector), |
|
||||||
list = collection.find('> ul'), |
|
||||||
count = list.find('li').size() |
|
||||||
; |
|
||||||
|
|
||||||
var newWidget = collection.attr('data-prototype'); |
|
||||||
|
|
||||||
// Check if an element with this ID already exists.
|
|
||||||
// If it does, increase the count by one and try again
|
|
||||||
var newName = newWidget.match(/id="(.*?)"/); |
|
||||||
var re = new RegExp(prototypeName, "g"); |
|
||||||
while ($('#' + newName[1].replace(re, count)).size() > 0) { |
|
||||||
count++; |
|
||||||
} |
|
||||||
newWidget = newWidget.replace(re, count); |
|
||||||
newWidget = newWidget.replace(/__id__/g, newName[1].replace(re, count)); |
|
||||||
var newLi = $('<li></li>').html(newWidget); |
|
||||||
newLi.appendTo(list); |
|
||||||
}; |
|
||||||
|
|
||||||
CollectionRemove.prototype.removeField = function (e) { |
|
||||||
var $this = $(this), |
|
||||||
selector = $this.attr('data-field') |
|
||||||
; |
|
||||||
|
|
||||||
e && e.preventDefault(); |
|
||||||
|
|
||||||
var listElement = $this.closest('li').remove(); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/* COLLECTION PLUGIN DEFINITION |
|
||||||
* ======================= */ |
|
||||||
|
|
||||||
var oldAdd = $.fn.addField; |
|
||||||
var oldRemove = $.fn.removeField; |
|
||||||
|
|
||||||
$.fn.addField = function (option) { |
|
||||||
return this.each(function () { |
|
||||||
var $this = $(this), |
|
||||||
data = $this.data('addfield') |
|
||||||
; |
|
||||||
if (!data) { |
|
||||||
$this.data('addfield', (data = new CollectionAdd(this))); |
|
||||||
} |
|
||||||
if (typeof option == 'string') { |
|
||||||
data[option].call($this); |
|
||||||
} |
|
||||||
}); |
|
||||||
}; |
|
||||||
|
|
||||||
$.fn.removeField = function (option) { |
|
||||||
return this.each(function() { |
|
||||||
var $this = $(this), |
|
||||||
data = $this.data('removefield') |
|
||||||
; |
|
||||||
if (!data) { |
|
||||||
$this.data('removefield', (data = new CollectionRemove(this))); |
|
||||||
} |
|
||||||
if (typeof option == 'string') { |
|
||||||
data[option].call($this); |
|
||||||
} |
|
||||||
}); |
|
||||||
}; |
|
||||||
|
|
||||||
$.fn.addField.Constructor = CollectionAdd; |
|
||||||
$.fn.removeField.Constructor = CollectionRemove; |
|
||||||
|
|
||||||
|
|
||||||
/* COLLECTION NO CONFLICT |
|
||||||
* ================= */ |
|
||||||
|
|
||||||
$.fn.addField.noConflict = function () { |
|
||||||
$.fn.addField = oldAdd; |
|
||||||
return this; |
|
||||||
} |
|
||||||
$.fn.removeField.noConflict = function () { |
|
||||||
$.fn.removeField = oldRemove; |
|
||||||
return this; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/* COLLECTION DATA-API |
|
||||||
* ============== */ |
|
||||||
|
|
||||||
$(document).on('click.addfield.data-api', addField, CollectionAdd.prototype.addField); |
|
||||||
$(document).on('click.removefield.data-api', removeField, CollectionRemove.prototype.removeField); |
|
||||||
|
|
||||||
}(window.jQuery); |
|
||||||
@ -1,70 +0,0 @@ |
|||||||
/** |
|
||||||
* Additional styles for BraincraftedBootstrapBundle |
|
||||||
* (c) 2013 Florian Eckerstorfer (http://braincrafted.com) |
|
||||||
* http://bootstrap.braincrafted.com |
|
||||||
*/ |
|
||||||
|
|
||||||
.bootstrap-time { |
|
||||||
width: 100%; |
|
||||||
select { |
|
||||||
display: inline-block; |
|
||||||
width: auto; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
.bootstrap-date { |
|
||||||
width: 100%; |
|
||||||
select { |
|
||||||
display: inline-block; |
|
||||||
width: auto; |
|
||||||
margin-right: 5px; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
.bootstrap-datetime { |
|
||||||
.bootstrap-time, |
|
||||||
.bootstrap-date { |
|
||||||
display: inline-block; |
|
||||||
width: auto; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
.form-group { |
|
||||||
.bc-collection { |
|
||||||
li + li { |
|
||||||
margin-top: 10px; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
.form-inline { |
|
||||||
.form-group { |
|
||||||
margin-left: 0; |
|
||||||
margin-right: 0; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
.form-horizontal { |
|
||||||
.col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11, .col-lg12 { |
|
||||||
.col-1, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-10, .col-11, .col-12, |
|
||||||
.col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12 { |
|
||||||
padding-left: 0; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
form { |
|
||||||
.has-error { |
|
||||||
ul.help-block { |
|
||||||
list-style: none; |
|
||||||
padding-left: 0; |
|
||||||
} |
|
||||||
} |
|
||||||
.alert { |
|
||||||
ul { |
|
||||||
list-style: none; |
|
||||||
padding-left: 0; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,59 +0,0 @@ |
|||||||
/*! |
|
||||||
* Bootstrap v3.0.0 |
|
||||||
* |
|
||||||
* Copyright 2013 Twitter, Inc |
|
||||||
* Licensed under the Apache License v2.0 |
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0 |
|
||||||
* |
|
||||||
* Designed and built with all the love in the world by @mdo and @fat. |
|
||||||
*/ |
|
||||||
|
|
||||||
// Core variables and mixins |
|
||||||
@import "{{ variables_file }}"; |
|
||||||
@import "{{ assets_dir }}less/mixins.less"; |
|
||||||
|
|
||||||
// Reset |
|
||||||
@import "{{ assets_dir }}less/normalize.less"; |
|
||||||
@import "{{ assets_dir }}less/print.less"; |
|
||||||
|
|
||||||
// Core CSS |
|
||||||
@import "{{ assets_dir }}less/scaffolding.less"; |
|
||||||
@import "{{ assets_dir }}less/type.less"; |
|
||||||
@import "{{ assets_dir }}less/code.less"; |
|
||||||
@import "{{ assets_dir }}less/grid.less"; |
|
||||||
@import "{{ assets_dir }}less/tables.less"; |
|
||||||
@import "{{ assets_dir }}less/forms.less"; |
|
||||||
@import "{{ assets_dir }}less/buttons.less"; |
|
||||||
|
|
||||||
// Components |
|
||||||
@import "{{ assets_dir }}less/component-animations.less"; |
|
||||||
@import "{{ assets_dir }}less/glyphicons.less"; |
|
||||||
@import "{{ assets_dir }}less/dropdowns.less"; |
|
||||||
@import "{{ assets_dir }}less/button-groups.less"; |
|
||||||
@import "{{ assets_dir }}less/input-groups.less"; |
|
||||||
@import "{{ assets_dir }}less/navs.less"; |
|
||||||
@import "{{ assets_dir }}less/navbar.less"; |
|
||||||
@import "{{ assets_dir }}less/breadcrumbs.less"; |
|
||||||
@import "{{ assets_dir }}less/pagination.less"; |
|
||||||
@import "{{ assets_dir }}less/pager.less"; |
|
||||||
@import "{{ assets_dir }}less/labels.less"; |
|
||||||
@import "{{ assets_dir }}less/badges.less"; |
|
||||||
@import "{{ assets_dir }}less/jumbotron.less"; |
|
||||||
@import "{{ assets_dir }}less/thumbnails.less"; |
|
||||||
@import "{{ assets_dir }}less/alerts.less"; |
|
||||||
@import "{{ assets_dir }}less/progress-bars.less"; |
|
||||||
@import "{{ assets_dir }}less/media.less"; |
|
||||||
@import "{{ assets_dir }}less/list-group.less"; |
|
||||||
@import "{{ assets_dir }}less/panels.less"; |
|
||||||
@import "{{ assets_dir }}less/wells.less"; |
|
||||||
@import "{{ assets_dir }}less/close.less"; |
|
||||||
|
|
||||||
// Components w/ JavaScript |
|
||||||
@import "{{ assets_dir }}less/modals.less"; |
|
||||||
@import "{{ assets_dir }}less/tooltip.less"; |
|
||||||
@import "{{ assets_dir }}less/popovers.less"; |
|
||||||
@import "{{ assets_dir }}less/carousel.less"; |
|
||||||
|
|
||||||
// Utility classes |
|
||||||
@import "{{ assets_dir }}less/utilities.less"; |
|
||||||
@import "{{ assets_dir }}less/responsive-utilities.less"; |
|
||||||
@ -1,864 +0,0 @@ |
|||||||
{% use "form_div_layout.html.twig" %} |
|
||||||
|
|
||||||
{# Widgets #} |
|
||||||
|
|
||||||
{% block form_widget %} |
|
||||||
{% spaceless %} |
|
||||||
{% if compound %} |
|
||||||
{{ block('form_widget_compound') }} |
|
||||||
{% else %} |
|
||||||
{{ block('form_widget_simple') }} |
|
||||||
{% endif %} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock form_widget %} |
|
||||||
|
|
||||||
{% block form_widget_simple %} |
|
||||||
{% spaceless %} |
|
||||||
{% set style = style|default(bootstrap_get_style()) %} |
|
||||||
{% set col_size = col_size|default(bootstrap_get_col_size()) %} |
|
||||||
|
|
||||||
{% if simple_col is not defined and bootstrap_get_simple_col() %} |
|
||||||
{% set simple_col = bootstrap_get_simple_col() %} |
|
||||||
{% endif %} |
|
||||||
{% if attr.simple_col is defined and attr.simple_col is not empty %} |
|
||||||
{% set simple_col = attr.simple_col %} |
|
||||||
{% endif %} |
|
||||||
{% if attr.col_size is defined and attr.col_size is not empty %} |
|
||||||
{% set col_size = attr.col_size %} |
|
||||||
{% endif %} |
|
||||||
{% if attr.style is defined and attr.style is not empty %} |
|
||||||
{% set style = attr.style %} |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
{% if simple_col is defined and simple_col %} |
|
||||||
<div class="col-{{ col_size }}-{{ simple_col }}"> |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
{% set type = type|default('text') %} |
|
||||||
{% set attr = attr|merge({ 'class': (attr.class|default('') ~ ' form-control')|trim }) %} |
|
||||||
|
|
||||||
{% if style == 'inline' and (attr.placeholder is not defined or attr.placeholder is empty) %} |
|
||||||
{% if label is empty %} |
|
||||||
{% set attr = attr|merge({ 'placeholder': name|humanize }) %} |
|
||||||
{% else %} |
|
||||||
{% set attr = attr|merge({ 'placeholder': label}) %} |
|
||||||
{% endif %} |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
<input type="{{ type }}" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %}> |
|
||||||
|
|
||||||
{% if simple_col is defined %} |
|
||||||
</div> |
|
||||||
{% endif %} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock form_widget_simple %} |
|
||||||
|
|
||||||
{% block form_widget_compound %} |
|
||||||
{% spaceless %} |
|
||||||
<div {{ block('widget_container_attributes') }}> |
|
||||||
{% if form.parent is empty %} |
|
||||||
{{ block('global_form_errors') }} |
|
||||||
{% endif %} |
|
||||||
{{ block('form_rows') }} |
|
||||||
{{ form_rest(form) }} |
|
||||||
</div> |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock form_widget_compound %} |
|
||||||
|
|
||||||
{% block collection_widget %} |
|
||||||
{% spaceless %} |
|
||||||
{% if prototype is defined %} |
|
||||||
{% set attr = attr|merge({'data-prototype': form_row(prototype) }) %} |
|
||||||
{% endif %} |
|
||||||
{{ block('form_widget') }} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock collection_widget %} |
|
||||||
|
|
||||||
{% block bootstrap_collection_widget %} |
|
||||||
{% spaceless %} |
|
||||||
{% if prototype is defined %} |
|
||||||
{% set prototype_vars = {} %} |
|
||||||
{% if style is defined %} |
|
||||||
{% set prototype_vars = prototype_vars|merge({'style': style}) %} |
|
||||||
{% endif %} |
|
||||||
{% set prototype_html = '<div class="col-xs-' ~ form.vars.sub_widget_col ~ '">' ~ form_widget(prototype, prototype_vars) ~ '</div>' %} |
|
||||||
{% if form.vars.allow_delete %} |
|
||||||
{% set prototype_html = prototype_html ~ '<div class="col-xs-' ~ form.vars.button_col ~ '"><a href="#" class="btn btn-danger btn-small" data-removefield="collection" data-field="__id__">' ~ form.vars.delete_button_text|trans({}, translation_domain) ~ '</a></div>' %} |
|
||||||
{% endif %} |
|
||||||
{% set prototype_html = '<div class="row">' ~ prototype_html ~ '</div>' %} |
|
||||||
|
|
||||||
{% set attr = attr|merge({'data-prototype': prototype_html }) %} |
|
||||||
{% set attr = attr|merge({'data-prototype-name': prototype_name }) %} |
|
||||||
{% endif %} |
|
||||||
<div {{ block('widget_container_attributes') }}> |
|
||||||
<ul class="bc-collection list-unstyled"> |
|
||||||
{% for field in form %} |
|
||||||
<li> |
|
||||||
<div class="row"> |
|
||||||
<div class="col-xs-{{ form.vars.sub_widget_col }}"> |
|
||||||
{{ form_widget(field) }} |
|
||||||
{{ form_errors(field) }} |
|
||||||
</div> |
|
||||||
{% if form.vars.allow_delete %} |
|
||||||
<div class="col-xs-{{ form.vars.button_col }}"> |
|
||||||
<a href="#" class="btn btn-danger btn-small" data-removefield="collection" data-field="{{ field.vars.id }}">{{ form.vars.delete_button_text|trans({}, translation_domain) }}</a> |
|
||||||
</div> |
|
||||||
{% endif %} |
|
||||||
</div> |
|
||||||
</li> |
|
||||||
{% endfor %} |
|
||||||
</ul> |
|
||||||
{% if form.vars.allow_add %} |
|
||||||
<a href="#" class="btn btn-primary btn-small" data-addfield="collection" data-collection="{{ form.vars.id }}" data-prototype-name="{{ prototype_name }}">{{ form.vars.add_button_text|trans({}, translation_domain) }}</a> |
|
||||||
{% endif %} |
|
||||||
</div> |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock bootstrap_collection_widget %} |
|
||||||
|
|
||||||
{% block textarea_widget %} |
|
||||||
{% spaceless %} |
|
||||||
{% set col_size = col_size|default(bootstrap_get_col_size()) %} |
|
||||||
|
|
||||||
{% if attr.simple_col is defined and attr.simple_col is not empty %} |
|
||||||
{% set simple_col = attr.simple_col %} |
|
||||||
{% endif %} |
|
||||||
{% if attr.col_size is defined and attr.col_size is not empty %} |
|
||||||
{% set col_size = attr.col_size %} |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
{% if simple_col is defined %} |
|
||||||
<div class="col-{{ col_size }}-{{ simple_col }}"> |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
{% set attr = attr|merge({ 'class': (attr.class|default('') ~ ' form-control')|trim }) %} |
|
||||||
|
|
||||||
<textarea {{ block('widget_attributes') }}>{{ value }}</textarea> |
|
||||||
|
|
||||||
{% if simple_col is defined %} |
|
||||||
</div> |
|
||||||
{% endif %} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock textarea_widget %} |
|
||||||
|
|
||||||
{% block file_widget %} |
|
||||||
{% spaceless %} |
|
||||||
{% set col_size = col_size|default(bootstrap_get_col_size()) %} |
|
||||||
|
|
||||||
{% if attr.simple_col is defined and attr.simple_col is not empty %} |
|
||||||
{% set simple_col = attr.simple_col %} |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
{% if attr.col_size is defined and attr.col_size is not empty %} |
|
||||||
{% set col_size = attr.col_size %} |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
{% if simple_col is defined %} |
|
||||||
<div class="col-{{ col_size }}-{{ simple_col }}"> |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
<input type="file" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %}> |
|
||||||
|
|
||||||
{% if simple_col is defined %} |
|
||||||
</div> |
|
||||||
{% endif %} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock file_widget %} |
|
||||||
|
|
||||||
{% block choice_widget %} |
|
||||||
{% spaceless %} |
|
||||||
{% if expanded %} |
|
||||||
{{ block('choice_widget_expanded') }} |
|
||||||
{% else %} |
|
||||||
{{ block('choice_widget_collapsed') }} |
|
||||||
{% endif %} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock choice_widget %} |
|
||||||
|
|
||||||
{% block choice_widget_expanded %} |
|
||||||
{% spaceless %} |
|
||||||
<div {{ block('widget_container_attributes') }}> |
|
||||||
{% for child in form %} |
|
||||||
{% if form.multiple is defined %} |
|
||||||
{{ checkbox_row(child, { 'no_form_group': true }) }} |
|
||||||
{% else %} |
|
||||||
{{ radio_row(child, { 'no_form_group': true }) }} |
|
||||||
{% endif %} |
|
||||||
{% endfor %} |
|
||||||
</div> |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock choice_widget_expanded %} |
|
||||||
|
|
||||||
{% block choice_widget_collapsed %} |
|
||||||
{% spaceless %} |
|
||||||
{% set attr = attr|merge({ 'class': (attr.class|default('') ~ ' form-control')|trim }) %} |
|
||||||
|
|
||||||
<select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple"{% endif %}> |
|
||||||
{% if empty_value is not none %} |
|
||||||
<option {% if required %} disabled="disabled"{% if value is empty %} selected="selected"{% endif %}{% else %} value=""{% endif %}>{{ empty_value|trans({}, translation_domain) }}</option> |
|
||||||
{% endif %} |
|
||||||
{% if preferred_choices|length > 0 %} |
|
||||||
{% set options = preferred_choices %} |
|
||||||
{{ block('choice_widget_options') }} |
|
||||||
{% if choices|length > 0 and separator is not none %} |
|
||||||
<option disabled="disabled">{{ separator }}</option> |
|
||||||
{% endif %} |
|
||||||
{% endif %} |
|
||||||
{% set options = choices %} |
|
||||||
{{ block('choice_widget_options') }} |
|
||||||
</select> |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock choice_widget_collapsed %} |
|
||||||
|
|
||||||
{% block choice_widget_options %} |
|
||||||
{% spaceless %} |
|
||||||
{% for group_label, choice in options %} |
|
||||||
{% if choice is iterable %} |
|
||||||
<optgroup label="{{ group_label|trans({}, translation_domain) }}"> |
|
||||||
{% set options = choice %} |
|
||||||
{{ block('choice_widget_options') }} |
|
||||||
</optgroup> |
|
||||||
{% else %} |
|
||||||
<option value="{{ choice.value }}"{% if choice is selectedchoice(value) %} selected="selected"{% endif %}>{{ choice.label|trans({}, translation_domain) }}</option> |
|
||||||
{% endif %} |
|
||||||
{% endfor %} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock choice_widget_options %} |
|
||||||
|
|
||||||
{% block checkbox_row %} |
|
||||||
{% spaceless %} |
|
||||||
{% set style = style|default(bootstrap_get_style()) %} |
|
||||||
{% set col_size = col_size|default(bootstrap_get_col_size()) %} |
|
||||||
|
|
||||||
{% if attr.label_col is defined and attr.label_col is not empty %} |
|
||||||
{% set label_col = attr.label_col %} |
|
||||||
{% endif %} |
|
||||||
{% if attr.widget_col is defined and attr.widget_col is not empty %} |
|
||||||
{% set widget_col = attr.widget_col %} |
|
||||||
{% endif %} |
|
||||||
{% if attr.col_size is defined and attr.col_size is not empty %} |
|
||||||
{% set col_size = attr.col_size %} |
|
||||||
{% endif %} |
|
||||||
{% if attr.style is defined and attr.style is not empty %} |
|
||||||
{% set style = attr.style %} |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
{% set class = '' %} |
|
||||||
{% if align_with_widget is defined or attr.align_with_widget is defined %} |
|
||||||
{% set widget_col = widget_col|default(bootstrap_get_widget_col()) %} |
|
||||||
{% set label_col = label_col|default(bootstrap_get_label_col()) %} |
|
||||||
{% set class = 'col-' ~ col_size ~ '-' ~ widget_col ~ ' col-' ~ col_size ~ '-offset-' ~ label_col %} |
|
||||||
<div class="form-group {% if not form.vars.valid %} has-error{% endif %}"> |
|
||||||
<div class="{{ class }}"> |
|
||||||
{% elseif no_form_group is not defined or no_form_group == false %} |
|
||||||
<div class="form-group{% if not form.vars.valid %} has-error{% endif %}"> |
|
||||||
{% endif %} |
|
||||||
<div class="checkbox"> |
|
||||||
{% if label is not sameas(false) %} |
|
||||||
{% if not compound %} |
|
||||||
{% set label_attr = label_attr|merge({'for': id}) %} |
|
||||||
{% endif %} |
|
||||||
{% if required %} |
|
||||||
{% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %} |
|
||||||
{% endif %} |
|
||||||
{% if label is empty %} |
|
||||||
{% set label = name|humanize %} |
|
||||||
{% endif %} |
|
||||||
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}> |
|
||||||
{{ block('checkbox_widget') }} |
|
||||||
{{ label|trans({}, translation_domain) }} |
|
||||||
</label> |
|
||||||
{% else %} |
|
||||||
{{ block('checkbox_widget') }} |
|
||||||
{% endif %} |
|
||||||
{{ form_errors(form) }} |
|
||||||
</div> |
|
||||||
{% if align_with_widget is defined or attr.align_with_widget is defined %} |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
{% elseif no_form_group is not defined or no_form_group == false %} |
|
||||||
</div> |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
{% if style == 'inline' %} {% endif %} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock checkbox_row %} |
|
||||||
|
|
||||||
{% block radio_row %} |
|
||||||
{% spaceless %} |
|
||||||
{% set class = '' %} |
|
||||||
|
|
||||||
{% set col_size = col_size|default(bootstrap_get_col_size()) %} |
|
||||||
|
|
||||||
{% if attr.label_col is defined and attr.label_col is not empty %} |
|
||||||
{% set label_col = attr.label_col %} |
|
||||||
{% endif %} |
|
||||||
{% if attr.widget_col is defined and attr.widget_col is not empty %} |
|
||||||
{% set widget_col = attr.widget_col %} |
|
||||||
{% endif %} |
|
||||||
{% if attr.col_size is defined and attr.col_size is not empty %} |
|
||||||
{% set col_size = attr.col_size %} |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
{% if align_with_widget is defined or attr.align_with_widget is defined %} |
|
||||||
{% set widget_col = widget_col|default(bootstrap_get_widget_col()) %} |
|
||||||
{% set label_col = label_col|default(bootstrap_get_label_col()) %} |
|
||||||
{% set class = ' col-'~ col_size ~ '-' ~ widget_col ~ ' col-' ~ col_size ~ '-offset-' ~ label_col %} |
|
||||||
<div class="form-group {% if not form.vars.valid %} has-error{% endif %}"> |
|
||||||
<div class="{{ class }}"> |
|
||||||
{% elseif no_form_group is not defined or no_form_group == false %} |
|
||||||
<div class="form-group{% if not form.vars.valid %} has-error{% endif %}"> |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
<div class="radio"> |
|
||||||
{% if label is not sameas(false) %} |
|
||||||
{% if not compound %} |
|
||||||
{% set label_attr = label_attr|merge({'for': id}) %} |
|
||||||
{% endif %} |
|
||||||
{% if required %} |
|
||||||
{% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %} |
|
||||||
{% endif %} |
|
||||||
{% if label is empty %} |
|
||||||
{% set label = name|humanize %} |
|
||||||
{% endif %} |
|
||||||
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}> |
|
||||||
{{ block('radio_widget') }} |
|
||||||
{{ label|trans({}, translation_domain) }} |
|
||||||
</label> |
|
||||||
{% else %} |
|
||||||
{{ block('radio_widget') }} |
|
||||||
{% endif %} |
|
||||||
{{ form_errors(form) }} |
|
||||||
</div> |
|
||||||
{% if align_with_widget is defined or attr.align_with_widget is defined %} |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
{% elseif no_form_group is not defined or no_form_group == false %} |
|
||||||
</div> |
|
||||||
{% endif %} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock radio_row %} |
|
||||||
|
|
||||||
{% block checkbox_widget %} |
|
||||||
{% spaceless %} |
|
||||||
<input type="checkbox" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} /> |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock checkbox_widget %} |
|
||||||
|
|
||||||
{% block radio_widget %} |
|
||||||
{% spaceless %} |
|
||||||
<input type="radio" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} /> |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock radio_widget %} |
|
||||||
|
|
||||||
{% block datetime_widget %} |
|
||||||
{% spaceless %} |
|
||||||
{% if widget == 'single_text' %} |
|
||||||
{{ block('form_widget_simple') }} |
|
||||||
{% else %} |
|
||||||
{% set attr = attr|merge({ 'class': 'bootstrap-datetime' }) %} |
|
||||||
<div {{ block('widget_container_attributes') }}> |
|
||||||
{{ form_widget(form.date) }} |
|
||||||
{{ form_widget(form.time) }} |
|
||||||
{{ form_errors(form.date) }} |
|
||||||
{{ form_errors(form.time) }} |
|
||||||
</div> |
|
||||||
{% endif %} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock datetime_widget %} |
|
||||||
|
|
||||||
{% block date_widget %} |
|
||||||
{% spaceless %} |
|
||||||
{% if widget == 'single_text' %} |
|
||||||
{{ block('form_widget_simple') }} |
|
||||||
{% else %} |
|
||||||
{% set attr = attr|merge({ 'class': 'bootstrap-date' }) %} |
|
||||||
<div {{ block('widget_container_attributes') }}> |
|
||||||
{{ date_pattern|replace({ |
|
||||||
'{{ year }}': form_widget(form.year), |
|
||||||
'{{ month }}': form_widget(form.month), |
|
||||||
'{{ day }}': form_widget(form.day), |
|
||||||
})|raw }} |
|
||||||
</div> |
|
||||||
{% endif %} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock date_widget %} |
|
||||||
|
|
||||||
{% block time_widget %} |
|
||||||
{% spaceless %} |
|
||||||
{% if widget == 'single_text' %} |
|
||||||
{{ block('form_widget_simple') }} |
|
||||||
{% else %} |
|
||||||
{% set vars = widget == 'text' ? { 'attr': { 'size': 1 }} : {} %} |
|
||||||
{% set attr = attr|merge({ 'class': 'bootstrap-time' }) %} |
|
||||||
<div {{ block('widget_container_attributes') }}> |
|
||||||
{{ form_widget(form.hour, vars) }} |
|
||||||
{% if with_minutes %}:{{ form_widget(form.minute, vars) }}{% endif %} |
|
||||||
{% if with_seconds %}:{{ form_widget(form.second, vars) }}{% endif %} |
|
||||||
</div> |
|
||||||
{% endif %} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock time_widget %} |
|
||||||
|
|
||||||
{% block number_widget %} |
|
||||||
{% spaceless %} |
|
||||||
{# type="number" doesn't work with floats #} |
|
||||||
{% set type = type|default('text') %} |
|
||||||
{{ block('form_widget_simple') }} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock number_widget %} |
|
||||||
|
|
||||||
{% block integer_widget %} |
|
||||||
{% spaceless %} |
|
||||||
{% set type = type|default('number') %} |
|
||||||
{{ block('form_widget_simple') }} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock integer_widget %} |
|
||||||
|
|
||||||
{% block money_widget %} |
|
||||||
{% spaceless %} |
|
||||||
<div class="input-group"> |
|
||||||
{{ money_pattern|replace({ |
|
||||||
'{{ widget }}': block('form_widget_simple'), |
|
||||||
'{{ tag_start }}': '<span class="input-group-addon">', |
|
||||||
'{{ tag_end }}': '</span>' |
|
||||||
})|raw }} |
|
||||||
</div> |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock money_widget %} |
|
||||||
|
|
||||||
{% block url_widget %} |
|
||||||
{% spaceless %} |
|
||||||
{% set type = type|default('url') %} |
|
||||||
{{ block('form_widget_simple') }} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock url_widget %} |
|
||||||
|
|
||||||
{% block search_widget %} |
|
||||||
{% spaceless %} |
|
||||||
{% set type = type|default('search') %} |
|
||||||
{{ block('form_widget_simple') }} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock search_widget %} |
|
||||||
|
|
||||||
{% block percent_widget %} |
|
||||||
{% spaceless %} |
|
||||||
{% set type = type|default('text') %} |
|
||||||
<div class="input-group"> |
|
||||||
{{ block('form_widget_simple') }} |
|
||||||
<span class="input-group-addon">%</span> |
|
||||||
</div> |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock percent_widget %} |
|
||||||
|
|
||||||
{% block password_widget %} |
|
||||||
{% spaceless %} |
|
||||||
{% set type = type|default('password') %} |
|
||||||
{{ block('form_widget_simple') }} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock password_widget %} |
|
||||||
|
|
||||||
{% block hidden_widget %} |
|
||||||
{% spaceless %} |
|
||||||
{% set type = type|default('hidden') %} |
|
||||||
{{ block('form_widget_simple') }} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock hidden_widget %} |
|
||||||
|
|
||||||
{% block email_widget %} |
|
||||||
{% spaceless %} |
|
||||||
{% set type = type|default('email') %} |
|
||||||
{{ block('form_widget_simple') }} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock email_widget %} |
|
||||||
|
|
||||||
{% block button_widget %} |
|
||||||
{% spaceless %} |
|
||||||
{% if label is empty %} |
|
||||||
{% set label = name|humanize %} |
|
||||||
{% endif %} |
|
||||||
{% if type is defined and type == 'submit' %} |
|
||||||
{% set attr = attr|merge({ 'class': (attr.class|default('') ~ ' btn btn-'~attr.type|default('primary'))|trim }) %} |
|
||||||
{% else %} |
|
||||||
{% set attr = attr|merge({ 'class': (attr.class|default('') ~ ' btn btn-'~attr.type|default('default'))|trim }) %} |
|
||||||
{% endif %} |
|
||||||
<button type="{{ type|default('button') }}" {{ block('button_attributes') }}>{% if attr.icon is defined and attr.icon != '' %}{{ icon(attr.icon) }}{% endif %}{{ label|trans({}, translation_domain) }}</button> |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock button_widget %} |
|
||||||
|
|
||||||
{% block submit_widget %} |
|
||||||
{% spaceless %} |
|
||||||
{% set type = type|default('submit') %} |
|
||||||
{{ block('button_widget') }} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock submit_widget %} |
|
||||||
|
|
||||||
{% block reset_widget %} |
|
||||||
{% spaceless %} |
|
||||||
{% set type = type|default('reset') %} |
|
||||||
{{ block('button_widget') }} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock reset_widget %} |
|
||||||
|
|
||||||
{% block form_actions_widget %} |
|
||||||
{% for button in form.children %} |
|
||||||
{{ form_widget(button) }} {# this needs to be here due to https://github.com/twbs/bootstrap/issues/3245 #} |
|
||||||
{% endfor %} |
|
||||||
{% endblock %} |
|
||||||
|
|
||||||
{# Labels #} |
|
||||||
|
|
||||||
{% block form_label %} |
|
||||||
{% spaceless %} |
|
||||||
{% set col_size = col_size|default(bootstrap_get_col_size()) %} |
|
||||||
|
|
||||||
{% if attr.label_col is defined and attr.label_col is not empty %} |
|
||||||
{% set label_col = attr.label_col %} |
|
||||||
{% endif %} |
|
||||||
{% if attr.widget_col is defined and attr.widget_col is not empty %} |
|
||||||
{% set widget_col = attr.widget_col %} |
|
||||||
{% endif %} |
|
||||||
{% if attr.col_size is defined and attr.col_size is not empty %} |
|
||||||
{% set col_size = attr.col_size %} |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
{% if label is not sameas(false) %} |
|
||||||
{% set style = style|default(bootstrap_get_style()) %} |
|
||||||
{% set label_col = label_col|default(bootstrap_get_label_col()) %} |
|
||||||
|
|
||||||
{% if attr.style is defined and attr.style is not empty %} |
|
||||||
{% set style = attr.style %} |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
{% set label_attr = label_attr|merge({ 'class': (label_attr.class|default('') ~ ' control-label')|trim }) %} |
|
||||||
{% if style == 'horizontal' %} |
|
||||||
{% set label_attr = label_attr|merge({ 'class': (label_attr.class|default('') ~ ' col-' ~ col_size ~ '-' ~ label_col)|trim }) %} |
|
||||||
{% elseif style == 'inline' %} |
|
||||||
{% set label_attr = label_attr|merge({ 'class': (label_attr.class|default('') ~ ' sr-only')|trim }) %} |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
{% if not compound %} |
|
||||||
{% set label_attr = label_attr|merge({'for': id}) %} |
|
||||||
{% endif %} |
|
||||||
{% if required %} |
|
||||||
{% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %} |
|
||||||
{% endif %} |
|
||||||
{% if label is empty %} |
|
||||||
{% set label = name|humanize %} |
|
||||||
{% endif %} |
|
||||||
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>{{ label|trans({}, translation_domain) }}</label> |
|
||||||
{% endif %} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock form_label %} |
|
||||||
|
|
||||||
{% block button_label %}{% endblock %} |
|
||||||
|
|
||||||
{# Rows #} |
|
||||||
|
|
||||||
{% block repeated_row %} |
|
||||||
{% spaceless %} |
|
||||||
{# |
|
||||||
No need to render the errors here, as all errors are mapped |
|
||||||
to the first child (see RepeatedTypeValidatorExtension). |
|
||||||
#} |
|
||||||
{{ block('form_rows') }} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock repeated_row %} |
|
||||||
|
|
||||||
{% block form_row %} |
|
||||||
{% spaceless %} |
|
||||||
{% set style = style|default(bootstrap_get_style()) %} |
|
||||||
{% set col_size = col_size|default(bootstrap_get_col_size()) %} |
|
||||||
|
|
||||||
{% if attr.label_col is defined and attr.label_col is not empty %} |
|
||||||
{% set label_col = attr.label_col %} |
|
||||||
{% endif %} |
|
||||||
{% if attr.widget_col is defined and attr.widget_col is not empty %} |
|
||||||
{% set widget_col = attr.widget_col %} |
|
||||||
{% endif %} |
|
||||||
{% if attr.col_size is defined and attr.col_size is not empty %} |
|
||||||
{% set col_size = attr.col_size %} |
|
||||||
{% endif %} |
|
||||||
{% if attr.style is defined and attr.style is not empty %} |
|
||||||
{% set style = attr.style %} |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
{% set label_col = label_col|default(bootstrap_get_label_col()) %} |
|
||||||
{% set widget_col = widget_col|default(bootstrap_get_widget_col()) %} |
|
||||||
|
|
||||||
<div class="form-group{% if not form.vars.valid %} has-error{% endif %}"> |
|
||||||
{% if style == 'horizontal' %} |
|
||||||
{{ form_label(form) }} |
|
||||||
<div class="col-{{ col_size }}-{{ widget_col }}"> |
|
||||||
{{ block('form_input_group') }} |
|
||||||
{{ block('form_help') }} |
|
||||||
{{ form_errors(form) }} |
|
||||||
</div> |
|
||||||
{% else %} |
|
||||||
{{ form_label(form) }} |
|
||||||
{{ block('form_input_group') }} |
|
||||||
{{ block('form_help') }} |
|
||||||
{{ form_errors(form) }} |
|
||||||
{% endif %} |
|
||||||
</div> |
|
||||||
|
|
||||||
{% if style == 'inline' %} {% endif %} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock form_row %} |
|
||||||
|
|
||||||
{% block form_input_group %} |
|
||||||
{% spaceless %} |
|
||||||
{% if attr.input_group is defined and attr.input_group is not empty %} |
|
||||||
{% set input_group = attr.input_group %} |
|
||||||
{% endif %} |
|
||||||
{% set input_group = input_group|default({}) %} |
|
||||||
{% if input_group is not empty %} |
|
||||||
{% set ig_size_class = '' %} |
|
||||||
{% if input_group.size is defined and input_group.size == 'large' %} |
|
||||||
{% set ig_size_class = ' input-group-lg' %} |
|
||||||
{% endif %} |
|
||||||
{% if input_group.size is defined and input_group.size == 'small' %} |
|
||||||
{% set ig_size_class = ' input-group-sm' %} |
|
||||||
{% endif %} |
|
||||||
<div class="input-group{{ ig_size_class }}"> |
|
||||||
{% if input_group.prepend is defined and input_group.prepend is not empty %} |
|
||||||
<span class="input-group-addon">{{ input_group.prepend|raw|parse_icons }}</span> |
|
||||||
{% endif %} |
|
||||||
{{ form_widget(form) }} |
|
||||||
{% if input_group.append is defined and input_group.append is not empty %} |
|
||||||
<span class="input-group-addon">{{ input_group.append|raw|parse_icons }}</span> |
|
||||||
{% endif %} |
|
||||||
</div> |
|
||||||
{% else %} |
|
||||||
{{ form_widget(form) }} |
|
||||||
{% endif %} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock form_input_group %} |
|
||||||
|
|
||||||
{% block form_help %} |
|
||||||
{% spaceless %} |
|
||||||
{% if attr.help_text is defined and attr.help_text is not empty %} |
|
||||||
{% set help_text = attr.help_text %} |
|
||||||
{% endif %} |
|
||||||
{% set help_text = help_text|default('') %} |
|
||||||
{% if help_text is not empty %} |
|
||||||
<span class="help-block">{{ help_text|trans({}, translation_domain) }}</span> |
|
||||||
{% endif %} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock form_help %} |
|
||||||
|
|
||||||
{% block button_row %} |
|
||||||
{% spaceless %} |
|
||||||
{% set style = style|default(bootstrap_get_style()) %} |
|
||||||
{% set col_size = col_size|default(bootstrap_get_col_size()) %} |
|
||||||
|
|
||||||
{% if attr.label_col is defined and attr.label_col is not empty %} |
|
||||||
{% set label_col = attr.label_col %} |
|
||||||
{% endif %} |
|
||||||
{% if attr.widget_col is defined and attr.widget_col is not empty %} |
|
||||||
{% set widget_col = attr.widget_col %} |
|
||||||
{% endif %} |
|
||||||
{% if attr.col_size is defined and attr.col_size is not empty %} |
|
||||||
{% set col_size = attr.col_size %} |
|
||||||
{% endif %} |
|
||||||
{% if attr.style is defined and attr.style is not empty %} |
|
||||||
{% set style = attr.style %} |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
{% set label_col = label_col|default(bootstrap_get_label_col()) %} |
|
||||||
{% set widget_col = widget_col|default(bootstrap_get_widget_col()) %} |
|
||||||
|
|
||||||
{% if style == 'horizontal' %} |
|
||||||
<div class="form-group"> |
|
||||||
<div class="col-{{ col_size }}-offset-{{ label_col }} col-{{ col_size }}-{{ widget_col }}"> |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
{{ form_widget(form) }} |
|
||||||
|
|
||||||
{% if style == 'horizontal' %} |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
{% endif %} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock button_row %} |
|
||||||
|
|
||||||
{% block hidden_row %} |
|
||||||
{{ form_widget(form) }} |
|
||||||
{% endblock hidden_row %} |
|
||||||
|
|
||||||
{% block form_actions_row %} |
|
||||||
{{ block('button_row') }} |
|
||||||
{% endblock %} |
|
||||||
|
|
||||||
{# Misc #} |
|
||||||
|
|
||||||
{% block form %} |
|
||||||
{% spaceless %} |
|
||||||
{{ form_start(form) }} |
|
||||||
{{ form_widget(form) }} |
|
||||||
{{ form_end(form) }} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock form %} |
|
||||||
|
|
||||||
{% block form_start %} |
|
||||||
{% spaceless %} |
|
||||||
{% set method = method|upper %} |
|
||||||
{% if method in ["GET", "POST"] %} |
|
||||||
{% set form_method = method %} |
|
||||||
{% else %} |
|
||||||
{% set form_method = "POST" %} |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
{% if style is defined %} |
|
||||||
{% set attr = attr|merge({ 'class': (attr.class|default('') ~ ' form-' ~ style)|trim }) %} |
|
||||||
{{ bootstrap_set_style(style) }} |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
{% if col_size is defined %} |
|
||||||
{{ bootstrap_set_col_size(col_size) }} |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
{% if widget_col is defined %} |
|
||||||
{{ bootstrap_set_widget_col(widget_col) }} |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
{% if label_col is defined %} |
|
||||||
{{ bootstrap_set_label_col(label_col) }} |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
{% if simple_col is defined %} |
|
||||||
{{ bootstrap_set_simple_col(simple_col) }} |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
{% if attr.role is not defined or attr.role is empty %} |
|
||||||
{% set attr = attr|merge({ 'role': 'form' }) %} |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
<form name="{{ form.vars.name }}" method="{{ form_method|lower }}" action="{{ action }}"{% for attrname, attrvalue in attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}{% if multipart %} enctype="multipart/form-data"{% endif %}> |
|
||||||
{% if form_method != method %} |
|
||||||
<input type="hidden" name="_method" value="{{ method }}" /> |
|
||||||
{% endif %} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock form_start %} |
|
||||||
|
|
||||||
{% block form_end %} |
|
||||||
{% spaceless %} |
|
||||||
{% if not render_rest is defined or render_rest %} |
|
||||||
{{ form_rest(form) }} |
|
||||||
{% endif %} |
|
||||||
</form> |
|
||||||
{% if bootstrap_get_style() %} |
|
||||||
{{ bootstrap_set_style('') }} |
|
||||||
{% endif %} |
|
||||||
{% if bootstrap_get_col_size() %} |
|
||||||
{{ bootstrap_set_col_size('lg') }} |
|
||||||
{% endif %} |
|
||||||
{% if bootstrap_get_widget_col() %} |
|
||||||
{{ bootstrap_set_widget_col(10) }} |
|
||||||
{% endif %} |
|
||||||
{% if bootstrap_get_label_col() %} |
|
||||||
{{ bootstrap_set_label_col(2) }} |
|
||||||
{% endif %} |
|
||||||
{% if bootstrap_get_simple_col() %} |
|
||||||
{{ bootstrap_set_simple_col(false) }} |
|
||||||
{% endif %} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock form_end %} |
|
||||||
|
|
||||||
{% block form_enctype %} |
|
||||||
{% spaceless %} |
|
||||||
{% if multipart %}enctype="multipart/form-data"{% endif %} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock form_enctype %} |
|
||||||
|
|
||||||
{% block global_form_errors %} |
|
||||||
{% if errors|length > 0 %} |
|
||||||
{% set global_errors = true %} |
|
||||||
{{ block('form_errors') }} |
|
||||||
{% endif %} |
|
||||||
{% endblock global_form_errors %} |
|
||||||
|
|
||||||
{% block form_errors %} |
|
||||||
{% spaceless %} |
|
||||||
{% set global_errors = global_errors|default(false) %} |
|
||||||
{% set style = style|default(bootstrap_get_style()) %} |
|
||||||
|
|
||||||
{% if attr.style is defined and attr.style is not empty %} |
|
||||||
{% set style = attr.style %} |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
{% if errors|length > 0 %} |
|
||||||
{% if global_errors %} |
|
||||||
<div class="alert alert-danger"> |
|
||||||
{% endif %} |
|
||||||
<ul{% if not global_errors %} class="help-block"{% endif %}> |
|
||||||
{% for error in errors %} |
|
||||||
<li>{{ error.message|trans(error.messageParameters, translation_domain) }}</li> |
|
||||||
{% endfor %} |
|
||||||
</ul> |
|
||||||
{% if global_errors == true %} |
|
||||||
</div> |
|
||||||
{% endif %} |
|
||||||
{% endif %} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock form_errors %} |
|
||||||
|
|
||||||
{% block form_rest %} |
|
||||||
{% spaceless %} |
|
||||||
{% for child in form %} |
|
||||||
{% if not child.rendered %} |
|
||||||
{{ form_row(child) }} |
|
||||||
{% endif %} |
|
||||||
{% endfor %} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock form_rest %} |
|
||||||
|
|
||||||
{# Support #} |
|
||||||
|
|
||||||
{% block form_rows %} |
|
||||||
{% spaceless %} |
|
||||||
{% for child in form %} |
|
||||||
{% set childAttr = {} %} |
|
||||||
{% if attr.col_size is defined %} |
|
||||||
{% set childAttr = childAttr|merge({ 'col_size': attr.col_size }) %} |
|
||||||
{% endif %} |
|
||||||
{% if attr.widget_col is defined %} |
|
||||||
{% set childAttr = childAttr|merge({ 'widget_col': attr.widget_col }) %} |
|
||||||
{% endif %} |
|
||||||
{% if attr.label_col is defined %} |
|
||||||
{% set childAttr = childAttr|merge({ 'label_col': attr.label_col }) %} |
|
||||||
{% endif %} |
|
||||||
{% if attr.simple_col is defined %} |
|
||||||
{% set childAttr = childAttr|merge({ 'simple_col': attr.simple_col }) %} |
|
||||||
{% endif %} |
|
||||||
{% if attr.style is defined %} |
|
||||||
{% set childAttr = childAttr|merge({ 'style': attr.style }) %} |
|
||||||
{% endif %} |
|
||||||
{{ form_row(child, childAttr) }} |
|
||||||
{% endfor %} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock form_rows %} |
|
||||||
|
|
||||||
{% block widget_attributes %} |
|
||||||
{% spaceless %} |
|
||||||
id="{{ id }}" name="{{ full_name }}"{% if read_only %} readonly="readonly"{% endif %}{% if disabled %} disabled="disabled"{% endif %}{% if required %} required="required"{% endif %}{% if max_length %} maxlength="{{ max_length }}"{% endif %}{% if pattern %} pattern="{{ pattern }}"{% endif %} |
|
||||||
{% for attrname, attrvalue in attr %}{% if attrname in ['placeholder', 'title'] %}{{ attrname }}="{{ attrvalue|trans({}, translation_domain) }}" {% elseif attrname in ['input_group'] %}{% else %}{{ attrname }}="{{ attrvalue }}" {% endif %}{% endfor %} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock widget_attributes %} |
|
||||||
|
|
||||||
{% block widget_container_attributes %} |
|
||||||
{% spaceless %} |
|
||||||
{% if attr.style is defined and (attr.style == 'inline' or attr.style == 'horizontal') %} |
|
||||||
{% set attr = attr|merge({ 'class': 'form-'~attr.style~attr.class|default('') }) %} |
|
||||||
{% set attr = attr|merge({ 'style': null }) %} |
|
||||||
{% endif %} |
|
||||||
{% if id is not empty %}id="{{ id }}" {% endif %} |
|
||||||
{% for attrname, attrvalue in attr %}{% if attrvalue is not null %}{{ attrname }}="{{ attrvalue }}" {% endif %}{% endfor %} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock widget_container_attributes %} |
|
||||||
|
|
||||||
{% block button_attributes %} |
|
||||||
{% spaceless %} |
|
||||||
id="{{ id }}" name="{{ full_name }}"{% if disabled %} disabled="disabled"{% endif %} |
|
||||||
{% for attrname, attrvalue in attr %}{{ attrname }}="{{ attrvalue }}" {% endfor %} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock button_attributes %} |
|
||||||
@ -1,186 +0,0 @@ |
|||||||
{% macro attributes(attributes) %} |
|
||||||
{% for name, value in attributes %} |
|
||||||
{%- if value is not none and value is not sameas(false) -%} |
|
||||||
{{- ' %s="%s"'|format(name, value is sameas(true) ? name|e : value|e)|raw -}} |
|
||||||
{%- endif -%} |
|
||||||
{%- endfor -%} |
|
||||||
{% endmacro %} |
|
||||||
|
|
||||||
{% block compressed_root %} |
|
||||||
{% spaceless %} |
|
||||||
{{ block('root') }} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock %} |
|
||||||
|
|
||||||
{% block root %} |
|
||||||
{# |
|
||||||
Twitter Bootstrap uses the CSS class "active" to indicate |
|
||||||
the current item, so lets change that. |
|
||||||
#} |
|
||||||
{% set options = options|merge({'currentDepth': 0}) %} |
|
||||||
{% if options.style is defined and options.currentClass is defined and options.currentClass == 'current' %} |
|
||||||
{% set options = options|merge({'currentClass': 'active'}) %} |
|
||||||
{% set options = options|merge({'ancestorClass': 'active'}) %} |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
{% set listAttributes = item.childrenAttributes %} |
|
||||||
{{ block('list') -}} |
|
||||||
{% endblock %} |
|
||||||
|
|
||||||
{% block list %} |
|
||||||
{% if item.hasChildren and options.depth is not sameas(0) and item.displayChildren %} |
|
||||||
{% set listAttributes = listAttributes|merge({'class': listAttributes.class|default('')|trim}) %} |
|
||||||
|
|
||||||
{% set listClass = '' %} |
|
||||||
{% if options.style is defined and options.style == 'tabs' %} |
|
||||||
{% set listClass = 'nav-tabs' %} |
|
||||||
{% elseif options.style is defined and options.style == 'stacked-tabs' %} |
|
||||||
{% set listClass = 'nav-tabs nav-stacked' %} |
|
||||||
{% elseif options.style is defined and options.style == 'justified-tabs' %} |
|
||||||
{% set listClass = 'nav-tabs nav-justified' %} |
|
||||||
{% elseif options.style is defined and options.style == 'pills' %} |
|
||||||
{% set listClass = 'nav-pills' %} |
|
||||||
{% elseif options.style is defined and options.style == 'justified-pills' %} |
|
||||||
{% set listClass = 'nav-pills nav-justified' %} |
|
||||||
{% elseif options.style is defined and options.style == 'stacked-pills' %} |
|
||||||
{% set listClass = 'nav-pills nav-stacked' %} |
|
||||||
{% elseif options.style is defined and options.style == 'list' %} |
|
||||||
{% set listClass = 'nav-list' %} |
|
||||||
{% elseif options.style is defined and options.style == 'navbar' %} |
|
||||||
{% set listClass = 'navbar-nav' %} |
|
||||||
{% elseif options.style is defined and options.style == 'navbar-right' %} |
|
||||||
{% set listClass = 'navbar-nav navbar-right' %} |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
{% if options.pull is defined and options.pull == 'right' %} |
|
||||||
{% set listClass = (listClass|default('') ~ ' pull-right')|trim %} |
|
||||||
{% elseif options.pull is defined and options.pull == 'left' %} |
|
||||||
{% set listClass = (listClass|default('') ~ 'pull-left')|trim %} |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
{% set listClass = (item.parent is null) ? listClass ~ ' nav' : listClass %} |
|
||||||
|
|
||||||
{% set listAttributes = listAttributes|merge({'class': (listAttributes.class|default('') ~ ' ' ~ listClass)|trim}) %} |
|
||||||
|
|
||||||
<ul{{ _self.attributes(listAttributes) }}> |
|
||||||
{{ block('children') }} |
|
||||||
</ul> |
|
||||||
{% endif %} |
|
||||||
{% endblock %} |
|
||||||
|
|
||||||
{% block dropdownList %} |
|
||||||
{% spaceless %} |
|
||||||
{% if item.hasChildren and options.depth is not sameas(0) and ((item.extras.dropdown is not defined and item.displayChildren is sameas(true) or item.extras.dropdown is defined and item.extras.dropdown is sameas(true) and item.displayChildren is sameas(true))) %} |
|
||||||
{% set listAttributes = listAttributes|merge({'class': (listAttributes.class|default('') ~ ' dropdown-menu')|trim}) %} |
|
||||||
<ul{{ _self.attributes(listAttributes) }}> |
|
||||||
{{ block('children') }} |
|
||||||
</ul> |
|
||||||
{% endif %} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock dropdownList %} |
|
||||||
|
|
||||||
{% block listList %} |
|
||||||
{% spaceless %} |
|
||||||
{% if item.hasChildren and options.depth is not sameas(0) and item.displayChildren %} |
|
||||||
{{ block('children') }} |
|
||||||
{% endif %} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock listList %} |
|
||||||
|
|
||||||
{% block children %} |
|
||||||
{# save current variables #} |
|
||||||
{% set currentOptions = options %} |
|
||||||
{% set currentItem = item %} |
|
||||||
{# update the depth for children #} |
|
||||||
{% if options.depth is not none %} |
|
||||||
{% set options = currentOptions|merge({'depth': currentOptions.depth - 1}) %} |
|
||||||
{% endif %} |
|
||||||
{% set options = options|merge({'currentDepth': options.currentDepth + 1}) %} |
|
||||||
{% for item in currentItem.children %} |
|
||||||
{{ block('item') }} |
|
||||||
{% endfor %} |
|
||||||
{# restore current variables #} |
|
||||||
{% set item = currentItem %} |
|
||||||
{% set options = currentOptions %} |
|
||||||
{% endblock %} |
|
||||||
|
|
||||||
{% block item %} |
|
||||||
{% if item.displayed %} |
|
||||||
{# building the class of the item #} |
|
||||||
{%- set classes = item.attribute('class') is not empty ? [item.attribute('class')] : [] %} |
|
||||||
{%- if (matcher is defined and matcher.isCurrent(item)) or (item.current is defined and item.current) %} |
|
||||||
{%- set classes = classes|merge([options.currentClass]) %} |
|
||||||
{%- elseif (matcher is defined and matcher.isAncestor(item, options.depth)) or (item.currentAncestor is defined and item.currentAncestor) %} |
|
||||||
{%- set classes = classes|merge([options.ancestorClass]) %} |
|
||||||
{%- endif %} |
|
||||||
{%- if item.actsLikeFirst %} |
|
||||||
{%- set classes = classes|merge([options.firstClass]) %} |
|
||||||
{%- endif %} |
|
||||||
{%- if item.actsLikeLast %} |
|
||||||
{%- set classes = classes|merge([options.lastClass]) %} |
|
||||||
{%- endif %} |
|
||||||
{%- if item.hasChildren and ((options.style is defined and options.style == 'list') or options.currentDepth is not sameas(1)) %} |
|
||||||
{%- set classes = classes|merge(['nav-header']) %} |
|
||||||
{%- elseif item.hasChildren and options.style is defined and options.style in ['tabs', 'justified-tabs', 'pills', 'justified-pills', 'navbar', 'navbar-right', 'navbar_justified'] and ((item.extras.dropdown is not defined and item.displayChildren is sameas(true) or item.extras.dropdown is defined and item.extras.dropdown is sameas(true) and item.displayChildren is sameas(true))) %} |
|
||||||
{%- set classes = classes|merge(['dropdown']) %} |
|
||||||
{%- endif %} |
|
||||||
|
|
||||||
{%- set attributes = item.attributes %} |
|
||||||
|
|
||||||
{%- if options.style is defined and options.style == 'navbar' and attributes.divider is defined and attributes.divider is not empty and options.currentDepth is sameas(1) %} |
|
||||||
{%- set classes = classes|merge(['divider-vertical']) %} |
|
||||||
{%- elseif attributes.divider is defined and attributes.divider is not empty %} |
|
||||||
{%- set classes = classes|merge(['divider']) %} |
|
||||||
{%- endif %} |
|
||||||
|
|
||||||
{%- if classes is not empty %} |
|
||||||
{%- set attributes = attributes|merge({'class': classes|join(' ')}) %} |
|
||||||
{%- endif %} |
|
||||||
{# displaying the item #} |
|
||||||
<li{{ _self.attributes(attributes) }}> |
|
||||||
{%- if attributes.divider is defined and attributes.divider is not empty %} |
|
||||||
{%- elseif item.hasChildren and options.style is defined and options.style in ['tabs', 'justified-tabs', 'pills', 'justified-pills', 'navbar', 'navbar-right', 'navbar_justified'] and options.currentDepth is sameas(1) and ((item.extras.dropdown is not defined and item.displayChildren is sameas(true) or item.extras.dropdown is defined and item.extras.dropdown is sameas(true) and item.displayChildren is sameas(true))) %} |
|
||||||
{{ block('dropdownElement') }} |
|
||||||
{%- elseif item.hasChildren and options.style is defined and options.style in ['tabs', 'justified-tabs', 'pills', 'justified-pills', 'navbar', 'navbar-right', 'navbar_justified'] and options.currentDepth is sameas(1) and ((item.extras.dropdown is defined and item.extras.dropdown is sameas(false) or item.displayChildren(false) )) %} |
|
||||||
{{ block('linkElement') }} |
|
||||||
{%- elseif item.uri is not empty and ((matcher is defined and not matcher.isCurrent(item)) or options.currentAsLink) %} |
|
||||||
{{ block('linkElement') }} |
|
||||||
{%- elseif item.uri is not empty and ((item.current is defined and not item.current) or options.currentAsLink) %} |
|
||||||
{{ block('linkElement') }} |
|
||||||
{%- else %} |
|
||||||
{{ block('spanElement') }} |
|
||||||
{%- endif %} |
|
||||||
{# render the list of children#} |
|
||||||
{%- set childrenClasses = item.childrenAttribute('class') is not empty ? [item.childrenAttribute('class')] : [] %} |
|
||||||
{%- set childrenClasses = childrenClasses|merge(['menu_level_' ~ item.level]) %} |
|
||||||
{%- set listAttributes = item.childrenAttributes|merge({'class': childrenClasses|join(' ') }) %} |
|
||||||
{%- if item.hasChildren and options.style is defined and (options.style == 'list' or options.currentDepth is not sameas(1)) %} |
|
||||||
{{ block('listList') }} |
|
||||||
{%- elseif item.hasChildren and options.style is defined and options.style in ['tabs', 'justified-tabs', 'pills', 'justified-pills', 'navbar', 'navbar-right', 'navbar_justified'] %} |
|
||||||
{{ block('dropdownList') }} |
|
||||||
{%- else %} |
|
||||||
{{ block('list') }} |
|
||||||
{%- endif %} |
|
||||||
</li> |
|
||||||
{% endif %} |
|
||||||
{% endblock %} |
|
||||||
|
|
||||||
{% block linkElement %}<a href="{{ item.uri }}"{{ _self.attributes(item.linkAttributes) }}>{{ block('label') }}</a>{% endblock %} |
|
||||||
|
|
||||||
{% block dropdownElement %} |
|
||||||
{% spaceless %} |
|
||||||
{% set labelAttributes = item.labelAttributes %} |
|
||||||
{% set labelAttributes = labelAttributes|merge({'class': (labelAttributes.class|default('') ~ ' dropdown-toggle')|trim}) %} |
|
||||||
{% set labelAttributes = labelAttributes|merge({'data-toggle': 'dropdown'}) %} |
|
||||||
<a href="#"{{ _self.attributes(labelAttributes) }}>{{ block('label') }} <b class="caret"></b></a> |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock dropdownElement %} |
|
||||||
|
|
||||||
{% block dividerElement %} |
|
||||||
{% spaceless %} |
|
||||||
{% endspaceless %} |
|
||||||
{% endblock dividerElement %} |
|
||||||
|
|
||||||
{% block spanElement %}<span{{ _self.attributes(item.labelAttributes) }}>{{ block('label') }}</span>{% endblock %} |
|
||||||
|
|
||||||
{% block label %}{% if options.allow_safe_labels and item.getExtra('safe_label', false) %}{{ item.label|raw|parse_icons }}{% else %}{{ item.label|parse_icons }}{% endif %}{% endblock %} |
|
||||||
@ -1,62 +0,0 @@ |
|||||||
{% set class = class|default('') %} |
|
||||||
|
|
||||||
{% if pageCount > 1 %} |
|
||||||
{% if style is defined and style == 'pager' %} |
|
||||||
|
|
||||||
{% set prev_label = prev_label|default('Previous') %} |
|
||||||
{% set next_label = next_label|default('Next') %} |
|
||||||
{% set aligned = aligned|default(false) %} |
|
||||||
|
|
||||||
<ul class="pager{% if class is not empty %} {{ class }}{% endif %}"> |
|
||||||
{% if previous is defined %} |
|
||||||
<li{% if aligned %} class="previous"{% endif %}><a href="{{ path(route, query|merge({(pageParameterName): previous})) }}">{{ prev_label|raw }}</a></li> |
|
||||||
{% else %} |
|
||||||
<li class="disabled{% if aligned %} previous{% endif %}"><span>{{ prev_label|raw }}</span></li> |
|
||||||
{% endif %} |
|
||||||
{% if next is defined %} |
|
||||||
<li{% if aligned %} class="next"{% endif %}><a href="{{ path(route, query|merge({(pageParameterName): next})) }}">{{ next_label|raw }}</a></li> |
|
||||||
{% else %} |
|
||||||
<li class="disabled{% if aligned %} next{% endif %}"><span>{{ next_label|raw }}</span></li> |
|
||||||
{% endif %} |
|
||||||
</ul> |
|
||||||
{% else %} |
|
||||||
|
|
||||||
{% set prev_label = prev_label|default('«') %} |
|
||||||
{% set next_label = next_label|default('»') %} |
|
||||||
|
|
||||||
<ul class="pagination{% if class is not empty %} {{ class }}{% endif %}"> |
|
||||||
{% if first_label is defined and first is defined and current != first %} |
|
||||||
<li><a href="{{ path(route, query|merge({(pageParameterName): first})) }}">{{ first_label|raw }}</a></li> |
|
||||||
{% elseif last_label is defined %} |
|
||||||
<li class="disabled"><span>{{ first_label|raw }}</span></li> |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
{% if previous is defined %} |
|
||||||
<li><a href="{{ path(route, query|merge({(pageParameterName): previous})) }}">{{ prev_label|raw }}</a></li> |
|
||||||
{% else %} |
|
||||||
<li class="disabled"><span>{{ prev_label|raw }}</span></li> |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
{% for page in pagesInRange %} |
|
||||||
{% if page != current %} |
|
||||||
<li><a href="{{ path(route, query|merge({(pageParameterName): page})) }}">{{ page }}</a></li> |
|
||||||
{% else %} |
|
||||||
<li class="active"><span>{{ page }}</span></li> |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
{% endfor %} |
|
||||||
|
|
||||||
{% if next is defined %} |
|
||||||
<li><a href="{{ path(route, query|merge({(pageParameterName): next})) }}">{{ next_label|raw }}</a></li> |
|
||||||
{% else %} |
|
||||||
<li class="disabled"><span>{{ next_label|raw }}</span></li> |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
{% if last_label is defined and last is defined and current != last %} |
|
||||||
<li><a href="{{ path(route, query|merge({(pageParameterName): last})) }}">{{ last_label|raw }}</a></li> |
|
||||||
{% elseif last_label is defined %} |
|
||||||
<li class="disabled"><span>{{ last_label|raw }}</span></li> |
|
||||||
{% endif %} |
|
||||||
</ul> |
|
||||||
{% endif %} |
|
||||||
{% endif %} |
|
||||||
@ -1,34 +0,0 @@ |
|||||||
{% if translation_domain is not defined %} |
|
||||||
{% set translation_domain = null %} |
|
||||||
{% endif %} |
|
||||||
{% if close is not defined %} |
|
||||||
{% set close = false %} |
|
||||||
{% endif %} |
|
||||||
|
|
||||||
{% for flashMessage in app.session.flashbag.get('alert') %} |
|
||||||
<div class="alert alert-warning"> |
|
||||||
{% if close %}<button type="button" class="close" data-dismiss="alert">×</button>{% endif %} |
|
||||||
{{ flashMessage|trans({}, translation_domain) }} |
|
||||||
</div> |
|
||||||
{% endfor %} |
|
||||||
|
|
||||||
{% for flashMessage in app.session.flashbag.get('error') %} |
|
||||||
<div class="alert alert-danger"> |
|
||||||
{% if close %}<button type="button" class="close" data-dismiss="alert">×</button>{% endif %} |
|
||||||
{{ flashMessage|trans({}, translation_domain) }} |
|
||||||
</div> |
|
||||||
{% endfor %} |
|
||||||
|
|
||||||
{% for flashMessage in app.session.flashbag.get('info') %} |
|
||||||
<div class="alert alert-info"> |
|
||||||
{% if close %}<button type="button" class="close" data-dismiss="alert">×</button>{% endif %} |
|
||||||
{{ flashMessage|trans({}, translation_domain) }} |
|
||||||
</div> |
|
||||||
{% endfor %} |
|
||||||
|
|
||||||
{% for flashMessage in app.session.flashbag.get('success') %} |
|
||||||
<div class="alert alert-success"> |
|
||||||
{% if close %}<button type="button" class="close" data-dismiss="alert">×</button>{% endif %} |
|
||||||
{{ flashMessage|trans({}, translation_domain) }} |
|
||||||
</div> |
|
||||||
{% endfor %} |
|
||||||
@ -1,4 +0,0 @@ |
|||||||
<!--[if lt IE 9]> |
|
||||||
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv-printshiv.min.js"></script> |
|
||||||
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script> |
|
||||||
<![endif]--> |
|
||||||
@ -1,27 +0,0 @@ |
|||||||
<!DOCTYPE html> |
|
||||||
<html> |
|
||||||
|
|
||||||
<head> |
|
||||||
|
|
||||||
<title>{% block title %}BraincraftedBootstrapBundle by Florian Eckerstorfer{% endblock title %}</title> |
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|
||||||
|
|
||||||
<!-- Bootstrap --> |
|
||||||
<link href="{{ asset('/css/bootstrap.css') }}" rel="stylesheet" media="screen"> |
|
||||||
|
|
||||||
</head> |
|
||||||
|
|
||||||
<body> |
|
||||||
|
|
||||||
{% block body %}{% endblock body %} |
|
||||||
|
|
||||||
<!-- JavaScript plugins (requires jQuery) --> |
|
||||||
<script src="//code.jquery.com/jquery.js"></script> |
|
||||||
<!-- Include all compiled plugins (below), or include individual files as needed --> |
|
||||||
<script src="{{ asset('/css/bootstrap.js') }}"></script> |
|
||||||
|
|
||||||
<!-- Optionally enable responsive features in IE8 --> |
|
||||||
<script src="js/respond.js"></script> |
|
||||||
|
|
||||||
</body> |
|
||||||
</html> |
|
||||||
@ -1,94 +0,0 @@ |
|||||||
<?php |
|
||||||
/** |
|
||||||
* This file is part of BraincraftedBootstrapBundle. |
|
||||||
* |
|
||||||
* (c) 2012-2013 by Florian Eckerstorfer |
|
||||||
*/ |
|
||||||
|
|
||||||
namespace Braincrafted\Bundle\BootstrapBundle\Session; |
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Session\SessionInterface; |
|
||||||
|
|
||||||
/** |
|
||||||
* FlashMessage |
|
||||||
* |
|
||||||
* @package BraincraftedBootstrapBundle |
|
||||||
* @subpackage Session |
|
||||||
* @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 FlashMessage |
|
||||||
{ |
|
||||||
/** @var SessionInterface */ |
|
||||||
private $session; |
|
||||||
|
|
||||||
/** |
|
||||||
* Constructor. |
|
||||||
* |
|
||||||
* @param SessionInterface $session The session |
|
||||||
*/ |
|
||||||
public function __construct(SessionInterface $session) |
|
||||||
{ |
|
||||||
$this->session = $session; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Sets an alert message. |
|
||||||
* |
|
||||||
* @param string $message The message |
|
||||||
* |
|
||||||
* @return void |
|
||||||
*/ |
|
||||||
public function alert($message) |
|
||||||
{ |
|
||||||
$this->session->getFlashBag()->add('alert', $message); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Sets an error message. |
|
||||||
* |
|
||||||
* @param string $message The message |
|
||||||
* |
|
||||||
* @return void |
|
||||||
*/ |
|
||||||
public function error($message) |
|
||||||
{ |
|
||||||
$this->session->getFlashBag()->add('error', $message); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Sets an info message. |
|
||||||
* |
|
||||||
* @param string $message The message |
|
||||||
* |
|
||||||
* @return void |
|
||||||
*/ |
|
||||||
public function info($message) |
|
||||||
{ |
|
||||||
$this->session->getFlashBag()->add('info', $message); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Sets a success message. |
|
||||||
* |
|
||||||
* @param string $message The message |
|
||||||
* |
|
||||||
* @return void |
|
||||||
*/ |
|
||||||
public function success($message) |
|
||||||
{ |
|
||||||
$this->session->getFlashBag()->add('success', $message); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Resets the flash bag. |
|
||||||
* |
|
||||||
* @return void |
|
||||||
*/ |
|
||||||
public function reset() |
|
||||||
{ |
|
||||||
$this->session->getFlashBag()->clear(); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,130 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
/** |
|
||||||
* This file is part of BraincraftedBootstrapBundle. |
|
||||||
* |
|
||||||
* (c) 2012-2013 by Florian Eckerstorfer |
|
||||||
*/ |
|
||||||
|
|
||||||
namespace Braincrafted\Bundle\BootstrapBundle\Tests\Command; |
|
||||||
|
|
||||||
use \Mockery as m; |
|
||||||
use Symfony\Component\Console\Tester\CommandTester; |
|
||||||
use Symfony\Bundle\FrameworkBundle\Console\Application; |
|
||||||
|
|
||||||
use Braincrafted\Bundle\BootstrapBundle\Command\GenerateCommand; |
|
||||||
|
|
||||||
/** |
|
||||||
* GenerateCommandTest |
|
||||||
* |
|
||||||
* @category Test |
|
||||||
* @package BraincraftedBootstrapBundle |
|
||||||
* @subpackage Command |
|
||||||
* @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 BraincraftedBootstrapBundle |
|
||||||
* @group unit |
|
||||||
*/ |
|
||||||
class GenerateCommandTest extends \PHPUnit_Framework_TestCase |
|
||||||
{ |
|
||||||
public function setUp() |
|
||||||
{ |
|
||||||
$this->twig = m::mock('\Twig_Environment'); |
|
||||||
|
|
||||||
$this->container = m::mock('Symfony\Component\DependencyInjection\ContainerInterface'); |
|
||||||
$this->container->shouldReceive('get')->with('twig')->andReturn($this->twig); |
|
||||||
|
|
||||||
$this->kernel = m::mock('Symfony\Component\HttpKernel\KernelInterface'); |
|
||||||
$this->kernel->shouldReceive('getName')->andReturn('app'); |
|
||||||
$this->kernel->shouldReceive('getEnvironment')->andReturn('prod'); |
|
||||||
$this->kernel->shouldReceive('isDebug')->andReturn(false); |
|
||||||
$this->kernel->shouldReceive('getContainer')->andReturn($this->container); |
|
||||||
} |
|
||||||
|
|
||||||
public function tearDown() |
|
||||||
{ |
|
||||||
if (true === file_exists(sprintf('%s/bootstrap.less', __DIR__))) { |
|
||||||
unlink(sprintf('%s/bootstrap.less', __DIR__)); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Command\GenerateCommand::execute() |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Command\GenerateCommand::executeGenerateBootstrap() |
|
||||||
*/ |
|
||||||
public function testExecute() |
|
||||||
{ |
|
||||||
$this->container |
|
||||||
->shouldReceive('getParameter') |
|
||||||
->with('braincrafted_bootstrap.customize') |
|
||||||
->andReturn(array( |
|
||||||
'variables_file' => __DIR__.'/x/variables.less', |
|
||||||
'bootstrap_output' => __DIR__.'/bootstrap.less', |
|
||||||
'bootstrap_template' => __DIR__.'/bootstrap.html.twig' |
|
||||||
)); |
|
||||||
$this->container->shouldReceive('getParameter')->with('braincrafted_bootstrap.less_filter')->andReturn('less'); |
|
||||||
$this->container->shouldReceive('getParameter')->with('braincrafted_bootstrap.assets_dir')->andReturn(__DIR__); |
|
||||||
|
|
||||||
$this->twig |
|
||||||
->shouldReceive('render') |
|
||||||
->with(__DIR__.'/bootstrap.html.twig', array( |
|
||||||
'variables_file' => './x/variables.less', |
|
||||||
'assets_dir' => '' |
|
||||||
)); |
|
||||||
|
|
||||||
// mock the Kernel or create one depending on your needs |
|
||||||
$application = new Application($this->kernel); |
|
||||||
$application->add(new GenerateCommand()); |
|
||||||
|
|
||||||
$command = $application->find('braincrafted:bootstrap:generate'); |
|
||||||
$commandTester = new CommandTester($command); |
|
||||||
$commandTester->execute(array('command' => $command->getName())); |
|
||||||
|
|
||||||
$this->assertRegExp('/Found custom variables file/', $commandTester->getDisplay()); |
|
||||||
$this->assertRegExp('/bootstrap\.less/', $commandTester->getDisplay()); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Command\GenerateCommand::execute() |
|
||||||
*/ |
|
||||||
public function testExecuteNoVariablesFile() |
|
||||||
{ |
|
||||||
$this->container |
|
||||||
->shouldReceive('getParameter') |
|
||||||
->with('braincrafted_bootstrap.customize') |
|
||||||
->andReturn(array('variables_file' => null)); |
|
||||||
|
|
||||||
// mock the Kernel or create one depending on your needs |
|
||||||
$application = new Application($this->kernel); |
|
||||||
$application->add(new GenerateCommand()); |
|
||||||
|
|
||||||
$command = $application->find('braincrafted:bootstrap:generate'); |
|
||||||
$commandTester = new CommandTester($command); |
|
||||||
$commandTester->execute(array('command' => $command->getName())); |
|
||||||
|
|
||||||
$this->assertRegExp('/Found no custom variables\.less file/', $commandTester->getDisplay()); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Command\GenerateCommand::execute() |
|
||||||
*/ |
|
||||||
public function testExecuteNoLessFilter() |
|
||||||
{ |
|
||||||
$this->container |
|
||||||
->shouldReceive('getParameter') |
|
||||||
->with('braincrafted_bootstrap.customize') |
|
||||||
->andReturn(array('variables_file' => __DIR__.'/x/variables.less')); |
|
||||||
$this->container->shouldReceive('getParameter')->with('braincrafted_bootstrap.less_filter')->andReturn('none'); |
|
||||||
|
|
||||||
// mock the Kernel or create one depending on your needs |
|
||||||
$application = new Application($this->kernel); |
|
||||||
$application->add(new GenerateCommand()); |
|
||||||
|
|
||||||
$command = $application->find('braincrafted:bootstrap:generate'); |
|
||||||
$commandTester = new CommandTester($command); |
|
||||||
$commandTester->execute(array('command' => $command->getName())); |
|
||||||
|
|
||||||
$this->assertRegExp('/configured with "less" or "lessphp"/', $commandTester->getDisplay()); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,138 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
/** |
|
||||||
* This file is part of BraincraftedBootstrapBundle. |
|
||||||
* |
|
||||||
* (c) 2012-2013 by Florian Eckerstorfer |
|
||||||
*/ |
|
||||||
|
|
||||||
namespace Braincrafted\Bundle\BootstrapBundle\Tests\Command; |
|
||||||
|
|
||||||
use \Mockery as m; |
|
||||||
use Symfony\Component\Console\Tester\CommandTester; |
|
||||||
use Symfony\Bundle\FrameworkBundle\Console\Application; |
|
||||||
|
|
||||||
use Braincrafted\Bundle\BootstrapBundle\Command\InstallCommand; |
|
||||||
|
|
||||||
/** |
|
||||||
* InstallCommandTest |
|
||||||
* |
|
||||||
* @category Test |
|
||||||
* @package BraincraftedBootstrapBundle |
|
||||||
* @subpackage Command |
|
||||||
* @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 BraincraftedBootstrapBundle |
|
||||||
* @group unit |
|
||||||
*/ |
|
||||||
class InstallCommandTest extends \PHPUnit_Framework_TestCase |
|
||||||
{ |
|
||||||
public function setUp() |
|
||||||
{ |
|
||||||
$this->container = m::mock('Symfony\Component\DependencyInjection\ContainerInterface'); |
|
||||||
|
|
||||||
$this->kernel = m::mock('Symfony\Component\HttpKernel\KernelInterface'); |
|
||||||
$this->kernel->shouldReceive('getName')->andReturn('app'); |
|
||||||
$this->kernel->shouldReceive('getEnvironment')->andReturn('prod'); |
|
||||||
$this->kernel->shouldReceive('isDebug')->andReturn(false); |
|
||||||
$this->kernel->shouldReceive('getContainer')->andReturn($this->container); |
|
||||||
} |
|
||||||
|
|
||||||
public function tearDown() |
|
||||||
{ |
|
||||||
$file = sprintf('%s/fixtures/web/fonts/font1.txt', __DIR__); |
|
||||||
if (true === file_exists($file)) { |
|
||||||
unlink($file); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Command\InstallCommand::execute() |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Command\InstallCommand::getSrcDir() |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Command\InstallCommand::getDestDir() |
|
||||||
*/ |
|
||||||
public function testExecute() |
|
||||||
{ |
|
||||||
$this->container |
|
||||||
->shouldReceive('getParameter') |
|
||||||
->with('kernel.root_dir') |
|
||||||
->andReturn(__DIR__.'/fixtures/app'); |
|
||||||
$this->container |
|
||||||
->shouldReceive('getParameter') |
|
||||||
->with('braincrafted_bootstrap.assets_dir') |
|
||||||
->andReturn(__DIR__.'/fixtures/vendor/twbs/bootstrap'); |
|
||||||
$this->container |
|
||||||
->shouldReceive('getParameter') |
|
||||||
->with('braincrafted_bootstrap.output_dir') |
|
||||||
->andReturn(''); |
|
||||||
|
|
||||||
// mock the Kernel or create one depending on your needs |
|
||||||
$application = new Application($this->kernel); |
|
||||||
$application->add(new InstallCommand()); |
|
||||||
|
|
||||||
$command = $application->find('braincrafted:bootstrap:install'); |
|
||||||
$commandTester = new CommandTester($command); |
|
||||||
$commandTester->execute(array('command' => $command->getName())); |
|
||||||
|
|
||||||
$this->assertRegExp('/Copied Glyphicon fonts/', $commandTester->getDisplay()); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Command\InstallCommand::execute() |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Command\InstallCommand::getSrcDir() |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Command\InstallCommand::getDestDir() |
|
||||||
*/ |
|
||||||
public function testExecuteSrcNotExists() |
|
||||||
{ |
|
||||||
$this->container |
|
||||||
->shouldReceive('getParameter') |
|
||||||
->with('kernel.root_dir') |
|
||||||
->andReturn(__DIR__.'/fixtures/app'); |
|
||||||
$this->container |
|
||||||
->shouldReceive('getParameter') |
|
||||||
->with('braincrafted_bootstrap.assets_dir') |
|
||||||
->andReturn(__DIR__.'/invalid'); |
|
||||||
$this->container |
|
||||||
->shouldReceive('getParameter') |
|
||||||
->with('braincrafted_bootstrap.output_dir') |
|
||||||
->andReturn(''); |
|
||||||
|
|
||||||
// mock the Kernel or create one depending on your needs |
|
||||||
$application = new Application($this->kernel); |
|
||||||
$application->add(new InstallCommand()); |
|
||||||
|
|
||||||
$command = $application->find('braincrafted:bootstrap:install'); |
|
||||||
$commandTester = new CommandTester($command); |
|
||||||
$commandTester->execute(array('command' => $command->getName())); |
|
||||||
|
|
||||||
$this->assertRegExp('/does not exist/', $commandTester->getDisplay()); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Command\InstallCommand::execute() |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Command\InstallCommand::getSrcDir() |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Command\InstallCommand::getDestDir() |
|
||||||
*/ |
|
||||||
public function testExecuteInvalidDestDirectory() |
|
||||||
{ |
|
||||||
$this->container |
|
||||||
->shouldReceive('getParameter') |
|
||||||
->with('kernel.root_dir') |
|
||||||
->andReturn('/'); |
|
||||||
$this->container |
|
||||||
->shouldReceive('getParameter') |
|
||||||
->with('braincrafted_bootstrap.output_dir') |
|
||||||
->andReturn(''); |
|
||||||
|
|
||||||
// mock the Kernel or create one depending on your needs |
|
||||||
$application = new Application($this->kernel); |
|
||||||
$application->add(new InstallCommand()); |
|
||||||
|
|
||||||
$command = $application->find('braincrafted:bootstrap:install'); |
|
||||||
$commandTester = new CommandTester($command); |
|
||||||
$commandTester->execute(array('command' => $command->getName())); |
|
||||||
|
|
||||||
$this->assertRegExp('/Could not create directory/', $commandTester->getDisplay()); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,54 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
namespace Braincrafted\Bundle\BootstrapBundle\Tests\DependencyInjection; |
|
||||||
|
|
||||||
use Braincrafted\Bundle\BootstrapBundle\DependencyInjection\AsseticConfiguration; |
|
||||||
|
|
||||||
/** |
|
||||||
* AsseticConfigurationTest |
|
||||||
* |
|
||||||
* @group unit |
|
||||||
*/ |
|
||||||
class AsseticConfigurationTest extends \PHPUnit_Framework_TestCase |
|
||||||
{ |
|
||||||
public function setUp() |
|
||||||
{ |
|
||||||
$this->asseticConfig = new AsseticConfiguration; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\DependencyInjection\AsseticConfiguration::build() |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\DependencyInjection\AsseticConfiguration::buildCssWithLess() |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\DependencyInjection\AsseticConfiguration::buildJs() |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\DependencyInjection\AsseticConfiguration::buildJquery() |
|
||||||
*/ |
|
||||||
public function testBuild() |
|
||||||
{ |
|
||||||
$this->asseticConfig->build(array( |
|
||||||
'less_filter' => 'less', |
|
||||||
'assets_dir' => './assets', |
|
||||||
'output_dir' => './web', |
|
||||||
'jquery_path' => './assets/jquery.js', |
|
||||||
'customize' => array( |
|
||||||
'variables_file' => './assets/variables.less', |
|
||||||
'bootstrap_output' => './assets/bootstrap.less' |
|
||||||
) |
|
||||||
)); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\DependencyInjection\AsseticConfiguration::build() |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\DependencyInjection\AsseticConfiguration::buildCssWithoutLess() |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\DependencyInjection\AsseticConfiguration::buildJs() |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\DependencyInjection\AsseticConfiguration::buildJquery() |
|
||||||
*/ |
|
||||||
public function testBuildWithoutLess() |
|
||||||
{ |
|
||||||
$this->asseticConfig->build(array( |
|
||||||
'less_filter' => 'none', |
|
||||||
'assets_dir' => './assets', |
|
||||||
'output_dir' => './web', |
|
||||||
'jquery_path' => './assets/jquery.js' |
|
||||||
)); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,69 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
namespace Braincrafted\Bundle\BootstrapBundle\Tests\DependencyInjection; |
|
||||||
|
|
||||||
use \Mockery as m; |
|
||||||
|
|
||||||
use Braincrafted\Bundle\BootstrapBundle\DependencyInjection\BraincraftedBootstrapExtension; |
|
||||||
|
|
||||||
/** |
|
||||||
* BraincraftedBootstrapExtensionTest |
|
||||||
* |
|
||||||
* @group unit |
|
||||||
*/ |
|
||||||
class BraincraftedBootstrapExtensionTest extends \PHPUnit_Framework_TestCase |
|
||||||
{ |
|
||||||
public function setUp() |
|
||||||
{ |
|
||||||
$this->extension = new BraincraftedBootstrapExtension; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\DependencyInjection\BraincraftedBootstrapExtension::load() |
|
||||||
*/ |
|
||||||
public function testLoad() |
|
||||||
{ |
|
||||||
$bag = m::mock('Symfony\Component\DependencyInjection\ParameterBag\ParameterBag'); |
|
||||||
$bag->shouldReceive('add'); |
|
||||||
|
|
||||||
$container = m::mock('Symfony\Component\DependencyInjection\ContainerBuilder'); |
|
||||||
$container->shouldReceive('hasExtension')->andReturn(false); |
|
||||||
$container->shouldReceive('addResource'); |
|
||||||
$container->shouldReceive('getParameterBag')->andReturn($bag); |
|
||||||
$container->shouldReceive('setDefinition'); |
|
||||||
$container->shouldReceive('setParameter'); |
|
||||||
|
|
||||||
$this->extension->load(array(), $container); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\DependencyInjection\BraincraftedBootstrapExtension::prepend() |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\DependencyInjection\BraincraftedBootstrapExtension::configureAsseticBundle() |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\DependencyInjection\BraincraftedBootstrapExtension::configureTwigBundle() |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\DependencyInjection\BraincraftedBootstrapExtension::configureKnpMenuBundle() |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\DependencyInjection\BraincraftedBootstrapExtension::configureKnpPaginatorBundle() |
|
||||||
*/ |
|
||||||
public function testPrepend() |
|
||||||
{ |
|
||||||
$bundles = array( |
|
||||||
'AsseticBundle' => '', |
|
||||||
'TwigBundle' => '', |
|
||||||
'KnpMenuBundle' => '', |
|
||||||
'KnpPaginatorBundle' => '' |
|
||||||
); |
|
||||||
|
|
||||||
$extensions = array( |
|
||||||
'assetic' => array(), |
|
||||||
'twig' => array(), |
|
||||||
'knp_menu' => array(), |
|
||||||
'knp_paginator' => array() |
|
||||||
); |
|
||||||
$container = m::mock('Symfony\Component\DependencyInjection\ContainerBuilder'); |
|
||||||
$container->shouldReceive('getParameter')->with('kernel.bundles')->andReturn($bundles); |
|
||||||
$container->shouldReceive('getExtensions')->andReturn($extensions); |
|
||||||
$container->shouldReceive('getExtensionConfig')->andReturn(array()); |
|
||||||
$container->shouldReceive('prependExtensionConfig'); |
|
||||||
|
|
||||||
$this->extension->prepend($container); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,47 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
namespace Braincrafted\Bundle\BootstrapBundle\Tests\Form\Extension; |
|
||||||
|
|
||||||
use \Mockery as m; |
|
||||||
|
|
||||||
use Braincrafted\Bundle\BootstrapBundle\Form\Extension\TypeSetterExtension; |
|
||||||
|
|
||||||
/** |
|
||||||
* TypeSetterExtensionTest |
|
||||||
* |
|
||||||
* @group unit |
|
||||||
*/ |
|
||||||
class TypeSetterExtensionTest extends \PHPUnit_Framework_TestCase |
|
||||||
{ |
|
||||||
/** @var TypeSetterExtension */ |
|
||||||
private $extension; |
|
||||||
|
|
||||||
public function setUp() |
|
||||||
{ |
|
||||||
$this->extension = new TypeSetterExtension; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Form\Extension\TypeSetterExtension::buildView() |
|
||||||
*/ |
|
||||||
public function testBuildView() |
|
||||||
{ |
|
||||||
$view = m::mock('Symfony\Component\Form\FormView'); |
|
||||||
$type = m::mock('Symfony\Component\Form\ResolvedFormTypeInterface'); |
|
||||||
$type->shouldReceive('getName')->andReturn('type'); |
|
||||||
$config = m::mock('Symfony\Component\Form\FormConfigInterface'); |
|
||||||
$config->shouldReceive('getType')->andReturn($type); |
|
||||||
$form = m::mock('Symfony\Component\Form\FormInterface'); |
|
||||||
$form->shouldReceive('getConfig')->andReturn($config); |
|
||||||
|
|
||||||
$this->extension->buildView($view, $form, array()); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Form\Extension\TypeSetterExtension::getExtendedType() |
|
||||||
*/ |
|
||||||
public function testGetExtendedType() |
|
||||||
{ |
|
||||||
$this->assertEquals('form', $this->extension->getExtendedType()); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,79 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
namespace Braincrafted\Bundle\BootstrapBundle\Tests\Type; |
|
||||||
|
|
||||||
use \Mockery as m; |
|
||||||
|
|
||||||
use Braincrafted\Bundle\BootstrapBundle\Form\Type\BootstrapCollectionType; |
|
||||||
|
|
||||||
/** |
|
||||||
* BootstrapCollectionTypeTest |
|
||||||
* |
|
||||||
* @group unit |
|
||||||
*/ |
|
||||||
class BootstrapCollectionTypeTest extends \PHPUnit_Framework_TestCase |
|
||||||
{ |
|
||||||
/** @var BootstrapCollectionType */ |
|
||||||
private $type; |
|
||||||
|
|
||||||
public function setUp() |
|
||||||
{ |
|
||||||
$this->type = new BootstrapCollectionType; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Form\Type\BootstrapCollectionType::buildView() |
|
||||||
*/ |
|
||||||
public function testBuildView() |
|
||||||
{ |
|
||||||
$view = m::mock('Symfony\Component\Form\FormView'); |
|
||||||
|
|
||||||
$prototype = m::mock('Symfony\Component\Form\FormInterface'); |
|
||||||
$prototype->shouldReceive('createView')->with($view); |
|
||||||
|
|
||||||
$config = m::mock('Symfony\Component\Form\FormConfigInterface'); |
|
||||||
$config->shouldReceive('hasAttribute')->andReturn(true); |
|
||||||
$config->shouldReceive('getAttribute')->andReturn($prototype); |
|
||||||
|
|
||||||
$form = m::mock('Symfony\Component\Form\FormInterface'); |
|
||||||
$form->shouldReceive('getConfig')->andReturn($config); |
|
||||||
|
|
||||||
$this->type->buildView($view, $form, array( |
|
||||||
'allow_add' => true, |
|
||||||
'allow_delete' => false, |
|
||||||
'add_button_text' => 'Add', |
|
||||||
'delete_button_text' => 'Delete', |
|
||||||
'sub_widget_col' => 2, |
|
||||||
'button_col' => 2, |
|
||||||
'prototype_name' => '___name___' |
|
||||||
)); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Form\Type\BootstrapCollectionType::setDefaultOptions() |
|
||||||
*/ |
|
||||||
public function testSetDefaultOptions() |
|
||||||
{ |
|
||||||
$resolver = m::mock('Symfony\Component\OptionsResolver\OptionsResolverInterface'); |
|
||||||
$resolver->shouldReceive('setDefaults'); |
|
||||||
$resolver->shouldReceive('setNormalizers'); |
|
||||||
|
|
||||||
$this->type->setDefaultOptions($resolver); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Form\Type\BootstrapCollectionType::getParent() |
|
||||||
*/ |
|
||||||
public function testGetParent() |
|
||||||
{ |
|
||||||
$this->assertEquals('collection', $this->type->getParent()); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Form\Type\BootstrapCollectionType::getName() |
|
||||||
*/ |
|
||||||
public function testGetName() |
|
||||||
{ |
|
||||||
$this->assertEquals('bootstrap_collection', $this->type->getName()); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,112 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
|
|
||||||
namespace Braincrafted\Bundle\BootstrapBundle\Tests\Type; |
|
||||||
|
|
||||||
use Braincrafted\Bundle\BootstrapBundle\Form\Type\FormActionsType; |
|
||||||
use Mockery as m; |
|
||||||
use Symfony\Component\Form\ButtonBuilder; |
|
||||||
use Symfony\Component\Form\FormBuilder; |
|
||||||
|
|
||||||
/** |
|
||||||
* Class FormActionsTypeTest |
|
||||||
* |
|
||||||
* @group unit |
|
||||||
*/ |
|
||||||
class FormActionsTypeTest extends \PHPUnit_Framework_TestCase |
|
||||||
{ |
|
||||||
/** |
|
||||||
* @var FormActionsType |
|
||||||
*/ |
|
||||||
protected $type; |
|
||||||
|
|
||||||
protected function setUp() |
|
||||||
{ |
|
||||||
parent::setUp(); |
|
||||||
$this->type = new FormActionsType(); |
|
||||||
} |
|
||||||
|
|
||||||
public function testBuildForm() |
|
||||||
{ |
|
||||||
$builder = m::mock('Symfony\Component\Form\FormBuilderInterface'); |
|
||||||
|
|
||||||
$input = array( |
|
||||||
'buttons' => array( |
|
||||||
'save' => array('type' => 'submit', 'options' => array('label' => 'button.save')), |
|
||||||
'cancel' => array('type' => 'button', 'options' => array('label' => 'button.cancel')), |
|
||||||
) |
|
||||||
); |
|
||||||
|
|
||||||
$buttonBuilder = new ButtonBuilder('name'); |
|
||||||
$builder->shouldReceive('add') |
|
||||||
->with(m::anyOf('save', 'cancel'), m::anyOf('submit', 'button'), m::hasKey('label')) |
|
||||||
->twice() |
|
||||||
->andReturn($buttonBuilder); |
|
||||||
|
|
||||||
$this->type = new FormActionsType(); |
|
||||||
$this->type->buildForm($builder, $input); |
|
||||||
} |
|
||||||
|
|
||||||
public function testBuildView() |
|
||||||
{ |
|
||||||
$view = m::mock('Symfony\Component\Form\FormView'); |
|
||||||
$form = m::mock('Symfony\Component\Form\FormInterface'); |
|
||||||
$button = m::mock('Symfony\Component\Form\Button'); |
|
||||||
$options = array(); |
|
||||||
|
|
||||||
$buttons = array( |
|
||||||
$button, |
|
||||||
$button |
|
||||||
); |
|
||||||
|
|
||||||
$form->shouldReceive('count')->andReturn(2)->once(); |
|
||||||
$form->shouldReceive('all')->andReturn($buttons)->once(); |
|
||||||
|
|
||||||
$this->type = new FormActionsType(); |
|
||||||
$this->type->buildView($view, $form, $options); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @expectedException \InvalidArgumentException |
|
||||||
*/ |
|
||||||
public function testBuildViewWithBadField() |
|
||||||
{ |
|
||||||
$view = m::mock('Symfony\Component\Form\FormView'); |
|
||||||
$form = m::mock('Symfony\Component\Form\FormInterface'); |
|
||||||
$button = m::mock('Symfony\Component\Form\Button'); |
|
||||||
$input = m::mock('Symfony\Component\Form\FormInterface'); |
|
||||||
$options = array(); |
|
||||||
|
|
||||||
$buttons = array( |
|
||||||
$button, |
|
||||||
$button, |
|
||||||
$input |
|
||||||
); |
|
||||||
|
|
||||||
$form->shouldReceive('count')->andReturn(2)->once(); |
|
||||||
$form->shouldReceive('all')->andReturn($buttons)->once(); |
|
||||||
|
|
||||||
$this->type = new FormActionsType(); |
|
||||||
$this->type->buildView($view, $form, $options); |
|
||||||
} |
|
||||||
|
|
||||||
public function testSetDefaultOptions() |
|
||||||
{ |
|
||||||
|
|
||||||
$defaults = array( |
|
||||||
'buttons' => array(), |
|
||||||
'options' => array(), |
|
||||||
'mapped' => false, |
|
||||||
); |
|
||||||
|
|
||||||
$resolver = m::mock('Symfony\Component\OptionsResolver\OptionsResolverInterface'); |
|
||||||
$resolver->shouldReceive('setDefaults')->with($defaults)->once(); |
|
||||||
|
|
||||||
$this->type->setDefaultOptions($resolver); |
|
||||||
} |
|
||||||
|
|
||||||
public function testGetName() |
|
||||||
{ |
|
||||||
$this->assertEquals('form_actions', $this->type->getName()); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,72 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
namespace Braincrafted\Bundle\BootstrapBundle\Tests\Type; |
|
||||||
|
|
||||||
use \Mockery as m; |
|
||||||
|
|
||||||
use Braincrafted\Bundle\BootstrapBundle\Form\Type\MoneyType; |
|
||||||
|
|
||||||
/** |
|
||||||
* MoneyTypeTest |
|
||||||
* |
|
||||||
* @group unit |
|
||||||
*/ |
|
||||||
class MoneyTypeTest extends \PHPUnit_Framework_TestCase |
|
||||||
{ |
|
||||||
/** @var MoneyType */ |
|
||||||
private $type; |
|
||||||
|
|
||||||
public function setUp() |
|
||||||
{ |
|
||||||
$this->type = new MoneyType; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Form\Type\MoneyType::buildView() |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Form\Type\MoneyType::getPattern() |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Form\Type\MoneyType::parsePatternMatches() |
|
||||||
*/ |
|
||||||
public function testBuildViewLeftSide() |
|
||||||
{ |
|
||||||
$view = m::mock('Symfony\Component\Form\FormView'); |
|
||||||
$form = m::mock('Symfony\Component\Form\FormInterface'); |
|
||||||
|
|
||||||
$this->type->buildView($view, $form, array('currency' => 'EUR')); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Form\Type\MoneyType::buildView() |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Form\Type\MoneyType::getPattern() |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Form\Type\MoneyType::parsePatternMatches() |
|
||||||
*/ |
|
||||||
public function testBuildViewRightSide() |
|
||||||
{ |
|
||||||
$view = m::mock('Symfony\Component\Form\FormView'); |
|
||||||
$form = m::mock('Symfony\Component\Form\FormInterface'); |
|
||||||
|
|
||||||
$default = \Locale::getDefault(); |
|
||||||
\Locale::setDefault('fr-CA'); |
|
||||||
$this->type->buildView($view, $form, array('currency' => 'EUR')); |
|
||||||
\Locale::setDefault($default); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Form\Type\MoneyType::buildView() |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Form\Type\MoneyType::getPattern() |
|
||||||
*/ |
|
||||||
public function testGetPatternEmpty() |
|
||||||
{ |
|
||||||
$view = m::mock('Symfony\Component\Form\FormView'); |
|
||||||
$form = m::mock('Symfony\Component\Form\FormInterface'); |
|
||||||
|
|
||||||
$this->type->buildView($view, $form, array('currency' => null)); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Form\Type\MoneyType::getName() |
|
||||||
*/ |
|
||||||
public function testGetName() |
|
||||||
{ |
|
||||||
$this->assertEquals('money', $this->type->getName()); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,101 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
namespace Braincrafted\Bundle\BootstrapBundle\Tests\Session; |
|
||||||
|
|
||||||
use \Mockery as m; |
|
||||||
|
|
||||||
use Braincrafted\Bundle\BootstrapBundle\Session\FlashMessage; |
|
||||||
|
|
||||||
/** |
|
||||||
* FlashMessageTest |
|
||||||
* |
|
||||||
* @group unit |
|
||||||
*/ |
|
||||||
class FlashMessageTest extends \PHPUnit_Framework_TestCase |
|
||||||
{ |
|
||||||
/** @var \Symfony\Component\HttpFoundation\Session\SessionInterface */ |
|
||||||
private $session; |
|
||||||
|
|
||||||
/** @var \Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface */ |
|
||||||
private $flashBag; |
|
||||||
|
|
||||||
/** @var FlashMessage */ |
|
||||||
private $flash; |
|
||||||
|
|
||||||
public function setUp() |
|
||||||
{ |
|
||||||
$this->flashBag = m::mock('Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface'); |
|
||||||
$this->session = m::mock('Symfony\Component\HttpFoundation\Session\SessionInterface'); |
|
||||||
$this->session |
|
||||||
->shouldReceive('getFlashBag') |
|
||||||
->withNoArgs() |
|
||||||
->atLeast()->once() |
|
||||||
->andReturn($this->flashBag); |
|
||||||
|
|
||||||
$this->flash = new FlashMessage($this->session); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Tests the alert() method. |
|
||||||
* |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Session\FlashMessage::__construct() |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Session\FlashMessage::alert() |
|
||||||
*/ |
|
||||||
public function testAlert() |
|
||||||
{ |
|
||||||
$this->flashBag |
|
||||||
->shouldReceive('add') |
|
||||||
->with('alert', 'Foobar Alert') |
|
||||||
->once(); |
|
||||||
|
|
||||||
$this->flash->alert('Foobar Alert'); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Tests the error() method. |
|
||||||
* |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Session\FlashMessage::__construct() |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Session\FlashMessage::error() |
|
||||||
*/ |
|
||||||
public function testError() |
|
||||||
{ |
|
||||||
$this->flashBag |
|
||||||
->shouldReceive('add') |
|
||||||
->with('error', 'Foobar Error') |
|
||||||
->once(); |
|
||||||
|
|
||||||
$this->flash->error('Foobar Error'); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Tests the info() method. |
|
||||||
* |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Session\FlashMessage::__construct() |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Session\FlashMessage::info() |
|
||||||
*/ |
|
||||||
public function testInfo() |
|
||||||
{ |
|
||||||
$this->flashBag |
|
||||||
->shouldReceive('add') |
|
||||||
->with('info', 'Foobar Info') |
|
||||||
->once(); |
|
||||||
|
|
||||||
$this->flash->info('Foobar Info'); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Tests the success() method. |
|
||||||
* |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Session\FlashMessage::__construct() |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Session\FlashMessage::success() |
|
||||||
*/ |
|
||||||
public function testSuccess() |
|
||||||
{ |
|
||||||
$this->flashBag |
|
||||||
->shouldReceive('add') |
|
||||||
->with('success', 'Foobar Success') |
|
||||||
->once(); |
|
||||||
|
|
||||||
$this->flash->success('Foobar Success'); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,69 +0,0 @@ |
|||||||
<?php |
|
||||||
/** |
|
||||||
* This file is part of BraincraftedBootstrapBundle. |
|
||||||
* |
|
||||||
* (c) 2012-2013 by Florian Eckerstorfer |
|
||||||
*/ |
|
||||||
|
|
||||||
namespace Braincrafted\Bundle\BootstrapBundle\Tests\Twig; |
|
||||||
|
|
||||||
use Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapBadgeExtension; |
|
||||||
|
|
||||||
/** |
|
||||||
* BootstrapBadgeExtensionTest |
|
||||||
* |
|
||||||
* This test is only useful if you consider that it will be run by Travis on every supported PHP |
|
||||||
* configuration. We live in a world where should not have too manually test every commit with every |
|
||||||
* version of PHP. And I know exactly that I will commit short array syntax all the time and break |
|
||||||
* compatibility with PHP 5.3 |
|
||||||
* |
|
||||||
* @category Test |
|
||||||
* @package BraincraftedBootstrapBundle |
|
||||||
* @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 |
|
||||||
* @group unit |
|
||||||
*/ |
|
||||||
class BootstrapBadgeExtensionTest extends \PHPUnit_Framework_TestCase |
|
||||||
{ |
|
||||||
/** @var BootstrapBadgeExtension */ |
|
||||||
private $extension; |
|
||||||
|
|
||||||
/** |
|
||||||
* Set up |
|
||||||
*/ |
|
||||||
public function setUp() |
|
||||||
{ |
|
||||||
$this->extension = new BootstrapBadgeExtension(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapBadgeExtension::getFunctions() |
|
||||||
*/ |
|
||||||
public function testGetFunctions() |
|
||||||
{ |
|
||||||
$this->assertCount(1, $this->extension->getFunctions()); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapBadgeExtension::badgeFunction |
|
||||||
*/ |
|
||||||
public function testBadgeFunction() |
|
||||||
{ |
|
||||||
$this->assertEquals( |
|
||||||
'<span class="badge">Hello World</span>', |
|
||||||
$this->extension->badgeFunction('Hello World'), |
|
||||||
'->badgeFunction() returns the HTML code for the given badge.' |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapBadgeExtension::getName() |
|
||||||
*/ |
|
||||||
public function testGetName() |
|
||||||
{ |
|
||||||
$this->assertEquals('braincrafted_bootstrap_badge', $this->extension->getName()); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,107 +0,0 @@ |
|||||||
<?php |
|
||||||
/** |
|
||||||
* This file is part of BraincraftedBootstrapBundle. |
|
||||||
* |
|
||||||
* (c) 2012-2013 by Florian Eckerstorfer |
|
||||||
*/ |
|
||||||
|
|
||||||
namespace Braincrafted\Bundle\BootstrapBundle\Tests\Twig; |
|
||||||
|
|
||||||
use Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapFormExtension; |
|
||||||
|
|
||||||
/** |
|
||||||
* BootstrapFormExtensionTest |
|
||||||
* |
|
||||||
* This test is only useful if you consider that it will be run by Travis on every supported PHP |
|
||||||
* configuration. We live in a world where should not have too manually test every commit with every |
|
||||||
* version of PHP. And I know exactly that I will commit short array syntax all the time and break |
|
||||||
* compatibility with PHP 5.3 |
|
||||||
* |
|
||||||
* @category Test |
|
||||||
* @package BraincraftedBootstrapBundle |
|
||||||
* @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 |
|
||||||
* @group unit |
|
||||||
*/ |
|
||||||
class BootstrapFormExtensionTest extends \PHPUnit_Framework_TestCase |
|
||||||
{ |
|
||||||
/** @var BootstrapFormExtension */ |
|
||||||
private $extension; |
|
||||||
|
|
||||||
/** |
|
||||||
* Set up |
|
||||||
*/ |
|
||||||
public function setUp() |
|
||||||
{ |
|
||||||
$this->extension = new BootstrapFormExtension(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapFormExtension::getFunctions() |
|
||||||
*/ |
|
||||||
public function testGetFunctions() |
|
||||||
{ |
|
||||||
$this->assertCount(13, $this->extension->getFunctions()); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapFormExtension::setStyle() |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapFormExtension::getStyle() |
|
||||||
*/ |
|
||||||
public function testSetStyleGetStyle() |
|
||||||
{ |
|
||||||
$this->extension->setStyle('inline'); |
|
||||||
$this->assertEquals('inline', $this->extension->getStyle()); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapFormExtension::setColSize() |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapFormExtension::getColSize() |
|
||||||
*/ |
|
||||||
public function testSetColSizeGetColSize() |
|
||||||
{ |
|
||||||
$this->extension->setColSize('sm'); |
|
||||||
$this->assertEquals('sm', $this->extension->getColSize()); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapFormExtension::setWidgetCol() |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapFormExtension::getWidgetCol() |
|
||||||
*/ |
|
||||||
public function testSetWidgetColGetWidgetCol() |
|
||||||
{ |
|
||||||
$this->extension->setWidgetCol(5); |
|
||||||
$this->assertEquals(5, $this->extension->getWidgetCol()); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapFormExtension::setLabelCol() |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapFormExtension::getLabelCol() |
|
||||||
*/ |
|
||||||
public function testSetLabelColGetLabelCol() |
|
||||||
{ |
|
||||||
$this->extension->setLabelCol(4); |
|
||||||
$this->assertEquals(4, $this->extension->getLabelCol()); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapFormExtension::setSimpleCol() |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapFormExtension::getSimpleCol() |
|
||||||
*/ |
|
||||||
public function testSetSimpleColGetSimpleCol() |
|
||||||
{ |
|
||||||
$this->extension->setSimpleCol(8); |
|
||||||
$this->assertEquals(8, $this->extension->getSimpleCol()); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapFormExtension::getName() |
|
||||||
*/ |
|
||||||
public function testGetName() |
|
||||||
{ |
|
||||||
$this->assertEquals('braincrafted_bootstrap_form', $this->extension->getName()); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,89 +0,0 @@ |
|||||||
<?php |
|
||||||
/** |
|
||||||
* This file is part of BraincraftedBootstrapBundle. |
|
||||||
* |
|
||||||
* (c) 2012-2013 by Florian Eckerstorfer |
|
||||||
*/ |
|
||||||
|
|
||||||
namespace Braincrafted\Bundle\BootstrapBundle\Tests\Twig; |
|
||||||
|
|
||||||
use Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapIconExtension; |
|
||||||
|
|
||||||
/** |
|
||||||
* BootstrapIconExtensionTest |
|
||||||
* |
|
||||||
* This test is only useful if you consider that it will be run by Travis on every supported PHP |
|
||||||
* configuration. We live in a world where should not have too manually test every commit with every |
|
||||||
* version of PHP. And I know exactly that I will commit short array syntax all the time and break |
|
||||||
* compatibility with PHP 5.3 |
|
||||||
* |
|
||||||
* @category Test |
|
||||||
* @package BraincraftedBootstrapBundle |
|
||||||
* @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 |
|
||||||
* @group unit |
|
||||||
*/ |
|
||||||
class BootstrapIconExtensionTest extends \PHPUnit_Framework_TestCase |
|
||||||
{ |
|
||||||
/** @var BootstrapIconExtension */ |
|
||||||
private $extension; |
|
||||||
|
|
||||||
/** |
|
||||||
* Set up |
|
||||||
*/ |
|
||||||
public function setUp() |
|
||||||
{ |
|
||||||
$this->extension = new BootstrapIconExtension(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapIconExtension::getFilters() |
|
||||||
*/ |
|
||||||
public function testGetFilters() |
|
||||||
{ |
|
||||||
$this->assertCount(1, $this->extension->getFilters()); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapIconExtension::getFunctions() |
|
||||||
*/ |
|
||||||
public function testGetFunctions() |
|
||||||
{ |
|
||||||
$this->assertCount(1, $this->extension->getFunctions()); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapIconExtension::iconFunction |
|
||||||
*/ |
|
||||||
public function testIconFilter() |
|
||||||
{ |
|
||||||
$this->assertEquals( |
|
||||||
'<span class="glyphicon glyphicon-heart"></span>', |
|
||||||
$this->extension->iconFunction('heart'), |
|
||||||
'->iconFunction() returns the HTML code for the given icon.' |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapIconExtension::parseIconsFilter |
|
||||||
*/ |
|
||||||
public function testParseIconsFilter() |
|
||||||
{ |
|
||||||
$this->assertEquals( |
|
||||||
'<span class="glyphicon glyphicon-heart"></span> foobar', |
|
||||||
$this->extension->parseIconsFilter('.icon-heart foobar'), |
|
||||||
'->parseIconsFilter() returns the HTML code with the replaced icons.' |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapIconExtension::getName() |
|
||||||
*/ |
|
||||||
public function testGetName() |
|
||||||
{ |
|
||||||
$this->assertEquals('braincrafted_bootstrap_icon', $this->extension->getName()); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,129 +0,0 @@ |
|||||||
<?php |
|
||||||
/** |
|
||||||
* This file is part of BraincraftedBootstrapBundle. |
|
||||||
* |
|
||||||
* (c) 2012-2013 by Florian Eckerstorfer |
|
||||||
*/ |
|
||||||
|
|
||||||
namespace Braincrafted\Bundle\BootstrapBundle\Tests\Twig; |
|
||||||
|
|
||||||
use Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapLabelExtension; |
|
||||||
|
|
||||||
/** |
|
||||||
* BootstrapLabelExtensionTest |
|
||||||
* |
|
||||||
* This test is only useful if you consider that it will be run by Travis on every supported PHP |
|
||||||
* configuration. We live in a world where should not have too manually test every commit with every |
|
||||||
* version of PHP. And I know exactly that I will commit short array syntax all the time and break |
|
||||||
* compatibility with PHP 5.3 |
|
||||||
* |
|
||||||
* @category Test |
|
||||||
* @package BraincraftedBootstrapBundle |
|
||||||
* @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 |
|
||||||
* @group unit |
|
||||||
*/ |
|
||||||
class BootstrapLabelExtensionTest extends \PHPUnit_Framework_TestCase |
|
||||||
{ |
|
||||||
/** @var BootstrapLabelExtension */ |
|
||||||
private $extension; |
|
||||||
|
|
||||||
/** |
|
||||||
* @return void |
|
||||||
*/ |
|
||||||
public function setUp() |
|
||||||
{ |
|
||||||
$this->extension = new BootstrapLabelExtension(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapLabelExtension::getFunctions() |
|
||||||
*/ |
|
||||||
public function testGetFunctions() |
|
||||||
{ |
|
||||||
$this->assertCount(6, $this->extension->getFunctions()); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapLabelExtension::labelFunction |
|
||||||
*/ |
|
||||||
public function testLabelFunction() |
|
||||||
{ |
|
||||||
$this->assertEquals( |
|
||||||
'<span class="label label-default">Hello World</span>', |
|
||||||
$this->extension->labelFunction('Hello World'), |
|
||||||
'->labelFunction() returns the HTML code for the given label.' |
|
||||||
); |
|
||||||
$this->assertEquals( |
|
||||||
'<span class="label label-success">Hello World</span>', |
|
||||||
$this->extension->labelFunction('Hello World', 'success'), |
|
||||||
'->labelFunction() returns the HTML code for the given success label.' |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapLabelExtension::labelSuccessFunction |
|
||||||
*/ |
|
||||||
public function testLabelSuccessFunction() |
|
||||||
{ |
|
||||||
$this->assertEquals( |
|
||||||
'<span class="label label-success">Foobar</span>', |
|
||||||
$this->extension->labelSuccessFunction('Foobar') |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapLabelExtension::labelWarningFunction |
|
||||||
*/ |
|
||||||
public function testLabelWarningFunction() |
|
||||||
{ |
|
||||||
$this->assertEquals( |
|
||||||
'<span class="label label-warning">Foobar</span>', |
|
||||||
$this->extension->labelWarningFunction('Foobar') |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapLabelExtension::labelDangerFunction |
|
||||||
*/ |
|
||||||
public function testLabelDangerFunction() |
|
||||||
{ |
|
||||||
$this->assertEquals( |
|
||||||
'<span class="label label-danger">Foobar</span>', |
|
||||||
$this->extension->labelDangerFunction('Foobar') |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapLabelExtension::labelInfoFunction |
|
||||||
*/ |
|
||||||
public function testLabelInfoFunction() |
|
||||||
{ |
|
||||||
$this->assertEquals( |
|
||||||
'<span class="label label-info">Foobar</span>', |
|
||||||
$this->extension->labelInfoFunction('Foobar') |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapLabelExtension::labelPrimaryFunction |
|
||||||
*/ |
|
||||||
public function testLabelPrimaryFunction() |
|
||||||
{ |
|
||||||
$this->assertEquals( |
|
||||||
'<span class="label label-primary">Foobar</span>', |
|
||||||
$this->extension->labelPrimaryFunction('Foobar') |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapLabelExtension::getName() |
|
||||||
*/ |
|
||||||
public function testGetName() |
|
||||||
{ |
|
||||||
$this->assertEquals('braincrafted_bootstrap_label', $this->extension->getName()); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,46 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
namespace Braincrafted\Bundle\BootstrapBundle\Tests\Util; |
|
||||||
|
|
||||||
use Braincrafted\Bundle\BootstrapBundle\Util\PathUtil; |
|
||||||
|
|
||||||
/** |
|
||||||
* PathUtilTest |
|
||||||
* |
|
||||||
* @group unit |
|
||||||
*/ |
|
||||||
class PathUtilTest extends \PHPUnit_Framework_TestCase |
|
||||||
{ |
|
||||||
/** @var PathUtil */ |
|
||||||
private $util; |
|
||||||
|
|
||||||
public function setUp() |
|
||||||
{ |
|
||||||
$this->util = new PathUtil; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @param $expected string |
|
||||||
* @param $from string |
|
||||||
* @param $to string |
|
||||||
* |
|
||||||
* @covers Braincrafted\Bundle\BootstrapBundle\Util\PathUtil::getRelativePath() |
|
||||||
* @dataProvider relativePathProvider |
|
||||||
*/ |
|
||||||
public function testGetRelativePath($expected, $from, $to) |
|
||||||
{ |
|
||||||
$this->assertEquals($expected, $this->util->getRelativePath($from, $to)); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @return array |
|
||||||
*/ |
|
||||||
public function relativePathProvider() |
|
||||||
{ |
|
||||||
return array( |
|
||||||
array('', '/var/user', '/var/user'), |
|
||||||
array('./foo/a.php', '/var/user/a.php', '/var/user/foo/a.php'), |
|
||||||
array('../bar/a.php', '/var/user/foo/a.php', '/var/user/bar/a.php') |
|
||||||
); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,59 +0,0 @@ |
|||||||
<?php |
|
||||||
/** |
|
||||||
* This file is part of BraincraftedBootstrapBundle. |
|
||||||
* |
|
||||||
* (c) 2012-2013 by Florian Eckerstorfer |
|
||||||
*/ |
|
||||||
|
|
||||||
namespace Braincrafted\Bundle\BootstrapBundle\Twig; |
|
||||||
|
|
||||||
use Twig_Extension; |
|
||||||
use Twig_Function_Method; |
|
||||||
|
|
||||||
/** |
|
||||||
* BootstrapLabelExtension |
|
||||||
* |
|
||||||
* @category TwigExtension |
|
||||||
* @package BraincraftedBootstrapBundle |
|
||||||
* @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 BootstrapBadgeExtension extends Twig_Extension |
|
||||||
{ |
|
||||||
/** |
|
||||||
* {@inheritDoc} |
|
||||||
*/ |
|
||||||
public function getFunctions() |
|
||||||
{ |
|
||||||
return array( |
|
||||||
'badge' => new Twig_Function_Method( |
|
||||||
$this, |
|
||||||
'badgeFunction', |
|
||||||
array('pre_escape' => 'html', 'is_safe' => array('html')) |
|
||||||
) |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Returns the HTML code for a badge. |
|
||||||
* |
|
||||||
* @param string $text The text of the badge |
|
||||||
* |
|
||||||
* @return string The HTML code of the badge |
|
||||||
*/ |
|
||||||
public function badgeFunction($text) |
|
||||||
{ |
|
||||||
return sprintf('<span class="badge">%s</span>', $text); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* {@inheritDoc} |
|
||||||
*/ |
|
||||||
public function getName() |
|
||||||
{ |
|
||||||
return 'braincrafted_bootstrap_badge'; |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,174 +0,0 @@ |
|||||||
<?php |
|
||||||
/** |
|
||||||
* This file is part of BraincraftedBootstrapBundle. |
|
||||||
* (c) 2012-2013 by Florian Eckerstorfer |
|
||||||
*/ |
|
||||||
|
|
||||||
namespace Braincrafted\Bundle\BootstrapBundle\Twig; |
|
||||||
|
|
||||||
/** |
|
||||||
* BootstrapFormExtension |
|
||||||
* |
|
||||||
* @package BraincraftedBootstrapBundle |
|
||||||
* @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 |
|
||||||
{ |
|
||||||
/** @var string */ |
|
||||||
private $style; |
|
||||||
|
|
||||||
/** @var string */ |
|
||||||
private $colSize = 'lg'; |
|
||||||
|
|
||||||
/** @var integer */ |
|
||||||
private $widgetCol = 10; |
|
||||||
|
|
||||||
/** @var integer */ |
|
||||||
private $labelCol = 2; |
|
||||||
|
|
||||||
/** @var integer */ |
|
||||||
private $simpleCol = false; |
|
||||||
|
|
||||||
/** |
|
||||||
* {@inheritdoc} |
|
||||||
*/ |
|
||||||
public function getFunctions() |
|
||||||
{ |
|
||||||
return array( |
|
||||||
new \Twig_SimpleFunction('bootstrap_set_style', array($this, 'setStyle')), |
|
||||||
new \Twig_SimpleFunction('bootstrap_get_style', array($this, 'getStyle')), |
|
||||||
new \Twig_SimpleFunction('bootstrap_set_col_size', array($this, 'setColSize')), |
|
||||||
new \Twig_SimpleFunction('bootstrap_get_col_size', array($this, 'getColSize')), |
|
||||||
new \Twig_SimpleFunction('bootstrap_set_widget_col', array($this, 'setWidgetCol')), |
|
||||||
new \Twig_SimpleFunction('bootstrap_get_widget_col', array($this, 'getWidgetCol')), |
|
||||||
new \Twig_SimpleFunction('bootstrap_set_label_col', array($this, 'setLabelCol')), |
|
||||||
new \Twig_SimpleFunction('bootstrap_get_label_col', array($this, 'getLabelCol')), |
|
||||||
new \Twig_SimpleFunction('bootstrap_set_simple_col', array($this, 'setSimpleCol')), |
|
||||||
new \Twig_SimpleFunction('bootstrap_get_simple_col', array($this, 'getSimpleCol')), |
|
||||||
'checkbox_row' => new \Twig_Function_Node( |
|
||||||
'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', |
|
||||||
array('is_safe' => array('html')) |
|
||||||
), |
|
||||||
'radio_row' => new \Twig_Function_Node( |
|
||||||
'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', |
|
||||||
array('is_safe' => array('html')) |
|
||||||
), |
|
||||||
'global_form_errors' => new \Twig_Function_Node( |
|
||||||
'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', |
|
||||||
array('is_safe' => array('html')) |
|
||||||
) |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* {@inheritdoc} |
|
||||||
*/ |
|
||||||
public function getName() |
|
||||||
{ |
|
||||||
return 'braincrafted_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; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Sets the column size. |
|
||||||
* |
|
||||||
* @param string $colSize Column size (xs, sm, md or lg) |
|
||||||
*/ |
|
||||||
public function setColSize($colSize) |
|
||||||
{ |
|
||||||
$this->colSize = $colSize; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Returns the column size. |
|
||||||
* |
|
||||||
* @return string Column size (xs, sm, md or lg) |
|
||||||
*/ |
|
||||||
public function getColSize() |
|
||||||
{ |
|
||||||
return $this->colSize; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Sets the number of columns of widgets. |
|
||||||
* |
|
||||||
* @param integer $widgetCol Number of columns. |
|
||||||
*/ |
|
||||||
public function setWidgetCol($widgetCol) |
|
||||||
{ |
|
||||||
$this->widgetCol = $widgetCol; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Returns the number of columns of widgets. |
|
||||||
* |
|
||||||
* @return integer Number of columns. |
|
||||||
*/ |
|
||||||
public function getWidgetCol() |
|
||||||
{ |
|
||||||
return $this->widgetCol; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Sets the number of columns of labels. |
|
||||||
* |
|
||||||
* @param integer $labelCol Number of columns. |
|
||||||
*/ |
|
||||||
public function setLabelCol($labelCol) |
|
||||||
{ |
|
||||||
$this->labelCol = $labelCol; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Returns the number of columns of labels. |
|
||||||
* |
|
||||||
* @return integer Number of columns. |
|
||||||
*/ |
|
||||||
public function getLabelCol() |
|
||||||
{ |
|
||||||
return $this->labelCol; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Sets the number of columns of simple widgets. |
|
||||||
* |
|
||||||
* @param integer $simpleCol Number of columns. |
|
||||||
*/ |
|
||||||
public function setSimpleCol($simpleCol) |
|
||||||
{ |
|
||||||
$this->simpleCol = $simpleCol; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Returns the number of columns of simple widgets. |
|
||||||
* |
|
||||||
* @return integer Number of columns. |
|
||||||
*/ |
|
||||||
public function getSimpleCol() |
|
||||||
{ |
|
||||||
return $this->simpleCol; |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,91 +0,0 @@ |
|||||||
<?php |
|
||||||
/** |
|
||||||
* This file is part of BraincraftedBootstrapBundle. |
|
||||||
* (c) 2012-2013 by Florian Eckerstorfer |
|
||||||
*/ |
|
||||||
|
|
||||||
namespace Braincrafted\Bundle\BootstrapBundle\Twig; |
|
||||||
|
|
||||||
use Twig_Extension; |
|
||||||
use Twig_Filter_Method; |
|
||||||
use Twig_Function_Method; |
|
||||||
|
|
||||||
/** |
|
||||||
* BootstrapIconExtension |
|
||||||
* |
|
||||||
* @package BraincraftedBootstrapBundle |
|
||||||
* @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 BootstrapIconExtension extends Twig_Extension |
|
||||||
{ |
|
||||||
/** |
|
||||||
* {@inheritDoc} |
|
||||||
*/ |
|
||||||
public function getFilters() |
|
||||||
{ |
|
||||||
return array( |
|
||||||
'parse_icons' => new Twig_Filter_Method( |
|
||||||
$this, |
|
||||||
'parseIconsFilter', |
|
||||||
array('pre_escape' => 'html', 'is_safe' => array('html')) |
|
||||||
) |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* {@inheritDoc} |
|
||||||
*/ |
|
||||||
public function getFunctions() |
|
||||||
{ |
|
||||||
return array( |
|
||||||
'icon' => new Twig_Function_Method( |
|
||||||
$this, |
|
||||||
'iconFunction', |
|
||||||
array('pre_escape' => 'html', 'is_safe' => array('html')) |
|
||||||
) |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Parses the given string and replaces all occurrences of .icon-[name] with the corresponding icon. |
|
||||||
* |
|
||||||
* @param string $text The text to parse |
|
||||||
* |
|
||||||
* @return string The HTML code with the icons |
|
||||||
*/ |
|
||||||
public function parseIconsFilter($text) |
|
||||||
{ |
|
||||||
$that = $this; |
|
||||||
return preg_replace_callback( |
|
||||||
'/\.icon-([a-z0-9-]+)/', |
|
||||||
function ($matches) use ($that) { |
|
||||||
return $that->iconFunction($matches[1]); |
|
||||||
}, |
|
||||||
$text |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Returns the HTML code for the given icon. |
|
||||||
* |
|
||||||
* @param string $icon The name of the icon |
|
||||||
* |
|
||||||
* @return string The HTML code for the icon |
|
||||||
*/ |
|
||||||
public function iconFunction($icon) |
|
||||||
{ |
|
||||||
return sprintf('<span class="glyphicon glyphicon-%s"></span>', $icon); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* {@inheritDoc} |
|
||||||
*/ |
|
||||||
public function getName() |
|
||||||
{ |
|
||||||
return 'braincrafted_bootstrap_icon'; |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,121 +0,0 @@ |
|||||||
<?php |
|
||||||
/** |
|
||||||
* This file is part of BraincraftedBootstrapBundle. |
|
||||||
* |
|
||||||
* (c) 2012-2013 by Florian Eckerstorfer |
|
||||||
*/ |
|
||||||
|
|
||||||
namespace Braincrafted\Bundle\BootstrapBundle\Twig; |
|
||||||
|
|
||||||
use Twig_Extension; |
|
||||||
use Twig_Function_Method; |
|
||||||
|
|
||||||
/** |
|
||||||
* BootstrapLabelExtension |
|
||||||
* |
|
||||||
* @category TwigExtension |
|
||||||
* @package BraincraftedBootstrapBundle |
|
||||||
* @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 BootstrapLabelExtension extends Twig_Extension |
|
||||||
{ |
|
||||||
/** |
|
||||||
* {@inheritDoc} |
|
||||||
*/ |
|
||||||
public function getFunctions() |
|
||||||
{ |
|
||||||
$options = array('pre_escape' => 'html', 'is_safe' => array('html')); |
|
||||||
|
|
||||||
return array( |
|
||||||
'label' => new Twig_Function_Method($this, 'labelFunction', $options), |
|
||||||
'label_primary' => new Twig_Function_Method($this, 'labelPrimaryFunction', $options), |
|
||||||
'label_success' => new Twig_Function_Method($this, 'labelSuccessFunction', $options), |
|
||||||
'label_info' => new Twig_Function_Method($this, 'labelInfoFunction', $options), |
|
||||||
'label_warning' => new Twig_Function_Method($this, 'labelWarningFunction', $options), |
|
||||||
'label_danger' => new Twig_Function_Method($this, 'labelDangerFunction', $options) |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Returns the HTML code for a label. |
|
||||||
* |
|
||||||
* @param string $text The text of the label |
|
||||||
* @param string $type The type of label |
|
||||||
* |
|
||||||
* @return string The HTML code of the label |
|
||||||
*/ |
|
||||||
public function labelFunction($text, $type = 'default') |
|
||||||
{ |
|
||||||
return sprintf('<span class="label%s">%s</span>', ($type ? ' label-' . $type : ''), $text); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @param string $text |
|
||||||
* |
|
||||||
* @return string |
|
||||||
*/ |
|
||||||
public function labelPrimaryFunction($text) |
|
||||||
{ |
|
||||||
return $this->labelFunction($text, 'primary'); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Returns the HTML code for a success label. |
|
||||||
* |
|
||||||
* @param string $text The text of the label |
|
||||||
* |
|
||||||
* @return string The HTML code of the label |
|
||||||
*/ |
|
||||||
public function labelSuccessFunction($text) |
|
||||||
{ |
|
||||||
return $this->labelFunction($text, 'success'); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Returns the HTML code for a warning label. |
|
||||||
* |
|
||||||
* @param string $text The text of the label |
|
||||||
* |
|
||||||
* @return string The HTML code of the label |
|
||||||
*/ |
|
||||||
public function labelWarningFunction($text) |
|
||||||
{ |
|
||||||
return $this->labelFunction($text, 'warning'); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Returns the HTML code for a important label. |
|
||||||
* |
|
||||||
* @param string $text The text of the label |
|
||||||
* |
|
||||||
* @return string The HTML code of the label |
|
||||||
*/ |
|
||||||
public function labelDangerFunction($text) |
|
||||||
{ |
|
||||||
return $this->labelFunction($text, 'danger'); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Returns the HTML code for a info label. |
|
||||||
* |
|
||||||
* @param string $text The text of the label |
|
||||||
* |
|
||||||
* @return string The HTML code of the label |
|
||||||
*/ |
|
||||||
public function labelInfoFunction($text) |
|
||||||
{ |
|
||||||
return $this->labelFunction($text, 'info'); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* {@inheritDoc} |
|
||||||
*/ |
|
||||||
public function getName() |
|
||||||
{ |
|
||||||
return 'braincrafted_bootstrap_label'; |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,64 +0,0 @@ |
|||||||
<?php |
|
||||||
/** |
|
||||||
* This file is part of BraincraftedBootstrapBundle. |
|
||||||
* |
|
||||||
* (c) 2012-2013 by Florian Eckerstorfer |
|
||||||
*/ |
|
||||||
|
|
||||||
namespace Braincrafted\Bundle\BootstrapBundle\Util; |
|
||||||
|
|
||||||
/** |
|
||||||
* PathUtil |
|
||||||
* |
|
||||||
* @package BraincraftedBootstrapBundle |
|
||||||
* @subpackage Util |
|
||||||
* @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 PathUtil |
|
||||||
{ |
|
||||||
/** |
|
||||||
* Returns the relative path $from to $to. |
|
||||||
* |
|
||||||
* @param string $from |
|
||||||
* @param string $to |
|
||||||
* |
|
||||||
* @return string |
|
||||||
* |
|
||||||
* @link http://stackoverflow.com/a/2638272/776654 |
|
||||||
*/ |
|
||||||
public function getRelativePath($from, $to) |
|
||||||
{ |
|
||||||
// some compatibility fixes for Windows paths |
|
||||||
$from = is_dir($from) ? rtrim($from, '\/') . '/' : $from; |
|
||||||
$to = is_dir($to) ? rtrim($to, '\/') . '/' : $to; |
|
||||||
$from = str_replace('\\', '/', $from); |
|
||||||
$to = str_replace('\\', '/', $to); |
|
||||||
|
|
||||||
$from = explode('/', $from); |
|
||||||
$to = explode('/', $to); |
|
||||||
$relPath = $to; |
|
||||||
|
|
||||||
foreach ($from as $depth => $dir) { |
|
||||||
// find first non-matching dir |
|
||||||
if ($dir === $to[$depth]) { |
|
||||||
// ignore this directory |
|
||||||
array_shift($relPath); |
|
||||||
} else { |
|
||||||
// get number of remaining dirs to $from |
|
||||||
$remaining = count($from) - $depth; |
|
||||||
if ($remaining > 1) { |
|
||||||
// add traversals up to first matching dir |
|
||||||
$padLength = (count($relPath) + $remaining - 1) * -1; |
|
||||||
$relPath = array_pad($relPath, $padLength, '..'); |
|
||||||
break; |
|
||||||
} else { |
|
||||||
$relPath[0] = './' . $relPath[0]; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
return implode('/', $relPath); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,40 +0,0 @@ |
|||||||
{ |
|
||||||
"name": "braincrafted/bootstrap-bundle", |
|
||||||
"description": "BraincraftedBootstrapBundle integrates Bootstrap into Symfony2 by providing templates, Twig extensions, services and commands.", |
|
||||||
"keywords": ["bootstrap"], |
|
||||||
"type": "symfony-bundle", |
|
||||||
"license": "MIT", |
|
||||||
"authors": [ |
|
||||||
{ |
|
||||||
"name": "Florian Eckerstorfer", |
|
||||||
"email": "florian@eckerstorfer.co", |
|
||||||
"homepage": "http://florian.ec" |
|
||||||
} |
|
||||||
], |
|
||||||
"require": { |
|
||||||
"php": ">=5.3.3", |
|
||||||
"symfony/framework-bundle": "~2.3", |
|
||||||
"symfony/twig-bundle": "~2.3", |
|
||||||
"symfony/form": "~2.3", |
|
||||||
"symfony/console": "~2.3", |
|
||||||
"symfony/finder": "~2.3" |
|
||||||
}, |
|
||||||
"require-dev": { |
|
||||||
"symfony/assetic-bundle": "~2.3", |
|
||||||
"knplabs/knp-menu": "~2.0@alpha", |
|
||||||
"knplabs/knp-menu-bundle": "~2.0@alpha", |
|
||||||
"knplabs/knp-paginator-bundle": "dev-master", |
|
||||||
"phpunit/phpunit": "3.7.*", |
|
||||||
"mockery/mockery": "0.8.*" |
|
||||||
}, |
|
||||||
"suggest": { |
|
||||||
"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.", |
|
||||||
"twbs/bootstrap": "Twitter Bootstrap provides the assets (images, CSS and JS)" |
|
||||||
}, |
|
||||||
"autoload": { |
|
||||||
"psr-0": { "Braincrafted\\Bundle\\BootstrapBundle": "" } |
|
||||||
}, |
|
||||||
"target-dir": "Braincrafted/Bundle/BootstrapBundle" |
|
||||||
} |
|
||||||
@ -1,38 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
|
|
||||||
<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html --> |
|
||||||
<phpunit |
|
||||||
backupGlobals = "false" |
|
||||||
backupStaticAttributes = "false" |
|
||||||
colors = "true" |
|
||||||
convertErrorsToExceptions = "true" |
|
||||||
convertNoticesToExceptions = "true" |
|
||||||
convertWarningsToExceptions = "true" |
|
||||||
processIsolation = "false" |
|
||||||
stopOnFailure = "false" |
|
||||||
syntaxCheck = "false" |
|
||||||
bootstrap = "./vendor/autoload.php" > |
|
||||||
|
|
||||||
<testsuites> |
|
||||||
<testsuite name="BraincraftedBootstrapBundle Test Suite"> |
|
||||||
<directory>./Tests</directory> |
|
||||||
<directory></directory> |
|
||||||
</testsuite> |
|
||||||
</testsuites> |
|
||||||
|
|
||||||
<filter> |
|
||||||
<whitelist> |
|
||||||
<directory>./</directory> |
|
||||||
<exclude> |
|
||||||
<directory>./Resources</directory> |
|
||||||
<directory>./Tests</directory> |
|
||||||
<directory>./vendor</directory> |
|
||||||
</exclude> |
|
||||||
</whitelist> |
|
||||||
</filter> |
|
||||||
|
|
||||||
<listeners> |
|
||||||
<listener class="\Mockery\Adapter\Phpunit\TestListener"></listener> |
|
||||||
</listeners> |
|
||||||
|
|
||||||
</phpunit> |
|
||||||
File diff suppressed because it is too large
Load Diff
@ -1,322 +0,0 @@ |
|||||||
{ |
|
||||||
"hash": "f763db6a8f5bcaff6e51ae516283a4c9", |
|
||||||
"packages": [ |
|
||||||
{ |
|
||||||
"name": "doctrine/annotations", |
|
||||||
"version": "v1.0", |
|
||||||
"source": { |
|
||||||
"type": "git", |
|
||||||
"url": "https://github.com/doctrine/annotations.git", |
|
||||||
"reference": "v1.0" |
|
||||||
}, |
|
||||||
"dist": { |
|
||||||
"type": "zip", |
|
||||||
"url": "https://github.com/doctrine/annotations/archive/v1.0.zip", |
|
||||||
"reference": "v1.0", |
|
||||||
"shasum": "" |
|
||||||
}, |
|
||||||
"require": { |
|
||||||
"php": ">=5.3.2", |
|
||||||
"doctrine/lexer": "1.*" |
|
||||||
}, |
|
||||||
"require-dev": { |
|
||||||
"doctrine/cache": "1.*" |
|
||||||
}, |
|
||||||
"time": "2013-01-12 19:23:32", |
|
||||||
"type": "library", |
|
||||||
"installation-source": "dist", |
|
||||||
"autoload": { |
|
||||||
"psr-0": { |
|
||||||
"Doctrine\\Common\\Annotations\\": "lib/" |
|
||||||
} |
|
||||||
}, |
|
||||||
"notification-url": "https://packagist.org/downloads/", |
|
||||||
"license": [ |
|
||||||
"MIT" |
|
||||||
], |
|
||||||
"authors": [ |
|
||||||
{ |
|
||||||
"name": "Jonathan Wage", |
|
||||||
"email": "jonwage@gmail.com", |
|
||||||
"homepage": "http://www.jwage.com/" |
|
||||||
}, |
|
||||||
{ |
|
||||||
"name": "Guilherme Blanco", |
|
||||||
"email": "guilhermeblanco@gmail.com", |
|
||||||
"homepage": "http://www.instaclick.com" |
|
||||||
}, |
|
||||||
{ |
|
||||||
"name": "Roman Borschel", |
|
||||||
"email": "roman@code-factory.org" |
|
||||||
}, |
|
||||||
{ |
|
||||||
"name": "Benjamin Eberlei", |
|
||||||
"email": "kontakt@beberlei.de" |
|
||||||
}, |
|
||||||
{ |
|
||||||
"name": "Johannes Schmitt", |
|
||||||
"email": "schmittjoh@gmail.com", |
|
||||||
"homepage": "https://github.com/schmittjoh", |
|
||||||
"role": "Developer of wrapped JMSSerializerBundle" |
|
||||||
} |
|
||||||
], |
|
||||||
"description": "Docblock Annotations Parser", |
|
||||||
"homepage": "http://www.doctrine-project.org", |
|
||||||
"keywords": [ |
|
||||||
"annotations", |
|
||||||
"parser", |
|
||||||
"docblock" |
|
||||||
] |
|
||||||
}, |
|
||||||
{ |
|
||||||
"name": "doctrine/cache", |
|
||||||
"version": "v1.0", |
|
||||||
"source": { |
|
||||||
"type": "git", |
|
||||||
"url": "https://github.com/doctrine/cache.git", |
|
||||||
"reference": "v1.0" |
|
||||||
}, |
|
||||||
"dist": { |
|
||||||
"type": "zip", |
|
||||||
"url": "https://github.com/doctrine/cache/archive/v1.0.zip", |
|
||||||
"reference": "v1.0", |
|
||||||
"shasum": "" |
|
||||||
}, |
|
||||||
"require": { |
|
||||||
"php": ">=5.3.2" |
|
||||||
}, |
|
||||||
"time": "2013-01-10 22:43:46", |
|
||||||
"type": "library", |
|
||||||
"installation-source": "dist", |
|
||||||
"autoload": { |
|
||||||
"psr-0": { |
|
||||||
"Doctrine\\Common\\Cache\\": "lib/" |
|
||||||
} |
|
||||||
}, |
|
||||||
"notification-url": "https://packagist.org/downloads/", |
|
||||||
"license": [ |
|
||||||
"MIT" |
|
||||||
], |
|
||||||
"authors": [ |
|
||||||
{ |
|
||||||
"name": "Jonathan Wage", |
|
||||||
"email": "jonwage@gmail.com", |
|
||||||
"homepage": "http://www.jwage.com/" |
|
||||||
}, |
|
||||||
{ |
|
||||||
"name": "Guilherme Blanco", |
|
||||||
"email": "guilhermeblanco@gmail.com", |
|
||||||
"homepage": "http://www.instaclick.com" |
|
||||||
}, |
|
||||||
{ |
|
||||||
"name": "Roman Borschel", |
|
||||||
"email": "roman@code-factory.org" |
|
||||||
}, |
|
||||||
{ |
|
||||||
"name": "Benjamin Eberlei", |
|
||||||
"email": "kontakt@beberlei.de" |
|
||||||
}, |
|
||||||
{ |
|
||||||
"name": "Johannes Schmitt", |
|
||||||
"email": "schmittjoh@gmail.com", |
|
||||||
"homepage": "https://github.com/schmittjoh", |
|
||||||
"role": "Developer of wrapped JMSSerializerBundle" |
|
||||||
} |
|
||||||
], |
|
||||||
"description": "Caching library offering an object-oriented API for many cache backends", |
|
||||||
"homepage": "http://www.doctrine-project.org", |
|
||||||
"keywords": [ |
|
||||||
"cache", |
|
||||||
"caching" |
|
||||||
] |
|
||||||
}, |
|
||||||
{ |
|
||||||
"name": "doctrine/collections", |
|
||||||
"version": "v1.0", |
|
||||||
"source": { |
|
||||||
"type": "git", |
|
||||||
"url": "https://github.com/doctrine/collections.git", |
|
||||||
"reference": "v1.0" |
|
||||||
}, |
|
||||||
"dist": { |
|
||||||
"type": "zip", |
|
||||||
"url": "https://github.com/doctrine/collections/archive/v1.0.zip", |
|
||||||
"reference": "v1.0", |
|
||||||
"shasum": "" |
|
||||||
}, |
|
||||||
"require": { |
|
||||||
"php": ">=5.3.2" |
|
||||||
}, |
|
||||||
"time": "2013-01-12 16:36:50", |
|
||||||
"type": "library", |
|
||||||
"installation-source": "dist", |
|
||||||
"autoload": { |
|
||||||
"psr-0": { |
|
||||||
"Doctrine\\Common\\Collections\\": "lib/" |
|
||||||
} |
|
||||||
}, |
|
||||||
"notification-url": "https://packagist.org/downloads/", |
|
||||||
"license": [ |
|
||||||
"MIT" |
|
||||||
], |
|
||||||
"authors": [ |
|
||||||
{ |
|
||||||
"name": "Jonathan Wage", |
|
||||||
"email": "jonwage@gmail.com", |
|
||||||
"homepage": "http://www.jwage.com/" |
|
||||||
}, |
|
||||||
{ |
|
||||||
"name": "Guilherme Blanco", |
|
||||||
"email": "guilhermeblanco@gmail.com", |
|
||||||
"homepage": "http://www.instaclick.com" |
|
||||||
}, |
|
||||||
{ |
|
||||||
"name": "Roman Borschel", |
|
||||||
"email": "roman@code-factory.org" |
|
||||||
}, |
|
||||||
{ |
|
||||||
"name": "Benjamin Eberlei", |
|
||||||
"email": "kontakt@beberlei.de" |
|
||||||
}, |
|
||||||
{ |
|
||||||
"name": "Johannes Schmitt", |
|
||||||
"email": "schmittjoh@gmail.com", |
|
||||||
"homepage": "https://github.com/schmittjoh", |
|
||||||
"role": "Developer of wrapped JMSSerializerBundle" |
|
||||||
} |
|
||||||
], |
|
||||||
"description": "Collections Abstraction library", |
|
||||||
"homepage": "http://www.doctrine-project.org", |
|
||||||
"keywords": [ |
|
||||||
"collections", |
|
||||||
"iterator", |
|
||||||
"array" |
|
||||||
] |
|
||||||
}, |
|
||||||
{ |
|
||||||
"name": "doctrine/inflector", |
|
||||||
"version": "v1.0", |
|
||||||
"source": { |
|
||||||
"type": "git", |
|
||||||
"url": "https://github.com/doctrine/inflector.git", |
|
||||||
"reference": "v1.0" |
|
||||||
}, |
|
||||||
"dist": { |
|
||||||
"type": "zip", |
|
||||||
"url": "https://github.com/doctrine/inflector/archive/v1.0.zip", |
|
||||||
"reference": "v1.0", |
|
||||||
"shasum": "" |
|
||||||
}, |
|
||||||
"require": { |
|
||||||
"php": ">=5.3.2" |
|
||||||
}, |
|
||||||
"time": "2013-01-10 21:49:15", |
|
||||||
"type": "library", |
|
||||||
"installation-source": "dist", |
|
||||||
"autoload": { |
|
||||||
"psr-0": { |
|
||||||
"Doctrine\\Common\\Inflector\\": "lib/" |
|
||||||
} |
|
||||||
}, |
|
||||||
"notification-url": "https://packagist.org/downloads/", |
|
||||||
"license": [ |
|
||||||
"MIT" |
|
||||||
], |
|
||||||
"authors": [ |
|
||||||
{ |
|
||||||
"name": "Jonathan Wage", |
|
||||||
"email": "jonwage@gmail.com", |
|
||||||
"homepage": "http://www.jwage.com/" |
|
||||||
}, |
|
||||||
{ |
|
||||||
"name": "Guilherme Blanco", |
|
||||||
"email": "guilhermeblanco@gmail.com", |
|
||||||
"homepage": "http://www.instaclick.com" |
|
||||||
}, |
|
||||||
{ |
|
||||||
"name": "Roman Borschel", |
|
||||||
"email": "roman@code-factory.org" |
|
||||||
}, |
|
||||||
{ |
|
||||||
"name": "Benjamin Eberlei", |
|
||||||
"email": "kontakt@beberlei.de" |
|
||||||
}, |
|
||||||
{ |
|
||||||
"name": "Johannes Schmitt", |
|
||||||
"email": "schmittjoh@gmail.com", |
|
||||||
"homepage": "https://github.com/schmittjoh", |
|
||||||
"role": "Developer of wrapped JMSSerializerBundle" |
|
||||||
} |
|
||||||
], |
|
||||||
"description": "Common String Manipulations with regard to casing and singular/plural rules.", |
|
||||||
"homepage": "http://www.doctrine-project.org", |
|
||||||
"keywords": [ |
|
||||||
"string", |
|
||||||
"inflection", |
|
||||||
"singuarlize", |
|
||||||
"pluarlize" |
|
||||||
] |
|
||||||
}, |
|
||||||
{ |
|
||||||
"name": "doctrine/lexer", |
|
||||||
"version": "v1.0", |
|
||||||
"source": { |
|
||||||
"type": "git", |
|
||||||
"url": "https://github.com/doctrine/lexer.git", |
|
||||||
"reference": "v1.0" |
|
||||||
}, |
|
||||||
"dist": { |
|
||||||
"type": "zip", |
|
||||||
"url": "https://github.com/doctrine/lexer/archive/v1.0.zip", |
|
||||||
"reference": "v1.0", |
|
||||||
"shasum": "" |
|
||||||
}, |
|
||||||
"require": { |
|
||||||
"php": ">=5.3.2" |
|
||||||
}, |
|
||||||
"time": "2013-01-12 18:59:04", |
|
||||||
"type": "library", |
|
||||||
"installation-source": "dist", |
|
||||||
"autoload": { |
|
||||||
"psr-0": { |
|
||||||
"Doctrine\\Common\\Lexer\\": "lib/" |
|
||||||
} |
|
||||||
}, |
|
||||||
"notification-url": "https://packagist.org/downloads/", |
|
||||||
"license": [ |
|
||||||
"MIT" |
|
||||||
], |
|
||||||
"authors": [ |
|
||||||
{ |
|
||||||
"name": "Guilherme Blanco", |
|
||||||
"email": "guilhermeblanco@gmail.com", |
|
||||||
"homepage": "http://www.instaclick.com" |
|
||||||
}, |
|
||||||
{ |
|
||||||
"name": "Roman Borschel", |
|
||||||
"email": "roman@code-factory.org" |
|
||||||
}, |
|
||||||
{ |
|
||||||
"name": "Johannes Schmitt", |
|
||||||
"email": "schmittjoh@gmail.com", |
|
||||||
"homepage": "https://github.com/schmittjoh", |
|
||||||
"role": "Developer of wrapped JMSSerializerBundle" |
|
||||||
} |
|
||||||
], |
|
||||||
"description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.", |
|
||||||
"homepage": "http://www.doctrine-project.org", |
|
||||||
"keywords": [ |
|
||||||
"parser", |
|
||||||
"lexer" |
|
||||||
] |
|
||||||
} |
|
||||||
], |
|
||||||
"packages-dev": null, |
|
||||||
"aliases": [ |
|
||||||
|
|
||||||
], |
|
||||||
"minimum-stability": "stable", |
|
||||||
"stability-flags": [ |
|
||||||
|
|
||||||
] |
|
||||||
} |
|
||||||
@ -1,246 +0,0 @@ |
|||||||
<?php |
|
||||||
/** |
|
||||||
* Native PHPUnit Task |
|
||||||
* |
|
||||||
* LICENSE |
|
||||||
* |
|
||||||
* This source file is subject to the new BSD license that is bundled |
|
||||||
* with this package in the file LICENSE.txt. |
|
||||||
* If you did not receive a copy of the license and are unable to |
|
||||||
* obtain it through the world-wide-web, please send an email |
|
||||||
* to kontakt@beberlei.de so I can send you a copy immediately. |
|
||||||
*/ |
|
||||||
|
|
||||||
require_once 'PHPUnit/Autoload.php'; |
|
||||||
|
|
||||||
/** |
|
||||||
* A more flexible and powerful PHPUnit Task than the native Phing one. |
|
||||||
* |
|
||||||
* Plus forward compatibility for PHPUnit 3.5 and later is ensured by using the PHPUnit Test Runner instead of implementing one. |
|
||||||
* |
|
||||||
* @author Benjamin Eberlei <kontakt@beberlei.de> |
|
||||||
*/ |
|
||||||
class NativePhpunitTask extends Task |
|
||||||
{ |
|
||||||
private $test; |
|
||||||
private $testfile; |
|
||||||
private $testdirectory; |
|
||||||
private $configuration = null; |
|
||||||
private $coverageClover = null; |
|
||||||
private $junitlogfile = null; |
|
||||||
private $haltonfailure = true; |
|
||||||
private $haltonerror = true; |
|
||||||
|
|
||||||
public function setTestdirectory($directory) { |
|
||||||
$this->testdirectory = $directory; |
|
||||||
} |
|
||||||
|
|
||||||
public function setTest($test) { |
|
||||||
$this->test = $test; |
|
||||||
} |
|
||||||
|
|
||||||
public function setTestfile($testfile) { |
|
||||||
$this->testfile = $testfile; |
|
||||||
} |
|
||||||
|
|
||||||
public function setJunitlogfile($junitlogfile) { |
|
||||||
if (strlen($junitlogfile) == 0) { |
|
||||||
$junitlogfile = NULL; |
|
||||||
} |
|
||||||
|
|
||||||
$this->junitlogfile = $junitlogfile; |
|
||||||
} |
|
||||||
|
|
||||||
public function setConfiguration($configuration) { |
|
||||||
if (strlen($configuration) == 0) { |
|
||||||
$configuration = NULL; |
|
||||||
} |
|
||||||
|
|
||||||
$this->configuration = $configuration; |
|
||||||
} |
|
||||||
|
|
||||||
public function setCoverageClover($coverageClover) { |
|
||||||
if (strlen($coverageClover) == 0) { |
|
||||||
$coverageClover = NULL; |
|
||||||
} |
|
||||||
|
|
||||||
$this->coverageClover = $coverageClover; |
|
||||||
} |
|
||||||
|
|
||||||
public function setHaltonfailure($haltonfailures) { |
|
||||||
$this->haltonfailure = $haltonfailures; |
|
||||||
} |
|
||||||
|
|
||||||
public function setHaltonerror($haltonerrors) { |
|
||||||
$this->haltonerror = $haltonerrors; |
|
||||||
} |
|
||||||
|
|
||||||
public function init() |
|
||||||
{ |
|
||||||
require_once "PHPUnit/Runner/Version.php"; |
|
||||||
$version = PHPUnit_Runner_Version::id(); |
|
||||||
|
|
||||||
if (version_compare($version, '3.4.0') < 0) { |
|
||||||
throw new BuildException("NativePHPUnitTask requires PHPUnit version >= 3.2.0", $this->getLocation()); |
|
||||||
} |
|
||||||
|
|
||||||
require_once 'PHPUnit/Util/Filter.php'; |
|
||||||
|
|
||||||
// point PHPUnit_MAIN_METHOD define to non-existing method |
|
||||||
if (!defined('PHPUnit_MAIN_METHOD')) { |
|
||||||
define('PHPUnit_MAIN_METHOD', 'PHPUnitTask::undefined'); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public function main() |
|
||||||
{ |
|
||||||
if (!is_dir(realpath($this->testdirectory))) { |
|
||||||
throw new BuildException("NativePHPUnitTask requires a Test Directory path given, '".$this->testdirectory."' given."); |
|
||||||
} |
|
||||||
set_include_path(realpath($this->testdirectory) . PATH_SEPARATOR . get_include_path()); |
|
||||||
|
|
||||||
$printer = new NativePhpunitPrinter(); |
|
||||||
|
|
||||||
$arguments = array( |
|
||||||
'configuration' => $this->configuration, |
|
||||||
'coverageClover' => $this->coverageClover, |
|
||||||
'junitLogfile' => $this->junitlogfile, |
|
||||||
'printer' => $printer, |
|
||||||
); |
|
||||||
|
|
||||||
$runner = new PHPUnit_TextUI_TestRunner(); |
|
||||||
$suite = $runner->getTest($this->test, $this->testfile, true); |
|
||||||
|
|
||||||
try { |
|
||||||
$result = $runner->doRun($suite, $arguments); |
|
||||||
/* @var $result PHPUnit_Framework_TestResult */ |
|
||||||
|
|
||||||
if ( ($this->haltonfailure && $result->failureCount() > 0) || ($this->haltonerror && $result->errorCount() > 0) ) { |
|
||||||
throw new BuildException("PHPUnit: ".$result->failureCount()." Failures and ".$result->errorCount()." Errors, ". |
|
||||||
"last failure message: ".$printer->getMessages()); |
|
||||||
} |
|
||||||
|
|
||||||
$this->log("PHPUnit Success: ".count($result->passed())." tests passed, no ". |
|
||||||
"failures (".$result->skippedCount()." skipped, ".$result->notImplementedCount()." not implemented)"); |
|
||||||
|
|
||||||
// Hudson for example doesn't like the backslash in class names |
|
||||||
if (is_file($this->coverageClover)) { |
|
||||||
$this->log("Generated Clover Coverage XML to: ".$this->coverageClover); |
|
||||||
$content = file_get_contents($this->coverageClover); |
|
||||||
$content = str_replace("\\", ".", $content); |
|
||||||
file_put_contents($this->coverageClover, $content); |
|
||||||
unset($content); |
|
||||||
} |
|
||||||
|
|
||||||
} catch(\Exception $e) { |
|
||||||
throw new BuildException("NativePhpunitTask failed: ".$e->getMessage()); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
class NativePhpunitPrinter extends PHPUnit_Util_Printer implements PHPUnit_Framework_TestListener |
|
||||||
{ |
|
||||||
private $_messages = array(); |
|
||||||
|
|
||||||
public function write($buffer) |
|
||||||
{ |
|
||||||
// do nothing |
|
||||||
} |
|
||||||
|
|
||||||
public function getMessages() |
|
||||||
{ |
|
||||||
return $this->_messages; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* An error occurred. |
|
||||||
* |
|
||||||
* @param PHPUnit_Framework_Test $test |
|
||||||
* @param Exception $e |
|
||||||
* @param float $time |
|
||||||
*/ |
|
||||||
public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) |
|
||||||
{ |
|
||||||
$this->_messages[] = "Test ERROR: ".$test->getName().": ".$e->getMessage(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* A failure occurred. |
|
||||||
* |
|
||||||
* @param PHPUnit_Framework_Test $test |
|
||||||
* @param PHPUnit_Framework_AssertionFailedError $e |
|
||||||
* @param float $time |
|
||||||
*/ |
|
||||||
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) |
|
||||||
{ |
|
||||||
$this->_messages[] = "Test FAILED: ".$test->getName().": ".$e->getMessage(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Incomplete test. |
|
||||||
* |
|
||||||
* @param PHPUnit_Framework_Test $test |
|
||||||
* @param Exception $e |
|
||||||
* @param float $time |
|
||||||
*/ |
|
||||||
public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) |
|
||||||
{ |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Skipped test. |
|
||||||
* |
|
||||||
* @param PHPUnit_Framework_Test $test |
|
||||||
* @param Exception $e |
|
||||||
* @param float $time |
|
||||||
* @since Method available since Release 3.0.0 |
|
||||||
*/ |
|
||||||
public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) |
|
||||||
{ |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* A test suite started. |
|
||||||
* |
|
||||||
* @param PHPUnit_Framework_TestSuite $suite |
|
||||||
* @since Method available since Release 2.2.0 |
|
||||||
*/ |
|
||||||
public function startTestSuite(PHPUnit_Framework_TestSuite $suite) |
|
||||||
{ |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* A test suite ended. |
|
||||||
* |
|
||||||
* @param PHPUnit_Framework_TestSuite $suite |
|
||||||
* @since Method available since Release 2.2.0 |
|
||||||
*/ |
|
||||||
public function endTestSuite(PHPUnit_Framework_TestSuite $suite) |
|
||||||
{ |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* A test started. |
|
||||||
* |
|
||||||
* @param PHPUnit_Framework_Test $test |
|
||||||
*/ |
|
||||||
public function startTest(PHPUnit_Framework_Test $test) |
|
||||||
{ |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* A test ended. |
|
||||||
* |
|
||||||
* @param PHPUnit_Framework_Test $test |
|
||||||
* @param float $time |
|
||||||
*/ |
|
||||||
public function endTest(PHPUnit_Framework_Test $test, $time) |
|
||||||
{ |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue