diff --git a/.phive/phars.xml b/.phive/phars.xml new file mode 100755 index 00000000..4e204fae --- /dev/null +++ b/.phive/phars.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/commands.md b/commands.md new file mode 100755 index 00000000..a0c7d50d --- /dev/null +++ b/commands.md @@ -0,0 +1,623 @@ + +* [`fop:add-hook`](#fopadd-hook) +* [`fop:check-container`](#fopcheck-container) +* [`fop:clear-cache`](#fopclear-cache) +* [`fop:debug-mode`](#fopdebug-mode) +* [`fop:export`](#fopexport) +* [`fop:generate:htaccess`](#fopgeneratehtaccess) +* [`fop:generate:robots`](#fopgeneraterobots) +* [`fop:hook-module`](#fophook-module) +* [`fop:images:generate:categories`](#fopimagesgeneratecategories) +* [`fop:images:generate:manufacturers`](#fopimagesgeneratemanufacturers) +* [`fop:images:generate:products`](#fopimagesgenerateproducts) +* [`fop:images:generate:stores`](#fopimagesgeneratestores) +* [`fop:images:generate:suppliers`](#fopimagesgeneratesuppliers) +* [`fop:latest-products`](#foplatest-products) +* [`fop:maintenance`](#fopmaintenance) +* [`fop:module:hooks`](#fopmodulehooks) +* [`fop:shop-status`](#fopshop-status) +* [`fop:theme-reset`](#foptheme-reset) +* [`fop:unhook-module`](#fopunhook-module) + +Symfony console options +----------------------- + +This options are available for all commands. + +#### `--help|-h` + +Display this help message + +* Accept value: no +* Is value required: no +* Is multiple: no +* Default: `false` + +#### `--quiet|-q` + +Do not output any message + +* Accept value: no +* Is value required: no +* Is multiple: no +* Default: `false` + +#### `--verbose|-v|-vv|-vvv` + +Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug + +* Accept value: no +* Is value required: no +* Is multiple: no +* Default: `false` + +#### `--version|-V` + +Display this application version + +* Accept value: no +* Is value required: no +* Is multiple: no +* Default: `false` + +#### `--ansi` + +Force ANSI output + +* Accept value: no +* Is value required: no +* Is multiple: no +* Default: `false` + +#### `--no-ansi` + +Disable ANSI output + +* Accept value: no +* Is value required: no +* Is multiple: no +* Default: `false` + +#### `--no-interaction|-n` + +Do not ask any interactive question + +* Accept value: no +* Is value required: no +* Is multiple: no +* Default: `false` + +#### `--env|-e` + +The Environment name. + +* Accept value: yes +* Is value required: yes +* Is multiple: no +* Default: `'dev'` + +#### `--no-debug` + +Switches off debug mode. + +* Accept value: no +* Is value required: no +* Is multiple: no +* Default: `false` + + +`fop:add-hook` +-------------- + +Create hook in database + +### Usage + +* `fop:add-hook [--name [NAME]] [--title [TITLE]] [--description [DESCRIPTION]]` + +This command allows you create a new hook in database, + you dont need to graft a module on it! + +### Options + +#### `--name` + +Name for the new Hook + +* Accept value: yes +* Is value required: no +* Is multiple: no +* Default: `NULL` + +#### `--title` + +Title for the Hook + +* Accept value: yes +* Is value required: no +* Is multiple: no +* Default: `NULL` + +#### `--description` + +Description for the Hook + +* Accept value: yes +* Is value required: no +* Is multiple: no +* Default: `NULL` + + +`fop:check-container` +--------------------- + +Health check of the Service Container + +### Usage + +* `fop:check-container` + +This command instantiate every service of Symfony in Console Context: will it works as expected ? + +### Options + +`fop:clear-cache` +----------------- + +Replace the cache directory with an empty one. + +### Usage + +* `fop:clear-cache` + +This command allows you to quickly remove the cache files. + + +`fop:debug-mode` +---------------- + +Enable or Disable debug mode. + +### Usage + +* `fop:debug-mode []` + +Get or change debug mode. Change _PS_MODE_DEV_ value. + +### Arguments + +#### `action` + +enable or disable debug mode ( possible values : status,enable,disable,toggle) + +* Is required: no +* Is array: no +* Default: `'status'` + + +`fop:export` +------------ + +Allows to export data in XML + +### Usage + +* `fop:export [-l|--limit LIMIT] [--] []` + +This command allows you to export most of your data in XML + +### Arguments + +#### `model` + +The Object Model to export + +* Is required: no +* Is array: no +* Default: `'Product'` + +### Options + +#### `--limit|-l` + +The limit if any, default to 100 + +* Accept value: yes +* Is value required: yes +* Is multiple: no +* Default: `100` + + + +`fop:generate:htaccess` +----------------------- + +Generate the .htaccess file + +### Usage + +* `fop:generate:htaccess` + +Generate the .htaccess file + +### Options + + + +`fop:generate:robots` +--------------------- + +Generate the robots.txt file + +### Usage + +* `fop:generate:robots [--executeHook [EXECUTEHOOK]]` + +Generate the robots.txt file + +### Options + +#### `--executeHook` + +Generate actionAdminMetaBeforeWriteRobotsFile hook ? + +* Accept value: yes +* Is value required: no +* Is multiple: no +* Default: `NULL` + + + +`fop:hook-module` +----------------- + +Attach one module on specific hook + +### Usage + +* `fop:hook-module [--module [MODULE]] [--hook [HOOK]]` +* `fop:hook-module --module=[modulename]` +* `fop:hook-module --hook=[hookname]` + +This command allows you to attach a module on one hook + +### Options + +#### `--module` + +* Accept value: yes +* Is value required: no +* Is multiple: no +* Default: `NULL` + +#### `--hook` + +* Accept value: yes +* Is value required: no +* Is multiple: no +* Default: `NULL` + + + +`fop:images:generate:categories` +-------------------------------- + +Regenerate categories thumbnails + +### Usage + +* `fop:images:generate:categories [-f|--force] [--] []...` + +Regenerate categories thumbnails + +### Arguments + +#### `format` + +images formats separated by a space + +* Is required: no +* Is array: yes +* Default: `array ( 0 => 'all',)` + +### Options + +#### `--force|-f` + +Force delete of currents thumbnails + +* Accept value: no +* Is value required: no +* Is multiple: no +* Default: `false` + + + +`fop:images:generate:manufacturers` +----------------------------------- + +Regenerate manufacturers thumbnails + +### Usage + +* `fop:images:generate:manufacturers [-f|--force] [--] []...` + +Regenerate manufacturers thumbnails + +### Arguments + +#### `format` + +images formats separated by a space + +* Is required: no +* Is array: yes +* Default: `array ( 0 => 'all',)` + +### Options + +#### `--force|-f` + +Force delete of currents thumbnails + +* Accept value: no +* Is value required: no +* Is multiple: no +* Default: `false` + + + +`fop:images:generate:products` +------------------------------ + +Regenerate products thumbnails + +### Usage + +* `fop:images:generate:products [-f|--force] [--] []...` + +Regenerate products thumbnails + +### Arguments + +#### `format` + +images formats separated by a space + +* Is required: no +* Is array: yes +* Default: `array ( 0 => 'all',)` + +### Options + +#### `--force|-f` + +Force delete of currents thumbnails + +* Accept value: no +* Is value required: no +* Is multiple: no +* Default: `false` + + + +`fop:images:generate:stores` +---------------------------- + +Regenerate stores thumbnails + +### Usage + +* `fop:images:generate:stores [-f|--force] [--] []...` + +Regenerate stores thumbnails + +### Arguments + +#### `format` + +images formats separated by a space + +* Is required: no +* Is array: yes +* Default: `array ( 0 => 'all',)` + +### Options + +#### `--force|-f` + +Force delete of currents thumbnails + +* Accept value: no +* Is value required: no +* Is multiple: no +* Default: `false` + + + +`fop:images:generate:suppliers` +------------------------------- + +Regenerate suppliers thumbnails + +### Usage + +* `fop:images:generate:suppliers [-f|--force] [--] []...` + +Regenerate suppliers thumbnails + +### Arguments + +#### `format` + +images formats separated by a space + +* Is required: no +* Is array: yes +* Default: `array ( 0 => 'all',)` + +### Options + +#### `--force|-f` + +Force delete of currents thumbnails + +* Accept value: no +* Is value required: no +* Is multiple: no +* Default: `false` + + + +`fop:latest-products` +--------------------- + +Displays the latest products + +### Usage + +* `fop:latest-products` + +This command allows you to display the latest products + + +`fop:maintenance` +----------------- + +Configure maintenance mode + +### Usage + +* `fop:maintenance [] []` + +This command allows you to get status or change maintenance mode + +### Arguments + +#### `action` + +get status or change maintenance mode ( possible values : enable,disable,toggle,status,ips,addip,addmyip) + +* Is required: no +* Is array: no +* Default: `'status'` + +#### `ipaddress` + +ip address to add + +* Is required: no +* Is array: no +* Default: `NULL` + + +`fop:module:hooks` +------------------ + +Get modules list + +### Usage + +* `fop:module:hooks ` + +Get modules list + +### Arguments + +#### `name` + +module name + +* Is required: yes +* Is array: no +* Default: `NULL` + +`fop:shop-status` +----------------- + +Display shops statuses + +### Usage + +* `fop:shop-status [] []` + +Display shops statuses + +### Arguments + +#### `id_shop` + +Specify an id_shop + +* Is required: no +* Is array: no +* Default: `NULL` + +#### `action` + +enable or disable + +* Is required: no +* Is array: no +* Default: `NULL` + +`fop:theme-reset` +----------------- + +Reset current theme layout + +### Usage + +* `fop:theme-reset [--id_shop [ID_SHOP]] [--] []` + +Disable & re-enable theme configuration + +### Arguments + +#### `theme` + +Theme on which the action will be executed + +* Is required: no +* Is array: no +* Default: `NULL` + +### Options + +#### `--id_shop` + +Shop on which the action will be executed + +* Accept value: yes +* Is value required: no +* Is multiple: no +* Default: `NULL` + +`fop:unhook-module` +------------------- + +Detach module from hook + +### Usage + +* `fop:unhook-module [--module [MODULE]] [--hook [HOOK]]` +* `fop:unhook-module --module=[modulename]` +* `fop:unhook-module --hook=[hookname]` + +This command allows you to detach a module from one hook + +### Options + +#### `--module` + +* Accept value: yes +* Is value required: no +* Is multiple: no +* Default: `NULL` + +#### `--hook` + +* Accept value: yes +* Is value required: no +* Is multiple: no +* Default: `NULL` diff --git a/src/Commands/Util/Dump.php b/src/Commands/Util/Dump.php new file mode 100644 index 00000000..ee9f0de7 --- /dev/null +++ b/src/Commands/Util/Dump.php @@ -0,0 +1,65 @@ + + * @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\Util; + +use Exception; +use FOP\Console\Command; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +class Dump extends Command +{ + public function configure() + { + $this->setName('fop:util:dump') + ->setDescription('Dump database objects.'); + // @todo usage, ect + $this->addArgument('entity', InputArgument::REQUIRED, 'the entity to dump (eg. product)') + ->addArgument('id_value', InputArgument::REQUIRED); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $entityName = ucfirst(strtolower($input->getArgument('entity'))); + $idValue = intval($input->getArgument('id_value')); + + try { + if (!class_exists($entityName)) { + throw new Exception("Class $entityName not found"); + } + + $object = new $entityName($idValue); + if (!\Validate::isLoadedObject($object)) { + throw new Exception('Object not found in database'); + } + dump(json_decode(json_encode($object))); // fast hack : decode + encode just to keep public properties + + return 0; + } catch (Exception $exception) { + $output->writeln('' . $exception->getMessage() . ''); + + return 1; + } + } +}