diff --git a/.circleci/config.yml b/.circleci/config.yml index d186814..978125b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -48,8 +48,11 @@ jobs: path: app/code/Eadesigndev/Pdfgenerator - run: - name: Install code climate - command: composer create-project codeclimate/php-test-reporter codeclimate + name: Enable all module + command: php bin/magento module:enable --all + - run: + name: Run compilation + command: php -d memory_limit=6G bin/magento setup:di:compile - run: name: Install marketplace qulity tools command: composer create-project --repository=https://repo.magento.com magento/marketplace-eqp magento-coding-standard @@ -62,17 +65,4 @@ jobs: command: php vendor/bin/phpmd app/code/Eadesigndev/Pdfgenerator/Api/,app/code/Eadesigndev/Pdfgenerator/Block/,app/code/Eadesigndev/Pdfgenerator/Controller/,app/code/Eadesigndev/Pdfgenerator/Helper/,app/code/Eadesigndev/Pdfgenerator/Model/,app/code/Eadesigndev/Pdfgenerator/Setup/,app/code/Eadesigndev/Pdfgenerator/Ui/,app/code/Eadesigndev/Pdfgenerator/view/ text app/code/Eadesigndev/Pdfgenerator/Test/Php/_files/phpmd/ruleset.xml - run: name: Run unit tests - command: php vendor/bin/phpunit app/code/Eadesigndev/Pdfgenerator/Test/ --config dev/tests/unit/phpunit.xml.dist --coverage-clover=app/code/Eadesigndev/Pdfgenerator/build/logs/clover.xml - - - run: - name: Get the reporter script - command: cd app/code/Eadesigndev/Pdfgenerator && curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter - - run: - name: Make the executable - command: cd app/code/Eadesigndev/Pdfgenerator && chmod +x ./cc-test-reporter - - run: - name: Run the before script - command: cd app/code/Eadesigndev/Pdfgenerator && ./cc-test-reporter before-build - - run: - name: Rune the reporter - command: cd app/code/Eadesigndev/Pdfgenerator && ./cc-test-reporter after-build -r $CC_TEST_REPORTER_ID --coverage-input-type clover --exit-code $? + command: php vendor/bin/phpunit app/code/Eadesigndev/Pdfgenerator/Test/ --config dev/tests/unit/phpunit.xml.dist --coverage-clover=app/code/Eadesigndev/Pdfgenerator/build/logs/clover.xml \ No newline at end of file diff --git a/Controller/Adminhtml/Variable/Template.php b/Controller/Adminhtml/Variable/Template.php index eb882d0..133010e 100644 --- a/Controller/Adminhtml/Variable/Template.php +++ b/Controller/Adminhtml/Variable/Template.php @@ -17,6 +17,7 @@ use Magento\Framework\Json\Helper\Data as JsonHelperData; use Magento\Variable\Model\Variable as VariableModel; use Magento\Email\Model\Source\Variables as EmailVariables; +use Eadesigndev\Pdfgenerator\Model\Email\VariablesFacrory; use Magento\Email\Model\BackendTemplate as EmailBackendTemplate; use Zend_Json; @@ -64,7 +65,7 @@ class Template extends Action /** * @var EmailVariables */ - private $emailVariables; + private $variablesFacrory; /** * @var EmailBackendTemplate @@ -79,7 +80,7 @@ class Template extends Action * @param JsonFactory $resultJsonFactory * @param JsonHelperData $jsonHelperData * @param VariableModel $variableModel - * @param EmailVariables $emailVariables + * @param VariablesFacrory $variablesFacrory * @param EmailBackendTemplate $emailBackendTemplate */ public function __construct( @@ -89,7 +90,7 @@ public function __construct( JsonFactory $resultJsonFactory, JsonHelperData $jsonHelperData, VariableModel $variableModel, - EmailVariables $emailVariables, + VariablesFacrory $variablesFacrory, EmailBackendTemplate $emailBackendTemplate ) { @@ -99,7 +100,7 @@ public function __construct( $this->resultJsonFactory = $resultJsonFactory; $this->jsonHelperData = $jsonHelperData; $this->variableModel = $variableModel; - $this->emailVariables = $emailVariables; + $this->variablesFacrory = $variablesFacrory; $this->emailBackendTemplate = $emailBackendTemplate; } @@ -149,7 +150,7 @@ public function execute() $customVariables = $this->variableModel ->getVariablesOptionArray(true); - $storeContactVariables = $this->emailVariables->toOptionArray(true); + $storeContactVariables = $this->variablesFacrory->create()->toOptionArray(true); /** @var Json $resultJson */ $resultJson = $this->resultJsonFactory->create(); return $resultJson->setData([ diff --git a/Model/Email/VariablesFacrory.php b/Model/Email/VariablesFacrory.php new file mode 100644 index 0000000..06b7006 --- /dev/null +++ b/Model/Email/VariablesFacrory.php @@ -0,0 +1,39 @@ +objectManager = $objectManager; + if (class_exists(\Magento\Email\Model\Source\Variables::class)) { + $this->instanceName = \Magento\Email\Model\Source\Variables::class; + } + + if (class_exists(\Magento\Variable\Model\Source\Variables::class)) { + $this->instanceName = \Magento\Variable\Model\Source\Variables::class; + } + } + + public function create(array $data = []) + { + return $this->objectManager->create($this->instanceName, $data); + } +} diff --git a/Model/Template/DataProvider.php b/Model/Template/DataProvider.php index 2742607..4885637 100644 --- a/Model/Template/DataProvider.php +++ b/Model/Template/DataProvider.php @@ -51,18 +51,7 @@ public function __construct( $this->collection = $templateCollectionFactory->create(); $this->dataPersistor = $dataPersistor; parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data); - $this->meta = $this->prepareMeta($this->meta); - } - - /** - * Prepares Meta - * - * @param array $meta - * @return array - */ - public function prepareMeta(array $meta) - { - return $meta; + $this->meta = $meta; } /** diff --git a/README.md b/README.md index 460ea77..2e1c1da 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ [![Maintainability](https://api.codeclimate.com/v1/badges/a0e292336dc421b6c903/maintainability)](https://codeclimate.com/github/EaDesgin/magento2-pdf-generator2/maintainability) -[![Test Coverage](https://api.codeclimate.com/v1/badges/a0e292336dc421b6c903/test_coverage)](https://codeclimate.com/github/EaDesgin/magento2-pdf-generator2/test_coverage) [![](https://img.shields.io/packagist/v/eadesignro/module-pdfgenerator.svg)](https://packagist.org/packages/eadesignro/module-pdfgenerator) [![](https://img.shields.io/packagist/dt/eadesignro/module-pdfgenerator.svg)](https://packagist.org/packages/eadesignro/module-pdfgenerator) diff --git a/composer.json b/composer.json index 6d34a70..9276aa4 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "eadesignro/module-pdfgenerator", "description": "The best pdf generator for Magento. EaDesign PDF Generator", "type": "magento2-module", - "version": "1.2.5", + "version": "1.2.6", "autoload": { "files": [ "registration.php" diff --git a/etc/module.xml b/etc/module.xml index bb18c34..9d21c22 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -6,5 +6,5 @@ */ --> - +