Skip to content

Commit

Permalink
Merge pull request #2 from Saeven/master
Browse files Browse the repository at this point in the history
Moving it up
  • Loading branch information
Saeven committed Oct 10, 2016
2 parents 46aa26e + 08f6596 commit f31d7a6
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 26 deletions.
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@
},
"require": {
"php": ">=5.5",
"zendframework/zend-filter": "^2.5",
"zendframework/zend-filter": "^2.7.1",
"ezyang/htmlpurifier": "^4.5"
},
"require-dev": {
"zendframework/zend-servicemanager": "^3.0.1",
"zendframework/zend-view": "@stable",
"zendframework/zend-view": "^2.8.1",
"phpunit/phpunit": "^4.8",
"php-vfs/php-vfs": "^1.3",
"fabpot/php-cs-fixer": "^1.11",
"zendframework/zend-mvc": "^3.0.1",
"zendframework/zend-inputfilter": "^2.7.3",
"zendframework/zend-serializer": "^2.5",
"zendframework/zend-log": "^2.6",
"zendframework/zend-i18n": "^2.5",
"zendframework/zend-console": "^2.5",
"zendframework/zend-serializer": "^2.8.0",
"zendframework/zend-log": "^2.9.1",
"zendframework/zend-i18n": "^2.7.3",
"zendframework/zend-console": "^2.6.0",
"zendframework/zend-http": "^2.5"
},
"suggest": {
Expand Down
8 changes: 3 additions & 5 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
use HTMLPurifier;
use HTMLPurifier_Config;

return array(
return [
'soflomo_purifier' => [
'standalone' => false,
'standalone' => false,
'standalone_path' => 'vendor/ezyang/htmlpurifier/library/HTMLPurifier.standalone.php',
],

'service_manager' => [
'factories' => [
HTMLPurifier::class => Factory\HtmlPurifierFactory::class,
HTMLPurifier::class => Factory\HtmlPurifierFactory::class,
HTMLPurifier_Config::class => Factory\HtmlPurifierConfigFactory::class,
],
],
Expand All @@ -38,4 +38,4 @@
PurifierViewHelper::ALIAS => PurifierViewHelper::class,
],
],
);
];
18 changes: 9 additions & 9 deletions src/Factory/HtmlPurifierConfigFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ class HtmlPurifierConfigFactory
public function __invoke(ServiceLocatorInterface $serviceLocator)
{
$configService = $serviceLocator->get('config');
$moduleConfig = isset($configService['soflomo_purifier']) ? $configService['soflomo_purifier'] : [];
$moduleConfig = isset($configService['soflomo_purifier']) ? $configService['soflomo_purifier'] : [];

if ($moduleConfig['standalone']) {
if (! file_exists($moduleConfig['standalone_path'])) {
if (!file_exists($moduleConfig['standalone_path'])) {
throw new RuntimeException('Could not find standalone purifier file');
}

include_once $moduleConfig['standalone_path'];
}

$config = isset($moduleConfig['config']) ? $moduleConfig['config'] : [ ];
$definitions = isset($moduleConfig['definitions']) ? $moduleConfig['definitions'] : [ ];
$config = isset($moduleConfig['config']) ? $moduleConfig['config'] : [];
$definitions = isset($moduleConfig['definitions']) ? $moduleConfig['definitions'] : [];

$purifierConfig = self::createConfig($config, $definitions);

Expand All @@ -43,8 +43,8 @@ public function __invoke(ServiceLocatorInterface $serviceLocator)
*/
public static function createConfig(array $config, array $definitions = [])
{
if (! empty($config['definitions'])) {
$definitions = $config['definitions'];
if (!empty($config['definitions'])) {
$definitions = $config['definitions'];
unset($config['definitions']);
}

Expand All @@ -53,15 +53,15 @@ public static function createConfig(array $config, array $definitions = [])
foreach ($definitions as $type => $methods) {
$definition = $purifierConfig->getDefinition($type, true, true);

if (! $definition) {
if (!$definition) {
// definition is cached, skip iteration
continue;
}

foreach ($methods as $method => $invocations) {
$invocations = self::convertSingleInvocationToArray($invocations);
foreach ($invocations as $args) {
call_user_func_array([ $definition, $method ], $args);
call_user_func_array([$definition, $method], $args);
}
}
}
Expand All @@ -88,6 +88,6 @@ private static function convertSingleInvocationToArray(array $invocations)
return $invocations;
}

return [ $invocations ];
return [$invocations];
}
}
2 changes: 1 addition & 1 deletion src/Factory/HtmlPurifierFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class HtmlPurifierFactory
public function __invoke(ServiceLocatorInterface $serviceLocator)
{
$purifierConfig = $serviceLocator->get(HTMLPurifier_Config::class);
$purifier = new HTMLPurifier($purifierConfig);
$purifier = new HTMLPurifier($purifierConfig);

return $purifier;
}
Expand Down
1 change: 1 addition & 0 deletions src/Factory/PurifierViewHelperFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class PurifierViewHelperFactory implements FactoryInterface
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
$htmlPurifier = $container->get('HTMLPurifier');

return new PurifierViewHelper($htmlPurifier);
}
}
2 changes: 1 addition & 1 deletion src/PurifierFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(HTMLPurifier $purifier, $options = [])
{
$this->purifier = $purifier;

if (! empty($options)) {
if (!empty($options)) {
$this->setOptions($options);
}
}
Expand Down

0 comments on commit f31d7a6

Please sign in to comment.