Permalink
Browse files

Add service markdown chanelle

  • Loading branch information...
tesshsu committed Apr 4, 2018
1 parent 233e639 commit 0aa3926681a02dfe84b1fd697ae3006103b79ed5
Showing with 405 additions and 251 deletions.
  1. +2 −0 .idea/php.xml
  2. +2 −0 .idea/the_spacebar.iml
  3. +257 −248 .idea/workspace.xml
  4. +1 −0 composer.json
  5. +117 −1 composer.lock
  6. +1 −0 config/bundles.php
  7. +2 −0 config/packages/monolog.yaml
  8. +3 −1 config/services.yaml
  9. +8 −1 src/Service/MarkdownHelper.php
  10. +12 −0 symfony.lock
@@ -70,6 +70,8 @@
<path value="$PROJECT_DIR$/vendor/ocramius/proxy-manager" />
<path value="$PROJECT_DIR$/vendor/zendframework/zend-code" />
<path value="$PROJECT_DIR$/vendor/zendframework/zend-eventmanager" />
<path value="$PROJECT_DIR$/vendor/nikic/php-parser" />
<path value="$PROJECT_DIR$/vendor/symfony/maker-bundle" />
</include_path>
</component>
<component name="PhpProjectSharedConfiguration" php_language_level="7.1" />
@@ -22,6 +22,7 @@
<excludeFolder url="file://$MODULE_DIR$/vendor/knplabs/knp-markdown-bundle" />
<excludeFolder url="file://$MODULE_DIR$/vendor/michelf/php-markdown" />
<excludeFolder url="file://$MODULE_DIR$/vendor/monolog/monolog" />
<excludeFolder url="file://$MODULE_DIR$/vendor/nikic/php-parser" />
<excludeFolder url="file://$MODULE_DIR$/vendor/ocramius/package-versions" />
<excludeFolder url="file://$MODULE_DIR$/vendor/ocramius/proxy-manager" />
<excludeFolder url="file://$MODULE_DIR$/vendor/psr/cache" />
@@ -47,6 +48,7 @@
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/http-kernel" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/inflector" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/intl" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/maker-bundle" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/monolog-bridge" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/monolog-bundle" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/options-resolver" />

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -12,6 +12,7 @@
"symfony/form": "^4.0",
"symfony/framework-bundle": "^4.0",
"symfony/lts": "^4@dev",
"symfony/maker-bundle": "^1.3",
"symfony/monolog-bundle": "^3.2",
"symfony/orm-pack": "^1.0",
"symfony/security-bundle": "^4.0",

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -12,4 +12,5 @@
Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
];
@@ -0,0 +1,2 @@
monolog:
channels: ['markdown']
@@ -11,7 +11,9 @@ services:
public: false # Allows optimizing the container by removing unused services; this also means
# fetching services directly from the container via $container->get() won't work.
# The best practice is to be explicit about your dependencies anyway.
# setup special, global autowiring rules
bind:
$markdownLogger: '@monolog.logger.markdown'
# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name
App\:
@@ -2,20 +2,27 @@
namespace App\Service;
use Michelf\MarkdownInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\Cache\Adapter\AdapterInterface;
class MarkdownHelper
{
private $cache;
private $markdown;
public function __construct(AdapterInterface $cache, MarkdownInterface $markdown)
private $logger;
public function __construct(AdapterInterface $cache, MarkdownInterface $markdown, LoggerInterface $markdownLogger)
{
$this->cache = $cache;
$this->markdown = $markdown;
$this->logger = $markdownLogger;
}
public function parse(string $source): string
{
if (stripos($source, 'Spicy') !== false) {
$this->logger->info('They are talking about spicy again!');
}
$item = $this->cache->getItem('markdown_'.md5($source));
if (!$item->isHit()) {
$item->set($this->markdown->transform($source));
@@ -68,6 +68,9 @@
"monolog/monolog": {
"version": "1.23.0"
},
"nikic/php-parser": {
"version": "v4.0.1"
},
"ocramius/package-versions": {
"version": "1.3.0"
},
@@ -170,6 +173,15 @@
"symfony/lts": {
"version": "4-dev"
},
"symfony/maker-bundle": {
"version": "1.0",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "1.0",
"ref": "fadbfe33303a76e25cb63401050439aa9b1a9c7f"
}
},
"symfony/monolog-bridge": {
"version": "v4.0.6"
},

0 comments on commit 0aa3926

Please sign in to comment.