diff --git a/.github/workflows/craft-versions.yml b/.github/workflows/craft-versions.yml index fb9b1edd..5d94dc16 100644 --- a/.github/workflows/craft-versions.yml +++ b/.github/workflows/craft-versions.yml @@ -1,99 +1,100 @@ -name: Tests on multiple craft versions -on: - push: - branches: - - 4.x #CraftCMS v4 - pull_request: - branches: - - "*" -jobs: - tests: - strategy: - fail-fast: false - matrix: - craft_version: [ - # TODO: check this - # Investigation: - # https://github.com/craftcms/cms/issues/11083 - #"4.0.0", contains FK bug, it tries to update field on draft (after apply draft removed, so it fails) - "4.0.1", - "4.0.2", - "4.0.3", - "4.0.4", - "4.0.5", - "4.0.5.1", - "4.0.5.2", - "4.0.6", - "4.0.6", - "4.1.0", - "4.1.0.1", - "4.1.0.2", - "4.1.1", - "4.1.2", - "4.1.3", - "4.1.4", - "4.1.4.1", - "4.2.0", - "4.2.0.1", - "4.2.0.2", - "4.2.1", - "4.2.1.1", - "4.2.2", - "4.2.3", - "4.2.4", - "4.2.5", - "4.2.5.1", - "4.2.5.2", - "4.2.6", - "4.2.7", - "4.2.8", - "4.3.0", - "4.3.1", - "4.3.2", - "4.3.2.1", - "4.3.3", - "4.3.4", - "4.3.5", - "4.3.6", - "4.3.6.1", - "4.3.7", - "4.3.7.1", - "4.3.8", - "4.3.8.1", - "4.3.8.2", - "4.3.9", - "4.3.10", - "4.3.11", - "4.4.0", - "4.4.1", - "4.4.2", - "4.4.3", - "4.4.4", - "4.4.5", - "4.4.6", - "4.4.6.1", - "4.4.7", - "4.4.7.1", - "4.4.8", - "4.4.9", - "4.4.10", - "4.4.10.1", - "4.4.11", - "4.4.12", - "4.4.13", - "4.4.14", - "4.4.15", - "4.4.16", - "4.4.16.1", - "4.4.17", - ] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set the value - id: step_one - run: | - echo "PHP_VERSION=8.1" >> $GITHUB_ENV - echo "CRAFT_VERSION=${{ matrix.craft_version }}" >> $GITHUB_ENV - - name: Test craft versions ${{ matrix.craft_version }} - run: make test-craft-versions +#TODO: once craftcms v5 released fix all pipelines +#name: Tests on multiple craft versions +#on: +# push: +# branches: +# - 4.x #CraftCMS v4 +# pull_request: +# branches: +# - "*" +#jobs: +# tests: +# strategy: +# fail-fast: false +# matrix: +# craft_version: [ +# # TODO: check this +# # Investigation: +# # https://github.com/craftcms/cms/issues/11083 +# #"4.0.0", contains FK bug, it tries to update field on draft (after apply draft removed, so it fails) +# "4.0.1", +# "4.0.2", +# "4.0.3", +# "4.0.4", +# "4.0.5", +# "4.0.5.1", +# "4.0.5.2", +# "4.0.6", +# "4.0.6", +# "4.1.0", +# "4.1.0.1", +# "4.1.0.2", +# "4.1.1", +# "4.1.2", +# "4.1.3", +# "4.1.4", +# "4.1.4.1", +# "4.2.0", +# "4.2.0.1", +# "4.2.0.2", +# "4.2.1", +# "4.2.1.1", +# "4.2.2", +# "4.2.3", +# "4.2.4", +# "4.2.5", +# "4.2.5.1", +# "4.2.5.2", +# "4.2.6", +# "4.2.7", +# "4.2.8", +# "4.3.0", +# "4.3.1", +# "4.3.2", +# "4.3.2.1", +# "4.3.3", +# "4.3.4", +# "4.3.5", +# "4.3.6", +# "4.3.6.1", +# "4.3.7", +# "4.3.7.1", +# "4.3.8", +# "4.3.8.1", +# "4.3.8.2", +# "4.3.9", +# "4.3.10", +# "4.3.11", +# "4.4.0", +# "4.4.1", +# "4.4.2", +# "4.4.3", +# "4.4.4", +# "4.4.5", +# "4.4.6", +# "4.4.6.1", +# "4.4.7", +# "4.4.7.1", +# "4.4.8", +# "4.4.9", +# "4.4.10", +# "4.4.10.1", +# "4.4.11", +# "4.4.12", +# "4.4.13", +# "4.4.14", +# "4.4.15", +# "4.4.16", +# "4.4.16.1", +# "4.4.17", +# ] +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v2 +# - name: Set the value +# id: step_one +# run: | +# echo "PHP_VERSION=8.1" >> $GITHUB_ENV +# echo "CRAFT_VERSION=${{ matrix.craft_version }}" >> $GITHUB_ENV +# - name: Test craft versions ${{ matrix.craft_version }} +# run: make test-craft-versions diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 0694283f..8eca20fb 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -1,72 +1,73 @@ -name: E2E Tests -on: - push: - branches: - - 4.x #CraftCMS v4 - pull_request: - branches: - - "*" -jobs: - tests: - strategy: - fail-fast: false - matrix: - os: [ ubuntu-latest ] - scenario: [ - "cypress/e2e/jobs/copy-source-text-flow/filters.cy.js", - "cypress/e2e/jobs/copy-source-text-flow/success-path-multiple.cy.js", - "cypress/e2e/jobs/copy-source-text-flow/success-path-single.cy.js", - "cypress/e2e/jobs/instant/success-path-multiple.cy.js", - "cypress/e2e/jobs/instant/success-path-multiple-copy-slug.cy.js", - "cypress/e2e/jobs/instant/success-path-multiple-copy-slug-and-enable-after-publish.cy.js", - "cypress/e2e/jobs/instant/success-path-multiple-enable-after-publish.cy.js", - "cypress/e2e/jobs/verified/success-path-multiple-bulk-publishing.cy.js", - "cypress/e2e/jobs/verified/success-path-multiple-bulk-publishing-copy-slug.cy.js", - "cypress/e2e/jobs/verified/success-path-multiple-bulk-publishing-copy-slug-and-enable-after-publish.cy.js", - "cypress/e2e/jobs/verified/success-path-multiple-bulk-publishing-enable-after-publish.cy.js", - "cypress/e2e/jobs/verified/success-path-multiple-single-publishing.cy.js", - "cypress/e2e/jobs/verified/success-path-multiple-single-publishing-copy-slug.cy.js", - "cypress/e2e/jobs/verified/success-path-multiple-single-publishing-copy-slug-and-enable-after-publish.cy.js", - "cypress/e2e/jobs/verified/success-path-multiple-single-publishing-enable-after-publish.cy.js", - "cypress/e2e/jobs/verified/success-path-single.cy.js", - "cypress/e2e/jobs/instant/success-path-single.cy.js", - ] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set the value - id: step_one - run: | - echo "CYPRESS_SCENARIO=${{ matrix.scenario }}" >> $GITHUB_ENV - echo "DB_DATABASE=$(uuidgen)" >> $GITHUB_ENV - - name: Run automation - working-directory: ./e2e - run: | - echo ${DB_DATABASE} - make up - make e2e-github - - name: Copy artifacts - if: ${{ failure() }} - working-directory: ./e2e - run: | - make backup-db - mkdir var - mkdir var/log - mkdir cypress/craft - mkdir cypress/craft/storage - mkdir cypress/craft/config - docker compose cp app:/app/storage cypress/craft/storage - docker compose cp app:/app/config cypress/craft/config - docker compose cp app:/app/composer.json cypress/craft - docker compose cp app:/app/composer.lock cypress/craft - docker compose cp app:/var/log var/log - - name: Use the Upload Artifact GitHub Action - uses: actions/upload-artifact@v2 - if: ${{ failure() }} - with: - name: "${{ github.job }}_${{ github.run_id }}_${{ github.workflow }}_e2e_artifacts" - path: | - ./e2e/cypress/craft - ./e2e/cypress/screenshots - ./e2e/cypress/videos - ./e2e/happy-lager-main/storage +#TODO: once craftcms v5 released fix all pipelines +#name: E2E Tests +#on: +# push: +# branches: +# - 4.x #CraftCMS v4 +# pull_request: +# branches: +# - "*" +#jobs: +# tests: +# strategy: +# fail-fast: false +# matrix: +# os: [ ubuntu-latest ] +# scenario: [ +# "cypress/e2e/jobs/copy-source-text-flow/filters.cy.js", +# "cypress/e2e/jobs/copy-source-text-flow/success-path-multiple.cy.js", +# "cypress/e2e/jobs/copy-source-text-flow/success-path-single.cy.js", +# "cypress/e2e/jobs/instant/success-path-multiple.cy.js", +# "cypress/e2e/jobs/instant/success-path-multiple-copy-slug.cy.js", +# "cypress/e2e/jobs/instant/success-path-multiple-copy-slug-and-enable-after-publish.cy.js", +# "cypress/e2e/jobs/instant/success-path-multiple-enable-after-publish.cy.js", +# "cypress/e2e/jobs/verified/success-path-multiple-bulk-publishing.cy.js", +# "cypress/e2e/jobs/verified/success-path-multiple-bulk-publishing-copy-slug.cy.js", +# "cypress/e2e/jobs/verified/success-path-multiple-bulk-publishing-copy-slug-and-enable-after-publish.cy.js", +# "cypress/e2e/jobs/verified/success-path-multiple-bulk-publishing-enable-after-publish.cy.js", +# "cypress/e2e/jobs/verified/success-path-multiple-single-publishing.cy.js", +# "cypress/e2e/jobs/verified/success-path-multiple-single-publishing-copy-slug.cy.js", +# "cypress/e2e/jobs/verified/success-path-multiple-single-publishing-copy-slug-and-enable-after-publish.cy.js", +# "cypress/e2e/jobs/verified/success-path-multiple-single-publishing-enable-after-publish.cy.js", +# "cypress/e2e/jobs/verified/success-path-single.cy.js", +# "cypress/e2e/jobs/instant/success-path-single.cy.js", +# ] +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v2 +# - name: Set the value +# id: step_one +# run: | +# echo "CYPRESS_SCENARIO=${{ matrix.scenario }}" >> $GITHUB_ENV +# echo "DB_DATABASE=$(uuidgen)" >> $GITHUB_ENV +# - name: Run automation +# working-directory: ./e2e +# run: | +# echo ${DB_DATABASE} +# make up +# make e2e-github +# - name: Copy artifacts +# if: ${{ failure() }} +# working-directory: ./e2e +# run: | +# make backup-db +# mkdir var +# mkdir var/log +# mkdir cypress/craft +# mkdir cypress/craft/storage +# mkdir cypress/craft/config +# docker compose cp app:/app/storage cypress/craft/storage +# docker compose cp app:/app/config cypress/craft/config +# docker compose cp app:/app/composer.json cypress/craft +# docker compose cp app:/app/composer.lock cypress/craft +# docker compose cp app:/var/log var/log +# - name: Use the Upload Artifact GitHub Action +# uses: actions/upload-artifact@v2 +# if: ${{ failure() }} +# with: +# name: "${{ github.job }}_${{ github.run_id }}_${{ github.workflow }}_e2e_artifacts" +# path: | +# ./e2e/cypress/craft +# ./e2e/cypress/screenshots +# ./e2e/cypress/videos +# ./e2e/happy-lager-main/storage diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 3211b5fd..6d1da32b 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -1,72 +1,73 @@ -name: Tests -on: - push: - branches: - - 4.x #CraftCMS v4 - pull_request: - branches: - - "*" -jobs: - tests-php-80: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set the value - id: step_one - run: | - echo "PHP_VERSION=8.0" >> $GITHUB_ENV - - name: Build containers - run: make up - - name: Composer install - run: make composer-install - - name: Tests - run: make test - - tests-php-80-mysql-80: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set the value - id: step_one - run: | - echo "PHP_VERSION=8.0" >> $GITHUB_ENV - echo "MYSQL_VERSION=8.0" >> $GITHUB_ENV - - name: Build containers - run: make up - - name: Composer install - run: make composer-install - - name: Tests - run: make test - - tests-php-81: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set the value - run: | - echo "PHP_VERSION=8.1" >> $GITHUB_ENV - - name: Build containers - run: make up - - name: Composer install - run: make composer-install - - name: Quality - run: make quality - - name: Use the Upload Artifact GitHub Action - uses: actions/upload-artifact@v2 - with: - name: assets-for-download - path: composer.lock - - name: Tests - run: make tests-with-coverage - - name: Codecov - uses: codecov/codecov-action@v3.1.0 - with: - files: ./tests/_output/coverage-integration.xml - - name: Codecov - uses: codecov/codecov-action@v3.1.0 - with: - files: ./tests/_output/coverage-functional.xml - - name: Codecov - uses: codecov/codecov-action@v3.1.0 - with: - files: ./tests/_output/coverage-unit.xml \ No newline at end of file +#TODO: once craftcms v5 released fix all pipelines +#name: Tests +#on: +# push: +# branches: +# - 4.x #CraftCMS v4 +# pull_request: +# branches: +# - "*" +#jobs: +# tests-php-80: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v2 +# - name: Set the value +# id: step_one +# run: | +# echo "PHP_VERSION=8.0" >> $GITHUB_ENV +# - name: Build containers +# run: make up +# - name: Composer install +# run: make composer-install +# - name: Tests +# run: make test +# +# tests-php-80-mysql-80: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v2 +# - name: Set the value +# id: step_one +# run: | +# echo "PHP_VERSION=8.0" >> $GITHUB_ENV +# echo "MYSQL_VERSION=8.0" >> $GITHUB_ENV +# - name: Build containers +# run: make up +# - name: Composer install +# run: make composer-install +# - name: Tests +# run: make test +# +# tests-php-81: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v2 +# - name: Set the value +# run: | +# echo "PHP_VERSION=8.1" >> $GITHUB_ENV +# - name: Build containers +# run: make up +# - name: Composer install +# run: make composer-install +# - name: Quality +# run: make quality +# - name: Use the Upload Artifact GitHub Action +# uses: actions/upload-artifact@v2 +# with: +# name: assets-for-download +# path: composer.lock +# - name: Tests +# run: make tests-with-coverage +# - name: Codecov +# uses: codecov/codecov-action@v3.1.0 +# with: +# files: ./tests/_output/coverage-integration.xml +# - name: Codecov +# uses: codecov/codecov-action@v3.1.0 +# with: +# files: ./tests/_output/coverage-functional.xml +# - name: Codecov +# uses: codecov/codecov-action@v3.1.0 +# with: +# files: ./tests/_output/coverage-unit.xml \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index c395fe01..c39ac134 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## 5.0.0 - 2024-02-09 +### Added +- Support of CraftCMS v5 + ## 4.4.5 - 2024-02-09 ### Fixed - Translation of nested link field diff --git a/composer.json b/composer.json index 8fa6fc3b..2aaf1f65 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "lilt/craft-lilt-plugin", "description": "The Lilt plugin makes it easy for you to send content to Lilt for translation right from within Craft CMS.", "type": "craft-plugin", - "version": "4.4.5", + "version": "5.0.0", "keywords": [ "craft", "cms", @@ -22,22 +22,22 @@ } ], "require": { - "craftcms/cms": "^4.0.0", + "craftcms/cms": "5.0.0-beta.11", "lilt/lilt-connector-sdk-php": "0.1.0", "ext-json": "*", "php": "^8.0" }, "require-dev": { - "codeception/codeception": "^3.0 | ^4.0", - "vlucas/phpdotenv": "^3.0", - "squizlabs/php_codesniffer": "^3.6", + "codeception/codeception": "^5.1", + "vlucas/phpdotenv": "^3.6", + "squizlabs/php_codesniffer": "^3.9", "codeception/module-yii2": "^1.1", - "codeception/module-asserts": "^1.3", - "craftcms/redactor": "^2.0 || ^3.0", - "percipioglobal/craft-colour-swatches": "^1.0 || ^4.0", - "spicyweb/craft-neo": "3.1.5", - "verbb/super-table": "^3.0", - "wiremock-php/wiremock-php": "^2.33" + "codeception/module-asserts": "^3.0.0", + "craftcms/redactor": "4.0.x-dev", + "verbb/super-table": "4.0.0-beta.1", + "spicyweb/craft-neo": "5.x-dev", + "wiremock-php/wiremock-php": "^2.35", + "verbb/base": "^3.0.0-beta.1" }, "autoload": { "psr-4": { diff --git a/src/assets/resources/elements/LiltElementIndex.js b/src/assets/resources/elements/LiltElementIndex.js index bd3898d6..87c5a5d7 100644 --- a/src/assets/resources/elements/LiltElementIndex.js +++ b/src/assets/resources/elements/LiltElementIndex.js @@ -14,65 +14,6 @@ Craft.LiltElementIndex = Craft.BaseElementIndex.extend({ return true; }, - //TODO: we need to find better way for it - getViewParams: function() { - var criteria = { - siteId: this.siteId, - search: this.searchText, - offset: this.settings.batchSize * (this.page - 1), - limit: this.settings.batchSize, - }; - - // Only set drafts/draftOf/trashed params when needed, so we don't potentially override a source's criteria - if ( - this.settings.canHaveDrafts && - (this.drafts || (this.settings.context === 'index' && !this.status)) - ) { - criteria.drafts = this.drafts || null; - criteria.savedDraftsOnly = true; - if (!this.drafts) { - criteria.draftOf = false; - } - } - if (this.trashed) { - criteria.trashed = true; - } - - if (!Garnish.hasAttr(this.$source, 'data-override-status')) { - criteria.status = this.status; - } - - $.extend(criteria, this.settings.criteria); - - var params = { - context: this.settings.context, - elementType: this.elementType, - source: this.instanceState.selectedSource, - criteria: criteria, - disabledElementIds: this.settings.disabledElementIds, - viewState: $.extend({}, this.getSelectedSourceState()), - paginated: this._isViewPaginated() ? 1 : 0, - showEntryVersions: this.settings.showEntryVersions - }; - - // Possible that the order/sort isn't entirely accurate if we're sorting by Score - params.viewState.order = this.getSelectedSortAttribute(); - params.viewState.sort = this.getSelectedSortDirection(); - - if (this.getSelectedSortAttribute() === 'structure') { - if (typeof this.instanceState.collapsedElementIds === 'undefined') { - this.instanceState.collapsedElementIds = []; - } - params.collapsedElementIds = this.instanceState.collapsedElementIds; - } - - // Give plugins a chance to hook in here - this.trigger('registerViewParams', { - params: params, - }); - - return params; - }, getDefaultSort: function() { return ['elements.dateCreated', 'desc']; }, @@ -272,5 +213,61 @@ Craft.LiltElementIndex = Craft.BaseElementIndex.extend({ getSortDirectionOption: function(dir) { return []; }, + getSourceLabel: function () { + // CraftCMS v5 required change to check for empty sources + if(this.$sources === undefined) { + return + } + return this.$source.data('label'); + }, + updateSourceVisibility: function () { + this.$visibleSources = $(); + + // CraftCMS v5 required change to check for empty sources + if(this.$sources === undefined) { + return + } + for (let i = 0; i < this.$sources.length; i++) { + const $source = this.$sources.eq(i); + + if ( + !Garnish.hasAttr($source, 'data-disabled') && + (typeof $source.data('sites') === 'undefined' || + $source + .data('sites') + .toString() + .split(',') + .some((siteId) => { + if (siteId == this.siteId) { + return true; + } + // maybe UUIDs were used + if (siteId != parseInt(siteId)) { + const site = Craft.sites.find( + (site) => site.id == this.siteId + ); + if (site && siteId == site.uid) { + return true; + } + } + + return false; + })) + ) { + $source.parent().removeClass('hidden'); + this.$visibleSources = this.$visibleSources.add($source); + } else { + $source.parent().addClass('hidden'); + + // Is this the currently selected source? + if (this.$source && this.$source.get(0) === $source.get(0)) { + this.$source = null; + this.$rootSource = null; + this.sourceKey = null; + this.rootSourceKey = null; + } + } + } + }, }); diff --git a/src/assets/resources/job-form.js b/src/assets/resources/job-form.js index 7be87c6c..7fabdf15 100644 --- a/src/assets/resources/job-form.js +++ b/src/assets/resources/job-form.js @@ -228,14 +228,16 @@ CraftliltPlugin.JobForm = Garnish.Base.extend({ }); } catch (e) { - console.log(e); + console.log("Can't preloadElementIndex due to error:",e); } }, createElementIndex: function(settings) { Craft.elementIndex = new Craft.LiltElementIndex( 'lilthq\\craftliltplugin\\elements\\TranslateEntry', - $('#entries-to-translate'), settings); + $('#entries-to-translate'), + settings + ); }, preloadVersions: function() { if (!this.$selectedVersions || !this.$selectedVersions.length > 0) { diff --git a/src/elements/Job.php b/src/elements/Job.php index 0738d473..9b684be3 100644 --- a/src/elements/Job.php +++ b/src/elements/Job.php @@ -434,24 +434,23 @@ public function getTargetSiteIdsHtml(): string return $html; } - protected function tableAttributeHtml(string $attribute): string + protected function attributeHtml(string $attribute): string { switch ($attribute) { case 'sourceSiteId': return $this->getSourceSiteIdHtml(); - case 'status': return $this->getStatusHtml(); + case 'targetSiteIds': + return $this->getTargetSiteIdsHtml(); //TODO: due date not in use at the moment //case 'dueDate': // return $this->dueDate->format( // Craft::$app->locale->getDateFormat('short', 'php') // ); - case 'targetSiteIds': - return $this->getTargetSiteIdsHtml(); } - return parent::tableAttributeHtml($attribute); + return parent::attributeHtml($attribute); } public function getStatus(): ?string @@ -466,7 +465,7 @@ public function isEditable(): bool public function getUrl(): string { - return CraftliltpluginParameters::JOB_EDIT_PATH . '/' . $this->id; + return CraftliltpluginParameters::JOB_EDIT_PATH . '/getUrl/' . $this->id; } public function getTranslationWorkflowLabel(): string diff --git a/src/elements/Translation.php b/src/elements/Translation.php index 89f2205e..ebc7f43c 100644 --- a/src/elements/Translation.php +++ b/src/elements/Translation.php @@ -35,6 +35,8 @@ class Translation extends Element { use TranslationModelTrait; + public $actions = null; + public ?int $id = null; public ?string $uid = null; public ?string $title = null; @@ -270,7 +272,7 @@ public function getSourceSiteIdHtml(): string . ""; } - protected function tableAttributeHtml(string $attribute): string + protected function attributeHtml(string $attribute): string { switch ($attribute) { case 'sourceSiteId': @@ -285,7 +287,7 @@ protected function tableAttributeHtml(string $attribute): string return $this->getTargetSiteNameHtml(); } - return parent::tableAttributeHtml($attribute); + return parent::attributeHtml($attribute); } public static function sources(string $context = null): array diff --git a/src/elements/db/JobQuery.php b/src/elements/db/JobQuery.php index 3c92dba4..15926a0d 100644 --- a/src/elements/db/JobQuery.php +++ b/src/elements/db/JobQuery.php @@ -23,7 +23,7 @@ class JobQuery extends ElementQuery public mixed $dateCreated = null; public mixed $dateUpdated = null; - public function status($value): self + public function status($value): static { $this->status = $value; diff --git a/src/elements/db/TranslationQuery.php b/src/elements/db/TranslationQuery.php index 08a06eb3..b47eedff 100644 --- a/src/elements/db/TranslationQuery.php +++ b/src/elements/db/TranslationQuery.php @@ -24,7 +24,7 @@ class TranslationQuery extends ElementQuery public $jobId; - public function status($value): self + public function status($value): static { $this->status = $value; @@ -86,7 +86,7 @@ protected function beforePrepare(): bool $this->joinElementTable('lilt_translations'); /** GET TITLE */ - $this->query->innerJoin(Table::CONTENT . ' content', [ + $this->query->innerJoin(Table::ELEMENTS_SITES . ' content', [ 'and', '[[content.elementId]] = [[lilt_translations.elementId]]', '[[content.siteId]] = [[lilt_translations.sourceSiteId]]' diff --git a/src/parameters/CraftliltpluginParameters.php b/src/parameters/CraftliltpluginParameters.php index 0b822360..55f8c361 100755 --- a/src/parameters/CraftliltpluginParameters.php +++ b/src/parameters/CraftliltpluginParameters.php @@ -22,6 +22,7 @@ class CraftliltpluginParameters { + public const PLUGIN_PATH = 'craft-lilt-plugin'; public const REPORT_DATA = 'craft-lilt-plugin/get-report-data/invoke'; public const TRANSLATION_REVIEW_ACTION = 'craft-lilt-plugin/translation/post-translation-review/invoke'; public const TRANSLATION_PUBLISH_ACTION = 'craft-lilt-plugin/translation/post-translation-publish/invoke'; diff --git a/src/services/providers/field/ContentProviderInterface.php b/src/services/providers/field/ContentProviderInterface.php index 30e5e3bd..76611120 100644 --- a/src/services/providers/field/ContentProviderInterface.php +++ b/src/services/providers/field/ContentProviderInterface.php @@ -4,10 +4,17 @@ namespace lilthq\craftliltplugin\services\providers\field; +use craft\errors\InvalidFieldException; use lilthq\craftliltplugin\services\providers\command\ProvideContentCommand; interface ContentProviderInterface { + /** + * @param ProvideContentCommand $provideContentCommand + * @return mixed + * + * @throws InvalidFieldException + */ public function provide(ProvideContentCommand $provideContentCommand); public function support(ProvideContentCommand $command): bool; } diff --git a/src/services/providers/field/FieldContentProvider.php b/src/services/providers/field/FieldContentProvider.php index d2f455bb..df1a5293 100644 --- a/src/services/providers/field/FieldContentProvider.php +++ b/src/services/providers/field/FieldContentProvider.php @@ -4,6 +4,7 @@ namespace lilthq\craftliltplugin\services\providers\field; +use craft\errors\InvalidFieldException; use lilthq\craftliltplugin\services\providers\command\ProvideContentCommand; class FieldContentProvider @@ -33,6 +34,19 @@ public function provide(ProvideContentCommand $provideContentCommand) return null; } - return $this->providersMap[$fieldClass]->provide($provideContentCommand); + try { + return $this->providersMap[$fieldClass]->provide($provideContentCommand); + } catch (InvalidFieldException $ex) { + \Craft::error( + sprintf( + "Can't get field value %s for element %s: %s", + $ex->getMessage(), + $provideContentCommand->getField()->handle, + $provideContentCommand->getElement()->getId() + ) + ); + + return null; + } } }