Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add log command #3

Merged
merged 2 commits into from
Oct 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"require": {
"symfony/framework-bundle": "~2.3|~3.0",
"symfony/console": "~2.3|~3.0",
"dekalee/cdn77": "~1"
"dekalee/cdn77": "~1.2"
},
"suggest": {
"eightpoints/guzzle-bundle": "To enable guzzle query debugging"
Expand Down
46 changes: 46 additions & 0 deletions src/Cdn77Bundle/Command/PathLoggedForResourceCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace Dekalee\Cdn77Bundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

/**
* Class PathLoggedForResourceCommand
*/
class PathLoggedForResourceCommand extends ContainerAwareCommand
{
/**
* Configure the command
*/
protected function configure()
{
$this
->setName('dekalee:cdn77:path-logged-for-resource')
->setDescription('Get all the path stored in the log for a resource')
->addOption('resource', null, InputOption::VALUE_REQUIRED, 'The resource to get the log from')
;
}

/**
* @param InputInterface $input
* @param OutputInterface $output
*
* @return int|null|void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$ressource = $input->getOption('resource');

$logs = $this->getContainer()->get('dekalee_cdn77.query.resource_log')->execute($ressource);

$output->writeln('List of file in the log');

foreach ($logs as $log) {
$output->writeln($log['path']);
}
}
}
1 change: 1 addition & 0 deletions src/Cdn77Bundle/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function getConfigTreeBuilder()
->scalarNode('create')->end()
->scalarNode('purge')->end()
->scalarNode('purge_all')->end()
->scalarNode('resource_log')->end()
->end()
->end()
->end();
Expand Down
2 changes: 2 additions & 0 deletions src/Cdn77Bundle/DependencyInjection/DekaleeCdn77Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Dekalee\Cdn77\Query\ListResourcesQuery;
use Dekalee\Cdn77\Query\PurgeAllQuery;
use Dekalee\Cdn77\Query\PurgeFileQuery;
use Dekalee\Cdn77\Query\ResourceLogQuery;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
Expand Down Expand Up @@ -35,6 +36,7 @@ public function load(array $configs, ContainerBuilder $container)
'purge' => PurgeFileQuery::URL,
'purge_all' => PurgeAllQuery::URL,
'create' => CreateResourceQuery::URL,
'resource_log' => ResourceLogQuery::URL,
] as $queryType => $url) {
if (array_key_exists($queryType, $config['url'])) {
$url = $config['url'][$queryType];
Expand Down
9 changes: 9 additions & 0 deletions src/Cdn77Bundle/Resources/config/query.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ parameters:
dekalee_cdn77.query.purge_file.class: Dekalee\Cdn77\Query\PurgeFileQuery
dekalee_cdn77.query.purge_all.class: Dekalee\Cdn77\Query\PurgeAllQuery
dekalee_cdn77.query.create_resource.class: Dekalee\Cdn77\Query\CreateResourceQuery
dekalee_cdn77.query.resource_log.class: Dekalee\Cdn77\Query\ResourceLogQuery

services:
dekalee_cdn77.query.list_resources:
Expand Down Expand Up @@ -35,3 +36,11 @@ services:
- '%dekalee_cdn77.api.password%'
- '%dekalee_cdn77.url.create%'
- '@guzzle.client.cdn77'
dekalee_cdn77.query.resource_log:
class: '%dekalee_cdn77.query.resource_log.class%'
arguments:
- '@dekalee_cdn77.query.list_resources'
- '%dekalee_cdn77.api.login%'
- '%dekalee_cdn77.api.password%'
- '%dekalee_cdn77.url.resource_log%'
- '@guzzle.client.cdn77'