diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..e882227 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,35 @@ +name: CI + +on: + push: + branches: [ main ] + +jobs: + continous-integration: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php-versions: [ "8.0", "8.1", "8.2" ] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup PHP, with composer and extensions + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php + with: + php-version: ${{ matrix.php-versions }} + extensions: mbstring, dom, fileinfo, pgsql, json + coverage: xdebug #optional + - name: Get composer cache directory + id: composercache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: Cache composer dependencies + uses: actions/cache@v3 + with: + path: ${{ steps.composercache.outputs.dir }} + # Use composer.json for key, if composer.lock is not committed. + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + - name: Install dependencies and run ci tasks + run: make install ci diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..722c2d4 --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +The MIT License (MIT) + +Copyright (c) 2023-present FOND OF GmbH + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5745fec --- /dev/null +++ b/Makefile @@ -0,0 +1,30 @@ +.PHONY: install +install: + composer install + +.PHONY: phpcs +phpcs: + ./vendor/bin/phpcs --standard=./vendor/spryker/code-sniffer/Spryker/ruleset.xml ./src/FondOfImpala/* ./tests/* + +.PHONY: phpcbf +phpcbf: + ./vendor/bin/phpcbf --standard=./vendor/spryker/code-sniffer/Spryker/ruleset.xml ./src/FondOfImpala/* ./tests/* + +.PHONY: phpstan +phpstan: + ./vendor/bin/phpstan --memory-limit=-1 analyse ./src/FondOfImpala + +.PHONY: codeception +codeception: + ./vendor/bin/codecept run --env standalone + +.PHONY: ci +ci: phpcs codeception phpstan + +.PHONY: clean +clean: + rm -Rf composer.lock + rm -Rf ./vendor + find ./tests/_output/ -not -name .gitignore -delete + rm -Rf src/Generated/* + rm -Rf src/Orm/* diff --git a/README.md b/README.md new file mode 100644 index 0000000..9d9a1d9 --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# Company Price List Gui Module +[![CI](https://github.com/fond-of-impala/company-price-list-gui/actions/workflows/main.yml/badge.svg)](https://github.com/fond-of-impala/company-price-list-gui/actions/workflows/main.yml) +[![license](https://img.shields.io/github/license/fond-of-impala/company-price-list-gui.svg)](https://packagist.org/packages/fond-of-impala/company-price-list-gui) + +Package was migrated from `fond-of-spryker/company-price-list-gui` + +## Installation + +``` +composer require fond-of-impala/company-price-list-gui +``` diff --git a/codeception.yml b/codeception.yml new file mode 100644 index 0000000..b019387 --- /dev/null +++ b/codeception.yml @@ -0,0 +1,43 @@ +namespace: fond-of-impala/company-price-list-gui + +suites: + unit: + path: . + +settings: + shuffle: true + lint: true + +bootstrap: _bootstrap.php + +paths: + tests: tests + output: tests/_output + support: tests/_support + data: tests/_data + +coverage: + enabled: true + include: + - src/*.php + +modules: + enabled: + - \FondOfCodeception\Module\Spryker + config: + \FondOfCodeception\Module\Spryker: + generate_transfer: false + generate_map_classes: false + generate_propel_classes: false + generate_ide_auto_completion: false + +env: + standalone: + modules: + config: + \FondOfCodeception\Module\Spryker: + generate_transfer: true + generate_map_classes: true + generate_propel_classes: true + generate_ide_auto_completion: true + monorepo: diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..759798d --- /dev/null +++ b/composer.json @@ -0,0 +1,40 @@ +{ + "name": "fond-of-impala/company-price-list-gui", + "description": "Company price list module", + "license": "MIT", + "authors": [ + { + "name": "Daniel Rose", + "email": "daniel-rose@gmx.de" + } + ], + "require": { + "php": ">=8.0", + "fond-of-impala/company-price-list": "^1.0.0", + "spryker/company-gui-extension": "^1.0.0" + }, + "require-dev": { + "fond-of-codeception/spryker": "*", + "spryker/code-sniffer": "*", + "spryker-sdk/phpstan-spryker": "*" + }, + "minimum-stability": "dev", + "prefer-stable": true, + "autoload": { + "psr-4": { + "FondOfImpala\\": "src/FondOfImpala/" + } + }, + "autoload-dev": { + "psr-4": { + "FondOfImpala\\": "tests/FondOfImpala/", + "Generated\\": "src/Generated/", + "Orm\\": "src/Orm/" + } + }, + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } + } +} diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..d2a9231 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,5 @@ +parameters: + level: 5 + reportUnmatchedIgnoredErrors: false + scanDirectories: + - src/Orm/Zed diff --git a/src/FondOfImpala/Zed/CompanyPriceListGui/Communication/CompanyPriceListGuiCommunicationFactory.php b/src/FondOfImpala/Zed/CompanyPriceListGui/Communication/CompanyPriceListGuiCommunicationFactory.php new file mode 100644 index 0000000..0a48e66 --- /dev/null +++ b/src/FondOfImpala/Zed/CompanyPriceListGui/Communication/CompanyPriceListGuiCommunicationFactory.php @@ -0,0 +1,36 @@ +getProvidedDependency(CompanyPriceListGuiDependencyProvider::FACADE_PRICE_LIST); + } + + /** + * @return \FondOfImpala\Zed\CompanyPriceListGui\Communication\Form\DataProvider\CompanyPriceListFormDataProvider + */ + public function createCompanyPriceListFormDataProvider(): CompanyPriceListFormDataProvider + { + return new CompanyPriceListFormDataProvider($this->getPriceListFacade()); + } + + /** + * @return \FondOfImpala\Zed\CompanyPriceListGui\Communication\Form\CompanyPriceListForm + */ + public function createCompanyPriceListForm(): CompanyPriceListForm + { + return new CompanyPriceListForm(); + } +} diff --git a/src/FondOfImpala/Zed/CompanyPriceListGui/Communication/Form/CompanyPriceListForm.php b/src/FondOfImpala/Zed/CompanyPriceListGui/Communication/Form/CompanyPriceListForm.php new file mode 100644 index 0000000..b7dcf9b --- /dev/null +++ b/src/FondOfImpala/Zed/CompanyPriceListGui/Communication/Form/CompanyPriceListForm.php @@ -0,0 +1,51 @@ +addPriceListCollectionField($builder, $options); + } + + /** + * @param \Symfony\Component\Form\FormBuilderInterface $builder + * @param array $options + * + * @return $this + */ + protected function addPriceListCollectionField(FormBuilderInterface $builder, array $options) + { + $builder->add(static::FIELD_FK_PRICE_LIST, SelectType::class, [ + 'label' => 'Price list', + 'choices' => $options[static::OPTIONS_PRICE_LIST], + 'required' => false, + ]); + + return $this; + } +} diff --git a/src/FondOfImpala/Zed/CompanyPriceListGui/Communication/Form/DataProvider/CompanyPriceListFormDataProvider.php b/src/FondOfImpala/Zed/CompanyPriceListGui/Communication/Form/DataProvider/CompanyPriceListFormDataProvider.php new file mode 100644 index 0000000..14f4e15 --- /dev/null +++ b/src/FondOfImpala/Zed/CompanyPriceListGui/Communication/Form/DataProvider/CompanyPriceListFormDataProvider.php @@ -0,0 +1,44 @@ +priceListFacade = $priceListFacade; + } + + /** + * @return array + */ + public function getOptions(): array + { + return [ + CompanyPriceListForm::OPTIONS_PRICE_LIST => $this->getPriceListOptions(), + ]; + } + + /** + * @return array + */ + protected function getPriceListOptions(): array + { + $priceListOptions = []; + $priceListCollectionTransfer = $this->priceListFacade->getPriceListCollection(); + + foreach ($priceListCollectionTransfer->getPriceLists() as $priceListTransfer) { + $priceListOptions[$priceListTransfer->getName()] = $priceListTransfer->getIdPriceList(); + } + + return $priceListOptions; + } +} diff --git a/src/FondOfImpala/Zed/CompanyPriceListGui/Communication/Plugin/CompanyGuiExtension/PriceListCompanyFormExpanderPlugin.php b/src/FondOfImpala/Zed/CompanyPriceListGui/Communication/Plugin/CompanyGuiExtension/PriceListCompanyFormExpanderPlugin.php new file mode 100644 index 0000000..414822e --- /dev/null +++ b/src/FondOfImpala/Zed/CompanyPriceListGui/Communication/Plugin/CompanyGuiExtension/PriceListCompanyFormExpanderPlugin.php @@ -0,0 +1,30 @@ +getFactory()->createCompanyPriceListFormDataProvider(); + $companyPriceListForm = $this->getFactory()->createCompanyPriceListForm(); + + $companyPriceListForm->buildForm($builder, $companyPriceListFormDataProvider->getOptions()); + } +} diff --git a/src/FondOfImpala/Zed/CompanyPriceListGui/CompanyPriceListGuiDependencyProvider.php b/src/FondOfImpala/Zed/CompanyPriceListGui/CompanyPriceListGuiDependencyProvider.php new file mode 100644 index 0000000..208816a --- /dev/null +++ b/src/FondOfImpala/Zed/CompanyPriceListGui/CompanyPriceListGuiDependencyProvider.php @@ -0,0 +1,43 @@ +addPriceListFacade($container); + + return $container; + } + + /** + * @param \Spryker\Zed\Kernel\Container $container + * + * @return \Spryker\Zed\Kernel\Container + */ + protected function addPriceListFacade(Container $container): Container + { + $container[static::FACADE_PRICE_LIST] = fn (Container $container): CompanyPriceListGuiToPriceListFacadeBridge => new CompanyPriceListGuiToPriceListFacadeBridge( + $container->getLocator()->priceList()->facade(), + ); + + return $container; + } +} diff --git a/src/FondOfImpala/Zed/CompanyPriceListGui/Dependency/Facade/CompanyPriceListGuiToPriceListFacadeBridge.php b/src/FondOfImpala/Zed/CompanyPriceListGui/Dependency/Facade/CompanyPriceListGuiToPriceListFacadeBridge.php new file mode 100644 index 0000000..9427a8a --- /dev/null +++ b/src/FondOfImpala/Zed/CompanyPriceListGui/Dependency/Facade/CompanyPriceListGuiToPriceListFacadeBridge.php @@ -0,0 +1,27 @@ +priceListFacade = $priceListFacade; + } + + /** + * @return \Generated\Shared\Transfer\PriceListCollectionTransfer + */ + public function getPriceListCollection(): PriceListCollectionTransfer + { + return $this->priceListFacade->getPriceListCollection(); + } +} diff --git a/src/FondOfImpala/Zed/CompanyPriceListGui/Dependency/Facade/CompanyPriceListGuiToPriceListFacadeInterface.php b/src/FondOfImpala/Zed/CompanyPriceListGui/Dependency/Facade/CompanyPriceListGuiToPriceListFacadeInterface.php new file mode 100644 index 0000000..e33486e --- /dev/null +++ b/src/FondOfImpala/Zed/CompanyPriceListGui/Dependency/Facade/CompanyPriceListGuiToPriceListFacadeInterface.php @@ -0,0 +1,13 @@ +