-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add simple in-memory cache for helpers, refactor helpers (#67)
* Dont run vendor fixtures by default, add flag to run vendor fixtures * Trailing slashes! * Change docs formats * Use first class callable syntax * Refactor FixtureTrait * Enable phpstan rule: checkMissingIterableValueType * Enable rule checkGenericClassInNonGenericObjectType in psalm * Add database utils and first method to delete entities * Automatically assign the fixtureHelper to each fixture * Disable error warnings if generics arent provided, since they were added in SW 6.5.something * Add property trait, refactor category utils * Refactor all utils classes * Move out all locale & language related methods of the sales channel fixture * Extract currency related methods of SalesChannelUtils to CurrencyUtils * Extract tax methods into TaxUtils * wip * Remove double definition of method * Remove trait
- Loading branch information
Showing
16 changed files
with
509 additions
and
238 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Basecom\FixturePlugin\Utils; | ||
|
||
use Shopware\Core\Framework\Context; | ||
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; | ||
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria; | ||
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter; | ||
use Shopware\Core\System\Currency\CurrencyCollection; | ||
use Shopware\Core\System\Currency\CurrencyEntity; | ||
|
||
/** | ||
* This class provides utility methods to work with currencies. It has build in caching to prevent | ||
* multiple database queries for the same data within one command execution / request. | ||
* | ||
* This class is designed to be used through the FixtureHelper, using: | ||
* ```php | ||
* $this->helper->Currency()->……(); | ||
* ``` | ||
*/ | ||
class CurrencyUtils | ||
{ | ||
/** | ||
* @param EntityRepository<CurrencyCollection> $currencyRepository | ||
*/ | ||
public function __construct( | ||
private EntityRepository $currencyRepository, | ||
) { | ||
} | ||
|
||
public function getCurrencyEuro(): ?CurrencyEntity | ||
{ | ||
return once(function (): ?CurrencyEntity { | ||
$criteria = (new Criteria()) | ||
->addFilter(new EqualsFilter('isoCode', 'EUR')) | ||
->setLimit(1); | ||
|
||
$criteria->setTitle(sprintf('%s::%s()', __CLASS__, __FUNCTION__)); | ||
|
||
$currency = $this->currencyRepository | ||
->search($criteria, Context::createDefaultContext()) | ||
->first(); | ||
|
||
return $currency instanceof CurrencyEntity ? $currency : null; | ||
}); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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.