loadConfig example

use Shopware\Components\Api\Exception\BatchInterfaceNotImplementedException;
use Shopware\Components\Api\Exception\CustomValidationException;
use Shopware\Components\Api\Exception\NonUniqueIdentifierUsedException;
use Shopware\Components\Api\Exception\NotFoundException;
use Shopware\Components\Api\Exception\OrmException;
use Shopware\Components\Api\Exception\ParameterMissingException;
use Shopware\Components\Api\Exception\PrivilegeException;
use Shopware\Components\Api\Exception\ValidationException;
use Shopware\Components\Logger;

if (file_exists($this->DocPath() . 'config_' . $this->Environment() . '.php')) {
    $customConfig = $this->loadConfig($this->DocPath() . 'config_' . $this->Environment() . '.php');
} elseif (file_exists($this->DocPath() . 'config.php')) {
    $customConfig = $this->loadConfig($this->DocPath() . 'config.php');
} else {
    $customConfig = [];
}

if (!\is_array($customConfig)) {
    throw new Enlight_Exception('The custom configuration file must return an array.');
}

return array_replace_recursive([
    

    protected function initializeConfig()
    {
        $configLoader = new ConfigLoader(
            $this->getRootDir(),
            $this->getCacheDir(),
            $this->environment,
            $this->name
        );

        $this->config = $configLoader->loadConfig(
            $this->getConfigPath()
        );
    }

    /** * Creates a new instance of the Shopware application */
    protected function initializeShopware()
    {
        $this->shopware = new Shopware($this->container);
        $this->container->setApplication($this->shopware);
    }
 {
        $this->mapping = MappingCollection::fromIterable($mapping);
    }

    /** * @param iterable<string, mixed> $record * * @return iterable<string, mixed> */
    public function in(Config $config, iterable $record): iterable
    {
        $this->loadConfig($config);

        $flat = ArrayNormalizer::flatten($record);

        $mapped = [];
        foreach ($flat as $key => $value) {
            $key = str_replace('extensions.', '', $key);
            $mapping = $this->mapping->get($key);
            if ($mapping === null) {
                continue;
            }

            
private string $escape = '\\',
        private bool $withHeader = true
    ) {
    }

    public function read(Config $config$resource, int $offset): iterable
    {
        if (!\is_resource($resource)) {
            throw new \InvalidArgumentException('Argument $resource is not a resource');
        }

        $this->loadConfig($config);

        $this->setOffset($offset);

        while (!feof($resource)) {
            // if we start at a non-zero offset, we need to re-parse the header and then continue at offset             if ($this->offset > 0 && $this->withHeader && $this->header === []) {
                $this->readSingleRecord($resource, 0);
            }

            $record = $this->readSingleRecord($resource$this->offset);
            $this->setOffset(ftell($resource));

            

    public function __construct(
        FilesystemOperator $filesystem,
        private string $delimiter = ';',
        private string $enclosure = '"'
    ) {
        parent::__construct($filesystem);
    }

    public function append(Config $config, array $data, int $index): void
    {
        $this->loadConfig($config);

        if ($index === 0) {
            $this->writeToBuffer(array_keys($data));
        }
        $this->writeToBuffer(array_values($data));
    }

    private function writeToBuffer(array $data): void
    {
        if (fputcsv($this->buffer, $data$this->delimiter, $this->enclosure) === false) {
            throw new \RuntimeException('Could not write to buffer');
        }
private ?EntityDefinition $definition = null,
        private ?AbstractEntitySerializer $entitySerializer = null,
        private readonly ?PrimaryKeyResolver $primaryKeyResolver = null
    ) {
    }

    /** * @param array<mixed> $record */
    public function in(Config $config, iterable $record): iterable
    {
        $this->loadConfig($config);

        return $this->entitySerializer->serialize($config$this->definition, $record);
    }

    public function out(Config $config, iterable $record): iterable
    {
        $this->loadConfig($config);

        if ($this->primaryKeyResolver) {
            $record = $this->primaryKeyResolver->resolvePrimaryKeyFromUpdatedBy($config$this->definition, $record);
        }

        
Home | Imprint | This part of the site doesn't use cookies.