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

fop:log:clean - start #253

Draft
wants to merge 4 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devtools/fop_names_rules.neon
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ services:
-
class: FOP\Console\Tests\Validator\PhpStanNamesConsistencyService
arguments:
yamlServicesFilePath: '%currentWorkingDirectory%/config/services.yml'
yamlServicesFilePath: '%currentWorkingDirectory%/config/console_commands.yml'
8 changes: 8 additions & 0 deletions config/bus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:

prestashop.adapter.category.command_handler.add_root_category_handler:
class: FOP\Console\Adapter\Log\CommandHandler\CleanLogHandler
public: true
tags:
- name: tactician.handler
command: FOP\Console\Core\Domain\Log\Command\CleanLogCommand
105 changes: 105 additions & 0 deletions config/console_commands.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
services:
_defaults:
tags: [ console.command ]

fop.console.cache.clear.command:
class: FOP\Console\Commands\Cache\CacheClear

fop.console.category.clean.command:
class: FOP\Console\Commands\Category\CategoryClean

fop.console.category.products_count.command:
class: FOP\Console\Commands\Category\CategoryProductsCount

fop.console.configuration.export.command:
class: FOP\Console\Commands\Configuration\ConfigurationExport

fop.console.configuration.import.command:
class: FOP\Console\Commands\Configuration\ConfigurationImport

fop.console.container.check.command:
class: FOP\Console\Commands\Container\ContainerCheck

fop.console.employee.list.command:
class: FOP\Console\Commands\Employee\EmployeeList

fop.console.employee.change_password.command:
class: FOP\Console\Commands\Employee\EmployeeChangePassword

fop.console.environment.debug.command:
class: FOP\Console\Commands\Environment\EnvironmentDebug

fop.console.environment.get_parameters.command:
class: FOP\Console\Commands\Environment\EnvironmentGetParameters

fop.console.environment.setup_dev.command:
class: FOP\Console\Commands\Environment\EnvironmentSetupDev

fop.console.export.data.command:
class: FOP\Console\Commands\Export\ExportData

fop.console.generate.htaccess.command:
class: FOP\Console\Commands\Generate\GenerateHtaccess

fop.console.generate.robots.command:
class: FOP\Console\Commands\Generate\GenerateRobots

fop.console.group.transfer_customers.command:
class: FOP\Console\Commands\Group\GroupTransferCustomers

fop.console.hook.add.command:
class: FOP\Console\Commands\Hook\HookAdd

fop.console.image.generate_products.command:
class: FOP\Console\Commands\Image\ImageGenerateProducts

fop.console.image.generate_categories.command:
class: FOP\Console\Commands\Image\ImageGenerateCategories

fop.console.image.generate_manufacturers.command:
class: FOP\Console\Commands\Image\ImageGenerateManufacturers

fop.console.image.generate_suppliers.command:
class: FOP\Console\Commands\Image\ImageGenerateSuppliers

fop.console.image.generate_stores.command:
class: FOP\Console\Commands\Image\ImageGenerateStores

fop.console.module.unhook.command:
class: FOP\Console\Commands\Module\ModuleUnhook

fop.console.module.hook.command:
class: FOP\Console\Commands\Module\ModuleHook

fop.console.module.hooks.command:
class: FOP\Console\Commands\Module\ModuleHooks

fop.console.module.rename.command:
class: FOP\Console\Commands\Module\ModuleRename

fop.console.module.non_essential.command:
class: FOP\Console\Commands\Module\ModuleNonEssential

fop.console.module.generate.command:
class: FOP\Console\Commands\Module\ModuleGenerate

fop.console.override.make.command:
class: FOP\Console\Commands\Override\OverrideMake

fop.console.product.latest.command:
class: FOP\Console\Commands\Product\ProductLatest

fop.console.shop.status.command:
class: FOP\Console\Commands\Shop\ShopStatus

fop.console.shop.maintenance.command:
class: FOP\Console\Commands\Shop\ShopMaintenance

fop.console.theme.reset_layout.command:
class: FOP\Console\Commands\Theme\ThemeResetLayout

fop.console.about.version.command:
class: FOP\Console\Commands\About\AboutVersion

fop.console.log.clean.command:
class: FOP\Console\Commands\Log\LogClean
135 changes: 2 additions & 133 deletions config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,138 +9,7 @@ services:
- "@prestashop.adapter.shop.context"
- "%kernel.root_dir%"

fop.console.cache.clear.command:
class: FOP\Console\Commands\Cache\CacheClear
tags: [ console.command ]

fop.console.category.clean.command:
class: FOP\Console\Commands\Category\CategoryClean
tags: [ console.command ]

fop.console.category.products_count.command:
class: FOP\Console\Commands\Category\CategoryProductsCount
tags: [ console.command ]

fop.console.configuration.export.command:
class: FOP\Console\Commands\Configuration\ConfigurationExport
tags: [ console.command ]

fop.console.configuration.import.command:
class: FOP\Console\Commands\Configuration\ConfigurationImport
tags: [ console.command ]

fop.console.container.check.command:
class: FOP\Console\Commands\Container\ContainerCheck
tags: [ console.command ]

fop.console.employee.list.command:
class: FOP\Console\Commands\Employee\EmployeeList
tags: [ console.command ]

fop.console.employee.change_password.command:
class: FOP\Console\Commands\Employee\EmployeeChangePassword
tags: [ console.command ]

fop.console.environment.debug.command:
class: FOP\Console\Commands\Environment\EnvironmentDebug
tags: [ console.command ]

fop.console.environment.get_parameters.command:
class: FOP\Console\Commands\Environment\EnvironmentGetParameters
tags: [ console.command ]

