sirclo-bachtiar / magento-helpers-v2
Magento Helpers v2
1.1.5
2022-08-19 08:07 UTC
Requires
- laminas/laminas-log: ^2.12
This package is auto-updated.
Last update: 2024-10-19 12:51:23 UTC
README
Service Helpers.
This service is used to help some activities during your work, which contains several functions that may make your job simpler. Personally, this library is used for magento.
Require
This library requiring Laminas Log for create logger.
Installation
- Set Config to composer.json (not a mandatory)
composer config repositories.sirclo-bachtiar/magento-helpers-v2 git git@github.com:sirclo-bachtiar/magento-helpers-v2.git
- Install library
composer require sirclo-bachtiar/magento-helpers-v2
Usage
It's used for create log activity.
use Bachtiar\Helper\LaminasLogger\Service\LogService; class LogServiceTest { public function Log() { return LogService::channel('default') ->mode('default') ->title('log_title') ->log('message_to_log'); } } #### Info #### :: channel('default') => not required -> select channel, available [ emerg, alert, crit, err, warn, notice, info ], if null then auto set to default. :: mode('default') => not required -> select log mode, available [ test, debug, develop ], if null then auto set to default. :: title('default') => not required -> set log title, if null then auto set to default title. :: log('default') => required -> set log message, if null then auto set to default message.
It's use for logging activity based on Icube Custom Swift Log Rule.
use Bachtiar\Helper\LaminasLogger\Service\SwiftLog; class SwiftLogTest { use SwiftLog; public function __invoke() { return $this->channel('default') ->mode('default') ->classLimit('default') ->group('group_title') ->title('log_title') ->log('message_to_log'); } } #### Info #### :: channel('default') => not required -> select channel, available [ emerg, alert, crit, err, warn, notice, info ], if null then auto set to default. :: mode('default') => not required -> select log mode, available [ test, debug, develop ], if null then auto set to default. :: classLimit('default') => not required -> set module class namespace limit, if null then auto set to default. :: group('default') => not required -> set group of log, if null then auto set to default. :: title('default') => not required -> set log title, if null then auto set to default title. :: log('default') => required -> set log message, if null then auto set to default message.
It's used for custom query builder. (return query only).
use Bachtiar\Helper\CustomQueryGenerator\Service\QueryBuilderService; class QueryBuilderTest { public function __invoke() { return QueryBuilderService::select() ->from('base_table') ->join('relation_table', 'base_table.baseColumnId', '=', 'relation_table.relationColumnId') ->where('base_table.name', '=', 'test') ->andWhere('base_table.age', '=', 'age') ->orWhere('relation_table.address', 'like', '%ponorogo%') ->generate(); } } #### Info #### :: select() -> optional -> set select column, if null, then auto set to all (*). :: from('base_table') -> ! must be included -> set base table query. :: join('relation_table', 'baseColumnId', '=', 'relationColumnId') -> set inner join from query. :: where('base_table.name', '=', 'test') -> optional -> set where clause from query :: andWhere('base_table.age', '=', 'age') -> optional -> set or where clause from query :: orWhere('relation_table.address', 'like', '%ponorogo%') -> optional -> set and where clause from query :: generate() -> process to create query builder.