Skip to content

Commit

Permalink
Merge a742485 into ddb4cf5
Browse files Browse the repository at this point in the history
  • Loading branch information
ElectricMaxxx authored May 10, 2018
2 parents ddb4cf5 + a742485 commit 212ad07
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 44 deletions.
15 changes: 10 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,22 @@ matrix:
- php: 7.2
env: DEPENDENCIES="symfony/lts:^3"

# Latest commit to master
#doc
- php: 7.2
env: TARGET=docs

- php: 7.2
env: STABILITY="dev"

#doc
- php: '7.2'
env: TARGET=docs
- php: 7.2
env: TARGET=phpstan LEVEL=0

- php: 7.2
env: TARGET=phpstan LEVEL=8

allow_failures:
# Dev-master is allowed to fail.
- env: STABILITY="dev"
- env: TARGET=phpstan LEVEL=8

before_install:
- if ! [ -z "$STABILITY" ]; then composer config minimum-stability ${STABILITY}; fi;
Expand Down
3 changes: 3 additions & 0 deletions .travis/script_phpstan.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

php vendor/bin/phpstan analyse -l ${LEVEL} src tests -c phpstan.neon
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
"symfony/templating": "^2.7 || ^3.0 || ^4.0",
"symfony/twig-bridge": "^2.7 || ^3.0 || ^4.0",
"symfony/yaml": "^2.7 || ^3.0 || ^4.0",
"twig/twig": "^1.34 || ^2.0"
"twig/twig": "^1.34 || ^2.0",
"phpstan/phpstan": "^0.9.2"
},
"suggest": {
"egeloen/form-extra-bundle": "Allows to load CKEditor asynchronously"
Expand Down
5 changes: 5 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
parameters:
bootstrap: %currentWorkingDirectory%/tests/autoload.php
excludes_analyse:
- %currentWorkingDirectory%/src/Resources/views/Form/*html.php
- %currentWorkingDirectory%/tests/autoload.php
45 changes: 8 additions & 37 deletions src/Command/CKEditorInstallerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ private function createOptions(InputInterface $input, OutputInterface $output)
*/
private function createNotifier(InputInterface $input, OutputInterface $output)
{
$clear = $this->createProgressBar($output);
$download = $this->createProgressBar($output);
$extract = $this->createProgressBar($output);
$clear = new ProgressBar($output);
$download = new ProgressBar($output);
$extract = new ProgressBar($output);

return function ($type, $data) use ($input, $output, $clear, $download, $extract) {
switch ($type) {
Expand Down Expand Up @@ -209,7 +209,7 @@ private function createNotifier(InputInterface $input, OutputInterface $output)
break;

case CKEditorInstaller::NOTIFY_CLEAR_SIZE:
$this->startProgressBar($clear, $output, $data);
$clear->start($data);

break;

Expand All @@ -224,12 +224,12 @@ private function createNotifier(InputInterface $input, OutputInterface $output)
break;

case CKEditorInstaller::NOTIFY_DOWNLOAD_PROGRESS:
$this->advanceProgressBar($download, $data);
$download->advance($data);

break;

case CKEditorInstaller::NOTIFY_DOWNLOAD_SIZE:
$this->startProgressBar($download, $output, $data);
$download->start($data);

break;

Expand All @@ -249,7 +249,7 @@ private function createNotifier(InputInterface $input, OutputInterface $output)
break;

case CKEditorInstaller::NOTIFY_EXTRACT_SIZE:
$this->startProgressBar($extract, $output, $data);
$extract->start($data);

break;
}
Expand Down Expand Up @@ -357,36 +357,7 @@ private function choice($question, array $choices, $default, InputInterface $inp
}

/**
* @param OutputInterface $output
*
* @return ProgressBar|ProgressHelper
*/
private function createProgressBar(OutputInterface $output)
{
return class_exists(ProgressBar::class) ? new ProgressBar($output) : new ProgressHelper();
}

/**
* @param ProgressBar|ProgressHelper $progress
* @param OutputInterface $output
* @param int|null $max
*/
private function startProgressBar($progress, OutputInterface $output, $max = null)
{
class_exists(ProgressBar::class) ? $progress->start($max) : $progress->start($output, $max);
}

/**
* @param ProgressBar|ProgressHelper $progress
* @param int $current
*/
private function advanceProgressBar($progress, $current)
{
class_exists(ProgressBar::class) ? $progress->setProgress($current) : $progress->setCurrent($current);
}

/**
* @param ProgressBar|ProgressHelper $progress
* @param ProgressBar $progress
* @param OutputInterface $output
*/
private function finishProgressBar($progress, OutputInterface $output)
Expand Down
33 changes: 33 additions & 0 deletions src/Resources/views/Form/_ckeditor_javascript.html.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
<?php

/*
* This file is part of the FOSCKEditor Bundle.
*
* (c) 2018 - present Friends of Symfony
* (c) 2009 - 2017 Eric GELOEN <geloen.eric@gmail.com>
*
* For the full copyright and license information, please read the LICENSE
* file that was distributed with this source code.
*/

use FOS\CKEditorBundle\Renderer\CKEditorRendererInterface;

/**
* @var CKEditorRendererInterface[] $view
* @var string $id
* @var string $base_path
* @var string $js_path
* @var string $jquery_path
* @var bool $jquery
* @var bool $require_js
* @var string[][] $styles
* @var string[][] $plugins
* @var string[][] $templates
* @var string $auto_inline
* @var string $input_sync
* @var string $inline
* @var string $filebrowsers
* @var array $config
*/

?>
<?php if ($autoload) : ?>
<script type="text/javascript">
var CKEDITOR_BASEPATH = "<?php echo $view['fos_ckeditor']->renderBasePath($base_path); ?>";
Expand Down
18 changes: 18 additions & 0 deletions src/Resources/views/Form/ckeditor_javascript.html.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
<?php

/*
* This file is part of the FOSCKEditor Bundle.
*
* (c) 2018 - present Friends of Symfony
* (c) 2009 - 2017 Eric GELOEN <geloen.eric@gmail.com>
*
* For the full copyright and license information, please read the LICENSE
* file that was distributed with this source code.
*/

/**
* @var bool $enable
* @var bool $async
*/

?>
<?php if ($enable && $async) : ?>
<?php include __DIR__.'/_ckeditor_javascript.html.php'; ?>
<?php endif; ?>
24 changes: 24 additions & 0 deletions src/Resources/views/Form/ckeditor_widget.html.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
<?php

/*
* This file is part of the FOSCKEditor Bundle.
*
* (c) 2018 - present Friends of Symfony
* (c) 2009 - 2017 Eric GELOEN <geloen.eric@gmail.com>
*
* For the full copyright and license information, please read the LICENSE
* file that was distributed with this source code.
*/

/**
* @var CKEditorRendererInterface|FormView[] $view
* @var object $form
* @var string $value
* @var bool $enable
* @var bool $async
*/

use FOS\CKEditorBundle\Renderer\CKEditorRendererInterface;
use Symfony\Component\Form\FormView;

?>
<textarea <?php echo $view['form']->block($form, 'attributes'); ?>><?php echo htmlspecialchars($value); ?></textarea>

<?php if ($enable && !$async) : ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ abstract class AbstractFOSCKEditorExtensionTest extends AbstractTestCase
private $container;

/**
* @var Packages|CoreAssetsHelper|\PHPUnit_Framework_MockObject_MockObject
* @var Packages|\PHPUnit_Framework_MockObject_MockObject
*/
private $packages;

Expand Down

0 comments on commit 212ad07

Please sign in to comment.