Skip to content

Commit

Permalink
Merge pull request #2 from kokspflanze/develop
Browse files Browse the repository at this point in the history
zend-servicemanager 3
  • Loading branch information
kokspflanze committed Jun 6, 2016
2 parents f791e9f + c7a5907 commit 65651b5
Show file tree
Hide file tree
Showing 12 changed files with 195 additions and 175 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: php

php:
- 5.5
- 5.6
- 7
- hhvm
Expand All @@ -10,7 +9,8 @@ matrix:
fast_finish: true

before_script:
- composer update --prefer-source --dev
- composer selfupdate
- composer update

script:
- mkdir -p build/logs
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# ZfcBBCode
Zendframework 2 Module to convert BBCode to HTML
Zendframework Module to convert BBCode to HTML

Master
[![Build Status](https://travis-ci.org/kokspflanze/ZfcBBCode.svg?branch=master)](https://travis-ci.org/kokspflanze/ZfcBBCode?branch=master)
[![Coverage Status](https://coveralls.io/repos/kokspflanze/ZfcBBCode/badge.svg?branch=master)](https://coveralls.io/r/kokspflanze/ZfcBBCode?branch=master)

## SYSTEM REQUIREMENTS

requires PHP 5.5 or later.
requires PHP 5.6 or later.

## INSTALLATION

Expand Down
16 changes: 5 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,14 @@
}
],
"require": {
"php": ">=5.5",
"zendframework/zend-modulemanager": "~2.5",
"zendframework/zend-servicemanager": "~2.5",
"zendframework/zend-mvc": "~2.5",
"zendframework/zend-loader": "~2.5",
"zendframework/zend-config": "~2.5",
"zendframework/zend-view": "~2.5",
"zendframework/zend-serializer": "~2.5",
"zendframework/zend-log": "~2.5",
"zendframework/zend-i18n": "~2.5",
"php": ">=5.6",
"zendframework/zend-servicemanager": "~3.0",
"zendframework/zend-validator": "~2.8",
"zendframework/zend-view": "~2.7",
"kokspflanze/sbb-code-parser": "~0.1"
},
"require-dev": {
"phpunit/phpunit": "~4|~5",
"phpunit/phpunit": "~4.8|~5.3",
"satooshi/php-coveralls": "dev-master"
}
}
24 changes: 22 additions & 2 deletions config/module.config.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
<?php

use ZfcBBCode\Service;
use ZfcBBCode\View\Helper;

$serverName = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : '';

return [
'service_manager' => [
'aliases' => [
'zfc-bbcode_parser' => Service\SBBCodeParser::class,
],
'factories' => [
Service\SBBCodeParser::class => Service\SBBCodeParserFactory::class,
],
],
'view_helpers' => [
'aliases' => [
'bbCodeParser' => Helper\BBCodeParser::class
],
'factories' => [
Helper\BBCodeParser::class => Helper\BBCodeParserFactory::class,
],
],
'zfc-bbcode' => [
'emoticons' => [
'active' => false,
Expand Down Expand Up @@ -36,7 +56,7 @@
':unsure:' => $serverName . '/minified/emoticons/unsure.png',
':woot:' => $serverName . '/minified/emoticons/woot.png',
':wassat:' => $serverName . '/minified/emoticons/wassat.png'
]
]
],
],
],
];
44 changes: 1 addition & 43 deletions src/ZfcBBCode/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace ZfcBBCode;

use Zend\ServiceManager\AbstractPluginManager;

class Module
{
Expand All @@ -14,36 +13,6 @@ public function getConfig()
return include __DIR__ . '/../../config/module.config.php';
}

/**
* @return array
*/
public function getAutoloaderConfig()
{
return [
'Zend\Loader\StandardAutoloader' => [
'namespaces' => [
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
],
],
];
}

/**
* @return array
*/
public function getViewHelperConfig()
{
return [
'factories' => [
'bbCodeParser' => function (AbstractPluginManager $pluginManager) {
/** @var \ZfcBBCode\Service\ParserInterface $bbCodeParser */
$bbCodeParser = $pluginManager->getServiceLocator()->get('zfc-bbcode_parser');
return new View\Helper\BBCodeParser($bbCodeParser);
},
]
];
}

/**
* Expected to return \Zend\ServiceManager\Config object or array to
* seed such an object.
Expand All @@ -52,17 +21,6 @@ public function getViewHelperConfig()
*/
public function getServiceConfig()
{
return [
'aliases' => [
'zfc-bbcode_parser' => Service\SBBCodeParser::class,
],
'factories' => [
Service\SBBCodeParser::class => function ($sm) {
/** @var $sm \Zend\ServiceManager\ServiceLocatorInterface */
$config = $sm->get('Configuration');
return new Service\SBBCodeParser($config['zfc-bbcode']);
},
],
];
return [];
}
}
6 changes: 4 additions & 2 deletions src/ZfcBBCode/Service/SBBCodeParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace ZfcBBCode\Service;

use SBBCodeParser\Node_Container_Document;

class SBBCodeParser implements ParserInterface
{
/** @var array */
Expand All @@ -24,7 +26,7 @@ public function __construct(array $configData)
*/
public function getParsedText($text)
{
$parser = new \SBBCodeParser\Node_Container_Document(true, false);
$parser = new Node_Container_Document(true, false);

if ($this->configData['emoticons']['active']) {
$parser->add_emoticons($this->configData['emoticons']['path']);
Expand All @@ -49,7 +51,7 @@ public function getParsedText($text)
*/
public function isTextValid($text)
{
$parser = new \SBBCodeParser\Node_Container_Document();
$parser = new Node_Container_Document();

if ($this->configData['emoticons']['active']) {
$parser->add_emoticons($this->configData['emoticons']['path']);
Expand Down
23 changes: 23 additions & 0 deletions src/ZfcBBCode/Service/SBBCodeParserFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php


namespace ZfcBBCode\Service;


use Interop\Container\ContainerInterface;
use Zend\ServiceManager\Factory\FactoryInterface;

class SBBCodeParserFactory implements FactoryInterface
{
/**
* @param ContainerInterface $container
* @param string $requestedName
* @param array|null $options
* @return SBBCodeParser
*/
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
return new SBBCodeParser($container->get('Configuration')['zfc-bbcode']);
}

}
2 changes: 1 addition & 1 deletion src/ZfcBBCode/View/Helper/BBCodeParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace ZfcBBCode\View\Helper;

use Zend\Form\View\Helper\AbstractHelper;
use Zend\View\Helper\AbstractHelper;
use ZfcBBCode\Service\ParserInterface;

class BBCodeParser extends AbstractHelper
Expand Down
23 changes: 23 additions & 0 deletions src/ZfcBBCode/View/Helper/BBCodeParserFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php


namespace ZfcBBCode\View\Helper;


use Interop\Container\ContainerInterface;
use Zend\ServiceManager\Factory\FactoryInterface;

class BBCodeParserFactory implements FactoryInterface
{
/**
* @param ContainerInterface $container
* @param string $requestedName
* @param array|null $options
* @return BBCodeParser
*/
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
return new BBCodeParser($container->get('zfc-bbcode_parser'));
}

}
Loading

0 comments on commit 65651b5

Please sign in to comment.