Skip to content

Commit

Permalink
Merge pull request #24 from Happyr/blackhole
Browse files Browse the repository at this point in the history
Added blackhole and filesystem service
  • Loading branch information
Nyholm committed Feb 25, 2016
2 parents 4edfa4d + a08288a commit ee7cef2
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function getConfigTreeBuilder()
$root = $treeBuilder->root('happyr_translation');

$root->children()
->enumNode('translation_service')->values(array('loco', 'foobar'))->defaultValue('loco')->end()
->enumNode('translation_service')->values(array('blackhole', 'filesystem', 'loco'))->defaultValue('loco')->end()
->scalarNode('target_dir')->defaultValue('%kernel.root_dir%/Resources/translations')->end()
->scalarNode('httplug_client')->defaultValue('httplug.client')->cannotBeEmpty()->end()
->scalarNode('httplug_message_factory')->defaultValue('httplug.message_factory')->cannotBeEmpty()->end()
Expand Down Expand Up @@ -48,7 +48,6 @@ private function getProjectNode()
$treeBuilder = new TreeBuilder();
$node = $treeBuilder->root('projects');
$node
->isRequired()
->useAttributeAsKey('name')
->prototype('array')
->children()
Expand Down
7 changes: 7 additions & 0 deletions src/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ services:
tags:
- { name: 'data_collector', template: "@HappyrTranslation/Profiler/translation", id: "translation", priority: 200 }

happyr.translation.service.blackhole:
class: Happyr\TranslationBundle\Service\Blackhole

happyr.translation.service.filesystem:
class: Happyr\TranslationBundle\Service\Filesystem
arguments: ['@happyr.translation.filesystem']

happyr.translation.service.loco:
class: Happyr\TranslationBundle\Service\Loco
arguments:
Expand Down
51 changes: 51 additions & 0 deletions src/Service/Blackhole.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace Happyr\TranslationBundle\Service;

use Happyr\TranslationBundle\Model\Message;

class Blackhole implements TranslationServiceInterface
{
/**
* @inheritDoc
*/
public function fetchTranslation(Message $message, $updateFs = false)
{
}

/**
* @inheritDoc
*/
public function updateTranslation(Message $message)
{
}

/**
* @inheritDoc
*/
public function flagTranslation(Message $message, $type = 0)
{
}

/**
* @inheritDoc
*/
public function createAsset(Message $message)
{
}

/**
* @inheritDoc
*/
public function downloadAllTranslations()
{
}

/**
* @inheritDoc
*/
public function synchronizeAllTranslations()
{
}

}
70 changes: 70 additions & 0 deletions src/Service/Filesystem.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

namespace Happyr\TranslationBundle\Service;

use Happyr\TranslationBundle\Model\Message;
use Happyr\TranslationBundle\Translation\FilesystemUpdater;

class Filesystem implements TranslationServiceInterface
{
/**
* @var FilesystemUpdater filesystemService
*/
private $filesystemService;

/**
*
* @param FilesystemUpdater $filesystemService
*/
public function __construct(FilesystemUpdater $filesystemService)
{
$this->filesystemService = $filesystemService;
}

/**
* @inheritDoc
*/
public function fetchTranslation(Message $message, $updateFs = false)
{
if ($updateFs) {
$this->filesystemService->updateMessageCatalog([$message]);
}
}

/**
* @inheritDoc
*/
public function updateTranslation(Message $message)
{
$this->filesystemService->updateMessageCatalog([$message]);
}

/**
* @inheritDoc
*/
public function flagTranslation(Message $message, $type = 0)
{
}

/**
* @inheritDoc
*/
public function createAsset(Message $message)
{
}

/**
* @inheritDoc
*/
public function downloadAllTranslations()
{
}

/**
* @inheritDoc
*/
public function synchronizeAllTranslations()
{
}

}

0 comments on commit ee7cef2

Please sign in to comment.