fop.console.environment.setup_dev.command:
class: FOP\Console\Commands\Environment\EnvironmentSetupDev
tags: [ console.command ]

fop.console.export.data.command:
class: FOP\Console\Commands\Export\ExportData
tags: [ console.command ]

fop.console.generate.htaccess.command:
class: FOP\Console\Commands\Generate\GenerateHtaccess
tags: [ console.command ]

fop.console.generate.robots.command:
class: FOP\Console\Commands\Generate\GenerateRobots
tags: [ console.command ]

fop.console.group.transfer_customers.command:
class: FOP\Console\Commands\Group\GroupTransferCustomers
tags: [ console.command ]

fop.console.hook.add.command:
class: FOP\Console\Commands\Hook\HookAdd
tags: [ console.command ]

fop.console.image.generate_products.command:
class: FOP\Console\Commands\Image\ImageGenerateProducts
tags: [ console.command ]

fop.console.image.generate_categories.command:
class: FOP\Console\Commands\Image\ImageGenerateCategories
tags: [ console.command ]

fop.console.image.generate_manufacturers.command:
class: FOP\Console\Commands\Image\ImageGenerateManufacturers
tags: [ console.command ]

fop.console.image.generate_suppliers.command:
class: FOP\Console\Commands\Image\ImageGenerateSuppliers
tags: [ console.command ]

fop.console.image.generate_stores.command:
class: FOP\Console\Commands\Image\ImageGenerateStores
tags: [ console.command ]

fop.console.module.unhook.command:
class: FOP\Console\Commands\Module\ModuleUnhook
tags: [ console.command ]

fop.console.module.hook.command:
class: FOP\Console\Commands\Module\ModuleHook
tags: [ console.command ]

fop.console.module.hooks.command:
class: FOP\Console\Commands\Module\ModuleHooks
tags: [ console.command ]

fop.console.module.rename.command:
class: FOP\Console\Commands\Module\ModuleRename
tags: [ console.command ]

fop.console.module.non_essential.command:
class: FOP\Console\Commands\Module\ModuleNonEssential
tags: [ console.command ]

fop.console.module.generate.command:
class: FOP\Console\Commands\Module\ModuleGenerate
tags: [ console.command ]

fop.console.override.make.command:
class: FOP\Console\Commands\Override\OverrideMake
tags: [ console.command ]

fop.console.product.latest.command:
class: FOP\Console\Commands\Product\ProductLatest
tags: [ console.command ]

fop.console.shop.status.command:
class: FOP\Console\Commands\Shop\ShopStatus
tags: [ console.command ]

fop.console.shop.maintenance.command:
class: FOP\Console\Commands\Shop\ShopMaintenance
tags: [ console.command ]

fop.console.theme.reset_layout.command:
class: FOP\Console\Commands\Theme\ThemeResetLayout
tags: [ console.command ]

fop.console.about.version.command:
class: FOP\Console\Commands\About\AboutVersion
tags: [ console.command ]


imports:
- { resource: console_commands.yml }
- { resource: overriders.yml }
- { resource: bus.yml }
34 changes: 34 additions & 0 deletions src/Adapter/Log/CommandHandler/CleanLogHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* Copyright (c) Since 2020 Friends of Presta
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file docs/licenses/LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to infos@friendsofpresta.org so we can send you a copy immediately.
*
* @author Friends of Presta <infos@friendsofpresta.org>
* @copyright since 2020 Friends of Presta
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License ("AFL") v. 3.0
*
*/

declare(strict_types=1);

namespace FOP\Console\Adapter\Log\CommandHandler;

use FOP\Console\Core\Domain\Log\Command\CleanLogCommand;
use FOP\Console\Core\Domain\Log\CommandHandler\CleanLogHandlerInterface;

final class CleanLogHandler implements CleanLogHandlerInterface
{
public function handle(CleanLogCommand $command): void
{
throw new \Exception('implement me');
}
}
58 changes: 58 additions & 0 deletions src/Commands/Log/LogClean.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php
/**
* Copyright (c) Since 2020 Friends of Presta
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file docs/licenses/LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to infos@friendsofpresta.org so we can send you a copy immediately.
*
* @author Friends of Presta <infos@friendsofpresta.org>
* @copyright since 2020 Friends of Presta
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License ("AFL") v. 3.0
*
*/

declare(strict_types=1);

namespace FOP\Console\Commands\Log;

use FOP\Console\Command;
use FOP\Console\Core\Domain\Log\Command\CleanLogCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

final class LogClean extends Command
{
protected function configure(): void
{
$this->setName('fop:log:clean')
->setDescription('Clears the PrestaShop (legacy) logs.');
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
try {
$otto = $this->getContainer()->get('prestashop.core.query_bus');
$cleanQuery = new CleanLogCommand();
$otto->handle($cleanQuery);

$this->io->warning('Not implemented.');
// $this->io->success('Logs cleaned.');

return 0;
} catch (\Throwable $throwable) {
if (_PS_MODE_DEV_ || $output->isVerbose()) {
throw $throwable;
}
$this->io->error(sprintf('%s failed : %s', $this->getName(), $throwable->getMessage()));

return 1;
}
}
}
31 changes: 31 additions & 0 deletions src/Core/Domain/Log/Command/CleanLogCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/**
* Copyright (c) Since 2020 Friends of Presta
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file docs/licenses/LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to infos@friendsofpresta.org so we can send you a copy immediately.
*
* @author Friends of Presta <infos@friendsofpresta.org>
* @copyright since 2020 Friends of Presta
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License ("AFL") v. 3.0
*
*/

declare(strict_types=1);

namespace FOP\Console\Core\Domain\Log\Command;

class CleanLogCommand
{
public function __construct()
{
throw new \Exception('implement me');
}
}
Loading