-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #135 from lilt/4.x-fixes
Add cache for get job and get translations requests
- Loading branch information
Showing
11 changed files
with
283 additions
and
6 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
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
36 changes: 36 additions & 0 deletions
36
e2e/happy-lager-override/migrations/m231004_192344_set_fields_propagation.php
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,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace craft\contentmigrations; | ||
|
||
use Craft; | ||
use craft\db\Migration; | ||
use craft\fields\Matrix; | ||
use lilthq\craftliltplugin\parameters\CraftliltpluginParameters; | ||
|
||
/** | ||
* m230304_162344_set_fields_translatable migration. | ||
*/ | ||
class m231004_192344_set_fields_propagation extends Migration | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public function safeUp() | ||
{ | ||
$ignoreDropdownsRecord = new \lilthq\craftliltplugin\records\SettingRecord(['name' => 'ignore_dropdowns']); | ||
$ignoreDropdownsRecord->value = 1; | ||
$ignoreDropdownsRecord->save(); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function safeDown() | ||
{ | ||
echo "m230304_162344_set_fields_translatable can't be reverted.\n"; | ||
|
||
return true; | ||
} | ||
} |
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
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
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
47 changes: 47 additions & 0 deletions
47
src/services/appliers/field/LenzLinkFieldContentApplier.php
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,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace lilthq\craftliltplugin\services\appliers\field; | ||
|
||
use craft\errors\InvalidFieldException; | ||
use fruitstudios\linkit\fields\LinkitField; | ||
use lenz\linkfield\fields\LinkField; | ||
use lenz\linkfield\models\input\InputLink; | ||
use lilthq\craftliltplugin\parameters\CraftliltpluginParameters; | ||
|
||
class LenzLinkFieldContentApplier extends AbstractContentApplier implements ApplierInterface | ||
{ | ||
/** | ||
* @throws InvalidFieldException | ||
*/ | ||
public function apply(ApplyContentCommand $command): ApplyContentResult | ||
{ | ||
/** @var LinkField $field */ | ||
$field = $command->getField(); | ||
$fieldKey = $this->getFieldKey($command->getField()); | ||
$content = $command->getContent(); | ||
|
||
if (!isset($content[$fieldKey])) { | ||
return ApplyContentResult::fail(); | ||
} | ||
|
||
/** | ||
* @var InputLink $fieldValue | ||
*/ | ||
$fieldValue = $command->getElement()->getFieldValue( | ||
$field->handle | ||
); | ||
$fieldValue->customText = $content[$fieldKey]; | ||
|
||
$command->getElement()->setFieldValue($field->handle, $fieldValue); | ||
|
||
return ApplyContentResult::applied(); | ||
} | ||
|
||
public function support(ApplyContentCommand $command): bool | ||
{ | ||
return get_class($command->getField()) === CraftliltpluginParameters::LENZ_LINKFIELD | ||
&& $command->getField()->getIsTranslatable($command->getElement()); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/services/providers/field/LenzLinkFieldContentProvider.php
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 lilthq\craftliltplugin\services\providers\field; | ||
|
||
use craft\errors\InvalidFieldException; | ||
use fruitstudios\linkit\fields\LinkitField; | ||
use lenz\linkfield\fields\LinkField; | ||
use lenz\linkfield\models\input\InputLink; | ||
use lilthq\craftliltplugin\parameters\CraftliltpluginParameters; | ||
use lilthq\craftliltplugin\services\providers\command\ProvideContentCommand; | ||
|
||
class LenzLinkFieldContentProvider extends AbstractContentProvider | ||
{ | ||
/** | ||
* @throws InvalidFieldException | ||
*/ | ||
public function provide(ProvideContentCommand $provideContentCommand): ?string | ||
{ | ||
/** @var LinkField $field */ | ||
$field = $provideContentCommand->getField(); | ||
|
||
/** | ||
* @var InputLink $fieldValue | ||
*/ | ||
$fieldValue = $provideContentCommand->getElement()->getFieldValue( | ||
$field->handle | ||
); | ||
|
||
return $fieldValue->getCustomText(); | ||
} | ||
|
||
public function support(ProvideContentCommand $command): bool | ||
{ | ||
return get_class($command->getField()) === CraftliltpluginParameters::LENZ_LINKFIELD | ||
&& $command->getField()->getIsTranslatable($command->getElement()); | ||
} | ||
} |
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
Oops, something went wrong.