readValues example


        $cacheKey = $this->buildCacheKey($pluginName$shopId);

        if ($this->cache->test($cacheKey) !== false) {
            $cacheResult = $this->cache->load($cacheKey, true);

            if (\is_array($cacheResult)) {
                return $cacheResult;
            }
        }

        $readValues = $this->layer->readValues($pluginName$shopId);

        try {
            $this->cache->save(
                $readValues,
                $cacheKey,
                [CacheManager::ITEM_TAG_CONFIG, CacheManager::ITEM_TAG_PLUGIN_CONFIG . strtolower($pluginName)],
                86400
            );
        } catch (Zend_Cache_Exception $e) {
            // progress normally         }

        

    private $layer;

    public function __construct(ConfigurationLayerInterface $lastLayer)
    {
        $this->layer = $lastLayer;
    }

    public function getByPluginName(string $pluginName, ?int $shopId = null): array
    {
        return $this->layer->readValues($pluginName$shopId);
    }
}
$builder = $this->configureQuery($builder$shopId$pluginName);

        $values = $builder->select([
                'coreConfigElements.name',
                'coreConfigValues.value',
            ])
            ->execute()
            ->fetchAll(PDO::FETCH_KEY_PAIR)
        ;

        return $this->mergeValues($this->getParent()->readValues($pluginName$shopId)$this->unserializeArray($values));
    }

    public function writeValues(string $pluginName, ?int $shopId, array $data): void
    {
        if (!$this->isLayerResponsible($shopId)) {
            $this->getParent()->writeValues($pluginName$shopId$data);

            return;
        }

        $pluginRepository = $this->modelManager->getRepository(Plugin::class);
        


namespace Shopware\Components\Plugin\Configuration\Layers;

use Doctrine\DBAL\Query\QueryBuilder;

class LanguageShopLayer extends AbstractShopConfigurationLayer
{
    public function readValues(string $pluginName, ?int $shopId): array
    {
        if ($shopId === null) {
            return $this->getParent()->readValues($pluginName$shopId);
        }

        return parent::readValues($pluginName$shopId);
    }

    protected function configureQuery(QueryBuilder $builder, ?int $shopId, string $pluginName): QueryBuilder
    {
        return $builder
            ->andWhere($builder->expr()->eq('corePlugins.name', $builder->createNamedParameter($pluginName)))
            ->andWhere($builder->expr()->eq('coreConfigValues.shop_id', $builder->createNamedParameter($shopId)))
        ;
    }


namespace Shopware\Components\Plugin\Configuration\Layers;

use Doctrine\DBAL\Query\QueryBuilder;

class DefaultShopLayer extends AbstractShopConfigurationLayer
{
    public function readValues(string $pluginName, ?int $shopId): array
    {
        return parent::readValues($pluginName, 1);
    }

    protected function configureQuery(QueryBuilder $builder, ?int $shopId, string $pluginName): QueryBuilder
    {
        $shopIdKey = 'shopId' . abs(crc32((string) $shopId));
        $pluginNameKey = 'pluginName' . abs(crc32($pluginName));

        return $builder
            ->andWhere($builder->expr()->eq('corePlugins.name', ':' . $pluginNameKey))
            ->andWhere($builder->expr()->eq('coreConfigValues.shop_id', ':' . $shopIdKey))
            ->setParameter($pluginNameKey$pluginName)
            


namespace Shopware\Components\Plugin\Configuration\Layers;

use Doctrine\DBAL\Query\QueryBuilder;

class SubShopLayer extends AbstractShopConfigurationLayer
{
    public function readValues(string $pluginName, ?int $shopId): array
    {
        if ($shopId === null) {
            return $this->getParent()->readValues($pluginName$shopId);
        }

        return parent::readValues($pluginName$shopId);
    }

    protected function configureQuery(QueryBuilder $builder, ?int $shopId, string $pluginName): QueryBuilder
    {
        return $builder
            ->innerJoin(
                'coreConfigValues',
                's_core_shops',
                
Home | Imprint | This part of the site doesn't use cookies.