-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 94b3b3d
Showing
89 changed files
with
4,642 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
on: [push] | ||
|
||
jobs: | ||
build: | ||
name: Running GrumPHP | ||
runs-on: ubuntu-latest | ||
env: | ||
extensions: intl, mbstring | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '7.3' | ||
extensions: ${{ env.extensions }} | ||
tools: composer | ||
- name: Get Composer Cache Directory | ||
id: composercache | ||
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
- name: Cache dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${{ steps.composercache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} | ||
restore-keys: ${{ runner.os }}-composer- | ||
- name: Install dependencies | ||
run: composer config "http-basic.repo.magento.com" ${{ secrets.MAGE_USER }} ${{ secrets.MAGE_PASS }} && composer install --prefer-dist | ||
- run: ./vendor/bin/grumphp run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/composer.lock | ||
/vendor | ||
/.phpunit.result.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
/** | ||
* PHP Coding Standards fixer configuration | ||
*/ | ||
use PhpCsFixer\Config; | ||
use PhpCsFixer\Finder; | ||
|
||
$finder = Finder::create() | ||
->in('./') | ||
->name(['*.php']); | ||
|
||
return Config::create() | ||
->setRules([ | ||
'@PSR2' => true, | ||
'no_useless_else' => true, | ||
'no_useless_return' => true, | ||
'ordered_class_elements' => true, | ||
'ordered_imports' => true, | ||
'phpdoc_order' => true, | ||
'phpdoc_summary' => false, | ||
'blank_line_after_opening_tag' => false, | ||
'concat_space' => ['spacing' => 'one'], | ||
'array_syntax' => ['syntax' => 'short'], | ||
// Removes @param and @return tags that don't provide any useful information; | ||
// Set to false to ensure custom Magento API implementations do not fail. Magento uses reflection based on its docblocks to process request/responses | ||
'no_superfluous_phpdoc_tags' => false, | ||
// add declare strict type to every file | ||
'declare_strict_types' => true, | ||
// use native phpunit methods | ||
'php_unit_construct' => true, | ||
// Enforce camel case for PHPUnit test methods | ||
'php_unit_method_casing' => ['case' => 'camel_case'], | ||
'yoda_style' => ['equal' => true, 'identical' => true, 'less_and_greater' => true], | ||
'php_unit_test_case_static_method_calls' => true, | ||
// comparisons should always be strict | ||
'strict_comparison' => true, | ||
// functions should be used with $strict param set to true | ||
'strict_param' => true, | ||
'array_indentation' => true, | ||
'compact_nullable_typehint' => true, | ||
'fully_qualified_strict_types' => true, | ||
]) | ||
->setFinder($finder) | ||
->setRiskyAllowed(true) | ||
->setUsingCache(false); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php declare(strict_types=1); | ||
|
||
|
||
namespace Phpro\Translations\Api\Data; | ||
|
||
interface TranslationInterface extends \Magento\Framework\Api\ExtensibleDataInterface | ||
{ | ||
const STRING = 'string'; | ||
const LOCALE = 'locale'; | ||
const TRANSLATE = 'translate'; | ||
const FRONTEND = 'frontend'; | ||
const KEY_ID = 'key_id'; | ||
|
||
/** | ||
* @return int|null | ||
*/ | ||
public function getKeyId(); | ||
|
||
/** | ||
* @param $keyId | ||
* @return mixed | ||
*/ | ||
public function setKeyId($keyId); | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getString(); | ||
|
||
/** | ||
* @param $string | ||
* @return mixed | ||
*/ | ||
public function setString($string); | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getLocale(); | ||
|
||
/** | ||
* @param $locale | ||
* @return mixed | ||
*/ | ||
public function setLocale($locale); | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getTranslate(); | ||
|
||
/** | ||
* @param $translate | ||
* @return mixed | ||
*/ | ||
public function setTranslate($translate); | ||
|
||
/** | ||
* @return boolean|null | ||
*/ | ||
public function getFrontend(); | ||
|
||
/** | ||
* @param $frontend | ||
* @return mixed | ||
*/ | ||
public function setFrontend($frontend); | ||
|
||
/** | ||
* Retrieve existing extension attributes object or create a new one. | ||
* @return \Phpro\Translations\Api\Data\TranslationExtensionInterface|null | ||
*/ | ||
public function getExtensionAttributes(); | ||
|
||
/** | ||
* Set an extension attributes object. | ||
* @param \Phpro\Translations\Api\Data\TranslationExtensionInterface $extensionAttributes | ||
* @return $this | ||
*/ | ||
public function setExtensionAttributes( | ||
TranslationExtensionInterface $extensionAttributes | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php declare(strict_types=1); | ||
|
||
|
||
namespace Phpro\Translations\Api\Data; | ||
|
||
interface TranslationSearchResultsInterface extends \Magento\Framework\Api\SearchResultsInterface | ||
{ | ||
|
||
/** | ||
* Get Translation list. | ||
* @return \Phpro\Translations\Api\Data\TranslationInterface[] | ||
*/ | ||
public function getItems(); | ||
|
||
/** | ||
* Set translate list. | ||
* @param \Phpro\Translations\Api\Data\TranslationInterface[] $items | ||
* @return $this | ||
*/ | ||
public function setItems(array $items); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Phpro\Translations\Api; | ||
|
||
use Phpro\Translations\Model\Data\ExportStats; | ||
|
||
interface ExportManagementInterface | ||
{ | ||
public function export(?array $locale): ExportStats; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Phpro\Translations\Api; | ||
|
||
use Phpro\Translations\Model\Data\ImportStats; | ||
|
||
interface ImportManagementInterface | ||
{ | ||
/** | ||
* Import Magento translation CSV to the database. | ||
* Example structure: "Foo","Foo value",module,Magento_Catalog | ||
* | ||
* @param string $filePath | ||
* @param string $locale | ||
* @throws \Exception | ||
* @return ImportStats | ||
*/ | ||
public function importMagentoCsv(string $filePath, string $locale): ImportStats; | ||
|
||
/** | ||
* Import translation CSV (based on export) to the database. | ||
* Example structure: "Bar","Bar value",en_US | ||
* | ||
* @param string $filePath | ||
* @return ImportStats | ||
*/ | ||
public function importFull(string $filePath): ImportStats; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Phpro\Translations\Api; | ||
|
||
interface TranslationDataManagementInterface | ||
{ | ||
/** | ||
* Add the translation key for all enabled locales of the Magento instance. | ||
* If default translation is not set, the translation key will be used as default translation. | ||
* | ||
* @param string $translationKey | ||
* @param null|string $defaultTranslation | ||
*/ | ||
public function prepare(string $translationKey, ?string $defaultTranslation = null); | ||
|
||
/** | ||
* Add a translation for given locales. | ||
* | ||
* @param string $translationKey | ||
* @param string $translationValue | ||
* @param array $locales | ||
*/ | ||
public function create(string $translationKey, string $translationValue, array $locales = []); | ||
|
||
/** | ||
* Delete a translation for given translation key and locale(s). | ||
* In case no locales are given, all enabled locales will be used. | ||
* | ||
* @param string $translationKey | ||
* @param array|null $locales | ||
*/ | ||
public function delete(string $translationKey, ?array $locales = []); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Phpro\Translations\Api; | ||
|
||
use Magento\Framework\Api\SearchCriteriaInterface; | ||
|
||
interface TranslationRepositoryInterface | ||
{ | ||
|
||
/** | ||
* Save Translation | ||
* @param \Phpro\Translations\Api\Data\TranslationInterface $translation | ||
* @throws \Magento\Framework\Exception\LocalizedException | ||
* @return \Phpro\Translations\Api\Data\TranslationInterface | ||
*/ | ||
public function save( | ||
Data\TranslationInterface $translation | ||
); | ||
|
||
/** | ||
* Retrieve Translation | ||
* @param string $translationId | ||
* @throws \Magento\Framework\Exception\LocalizedException | ||
* @return \Phpro\Translations\Api\Data\TranslationInterface | ||
*/ | ||
public function getById($translationId); | ||
|
||
/** | ||
* Retrieve Translation matching the specified criteria. | ||
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria | ||
* @throws \Magento\Framework\Exception\LocalizedException | ||
* @return \Phpro\Translations\Api\Data\TranslationSearchResultsInterface | ||
*/ | ||
public function getList( | ||
SearchCriteriaInterface $searchCriteria | ||
); | ||
|
||
/** | ||
* Delete translation by given key and locales. | ||
* @param string $translationKey | ||
* @param array $locales | ||
* @return bool true on success | ||
*/ | ||
public function deleteByTranslationKeyAndLocales(string $translationKey, array $locales); | ||
|
||
/** | ||
* Delete Translation by ID | ||
* @param string $translationId | ||
* @throws \Magento\Framework\Exception\NoSuchEntityException | ||
* @throws \Magento\Framework\Exception\LocalizedException | ||
* @return bool true on success | ||
*/ | ||
public function deleteById($translationId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Phpro\Translations\Block\Adminhtml\Translation\Edit; | ||
|
||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface; | ||
|
||
class BackButton extends GenericButton implements ButtonProviderInterface | ||
{ | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getButtonData() | ||
{ | ||
return [ | ||
'label' => __('Back'), | ||
'on_click' => sprintf("location.href = '%s';", $this->getBackUrl()), | ||
'class' => 'back', | ||
'sort_order' => 10 | ||
]; | ||
} | ||
|
||
/** | ||
* Get URL for back (reset) button | ||
* | ||
* @return string | ||
*/ | ||
public function getBackUrl() | ||
{ | ||
return $this->getUrl('*/*/'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Phpro\Translations\Block\Adminhtml\Translation\Edit; | ||
|
||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface; | ||
|
||
class DeleteButton extends GenericButton implements ButtonProviderInterface | ||
{ | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getButtonData() | ||
{ | ||
$data = []; | ||
if ($this->getModelId()) { | ||
$data = [ | ||
'label' => __('Delete Translation'), | ||
'class' => 'delete', | ||
'on_click' => 'deleteConfirm(\'' . __( | ||
'Are you sure you want to do this?' | ||
) . '\', \'' . $this->getDeleteUrl() . '\')', | ||
'sort_order' => 20, | ||
]; | ||
} | ||
return $data; | ||
} | ||
|
||
/** | ||
* Get URL for delete button | ||
* | ||
* @return string | ||
*/ | ||
public function getDeleteUrl() | ||
{ | ||
return $this->getUrl('*/*/delete', ['key_id' => $this->getModelId()]); | ||
} | ||
} |
Oops, something went wrong.