Skip to content

Commit

Permalink
#127 - removed HighlightProviderFactory and replaced all references t…
Browse files Browse the repository at this point in the history
…o it with the new ServiceFactory class
  • Loading branch information
alphadevx committed Dec 31, 2017
1 parent 937ecfa commit 65cd22c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 103 deletions.
97 changes: 0 additions & 97 deletions Alpha/Util/Code/Highlight/HighlightProviderFactory.php

This file was deleted.

4 changes: 2 additions & 2 deletions Alpha/Util/Extension/Markdown.php
Expand Up @@ -4,7 +4,7 @@

use Alpha\Util\Config\ConfigProvider;
use Michelf\MarkdownExtra;
use Alpha\Util\Code\Highlight\HighlightProviderFactory;
use Alpha\Util\Service\ServiceFactory;

/**
* A custom version of the Markdown class which uses the geshi library for rendering code.
Expand Down Expand Up @@ -82,7 +82,7 @@ public function _doCodeBlocks_callback($matches)
}

if ($config->get('cms.highlight.provider.name') != '') {
$highlighter = HighlightProviderFactory::getInstance($config->get('cms.highlight.provider.name'));
$highlighter = ServiceFactory::getInstance($config->get('cms.highlight.provider.name'), 'Alpha\Util\Code\Highlight\HighlightProviderInterface');
$codeblock = $highlighter->highlight($codeblock, $language);
} else {
$codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES);
Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -502,11 +502,11 @@ A data cache is provided, that provides a factory and injectable providers that

The _Alpha\Util\Code\Highlight\HighlightProviderFactory_ providers objects for converting plain source code into code-highlighted HTML source code. Providers for the Geshi and Luminous libraries are provided. Here is an example:

use Alpha\Util\Code\Highlight\HighlightProviderFactory;
use Alpha\Util\Service\ServiceFactory;

// ...

$highlighter = HighlightProviderFactory::getInstance('Alpha\Util\Code\Highlight\HighlightProviderGeshi');
$highlighter = ServiceFactory::getInstance('Alpha\Util\Code\Highlight\HighlightProviderGeshi','Alpha\Util\Code\Highlight\HighlightProviderInterface');

$html = $highlighter->highlight($code, 'php');

Expand Down
4 changes: 2 additions & 2 deletions test/Alpha/Test/Util/Code/Highlight/HighlightProviderTest.php
Expand Up @@ -2,7 +2,7 @@

namespace Alpha\Test\Util\Code\Highlight;

use Alpha\Util\Code\Highlight\HighlightProviderFactory;
use Alpha\Util\Service\ServiceFactory;
use Alpha\Util\Helper\Validator;

/**
Expand Down Expand Up @@ -72,7 +72,7 @@ public function getHighlightProviders()
*/
public function testHighlight($provider)
{
$highlighter = HighlightProviderFactory::getInstance($provider);
$highlighter = ServiceFactory::getInstance($provider, 'Alpha\Util\Code\Highlight\HighlightProviderInterface');

$code = '<?= $value ?>';

Expand Down

0 comments on commit 65cd22c

Please sign in to comment.