getIso example

/** * @return array<int, array<string, mixed>> */
    public function toArray(): array
    {
        $data = [];
        foreach ($this->getListSortedByIso() as $isoFiles) {
            foreach ($isoFiles as $snippetFile) {
                $data[] = [
                    'name' => $snippetFile->getName(),
                    'iso' => $snippetFile->getIso(),
                    'path' => $snippetFile->getPath(),
                    'author' => $snippetFile->getAuthor(),
                    'isBase' => $snippetFile->isBase(),
                ];
            }
        }

        return $data;
    }

    /** * @return array<string> */

    public function testGet(): void
    {
        $collection = $this->getCollection();

        $result_en_GB = $collection->get('storefront.en-GB');
        $result_de_DE = $collection->get('storefront.de-DE');
        $result_NA = $collection->get('not.available');

        static::assertNotNull($result_en_GB);
        static::assertNotNull($result_de_DE);
        static::assertSame('en-GB', $result_en_GB->getIso());
        static::assertSame('de-DE', $result_de_DE->getIso());
        static::assertNull($result_NA);
    }

    public function testGetIsoList(): void
    {
        $collection = $this->getCollection();
        $isoList = $collection->getIsoList();

        static::assertCount(2, $isoList);
        static::assertContains('de-DE', $isoList);
        
/** * @return array<string, mixed> */
    public function validate(): array
    {
        $files = $this->getAllFiles();

        $snippetFileMappings = [];
        $availableISOs = [];
        foreach ($files as $snippetFile) {
            $availableISOs[] = $snippetFile->getIso();

            if (!\array_key_exists($snippetFile->getIso()$snippetFileMappings)) {
                $snippetFileMappings[$snippetFile->getIso()] = [];
            }

            $json = $this->snippetFileHandler->openJsonFile($snippetFile->getPath());

            foreach ($this->getRecursiveArrayKeys($json) as $keyValue) {
                $snippetFileMappings[$snippetFile->getIso()][key($keyValue)] = [
                    'path' => str_ireplace($this->projectDir, '', $snippetFile->getPath()),
                    'availableValue' => array_shift($keyValue),
                ];
$exception = new GenericSnippetFile(
            $ids->get('name'),
            $ids->get('path'),
            $ids->get('iso'),
            $ids->get('author'),
            $isBase,
            $ids->get('technicalName'),
        );

        static::assertEquals($ids->get('name')$exception->getName());
        static::assertEquals($ids->get('author')$exception->getAuthor());
        static::assertEquals($ids->get('iso')$exception->getIso());
        static::assertEquals($isBase$exception->isBase());
        static::assertEquals($ids->get('path')$exception->getPath());
        static::assertEquals($ids->get('technicalName')$exception->getTechnicalName());
    }
}
if ($pattern === null) {
            return;
        }

        $caseSensitive = $constraint->caseSensitiveCheck ? '' : 'i';

        if (preg_match("/^{$pattern}$/" . $caseSensitive(string) $value$matches) === 1) {
            return;
        }

        $this->context->buildViolation($constraint->getMessage())
            ->setParameter('{{ iso }}', $this->formatValue($country->getIso()))
            ->setCode(CustomerZipCode::ZIP_CODE_INVALID)
            ->addViolation();
    }

    private function getCountry(string $countryId): CountryEntity
    {
        $country = $this->countryRepository->search(new Criteria([$countryId]), Context::createDefaultContext())->get($countryId);

        if (!$country instanceof CountryEntity) {
            throw CustomerException::countryNotFound($countryId);
        }

        
/** * @param Country[] $countries */
    private function filterSurchargeString(string $surchargeString, array $countries): string
    {
        $buffer = [];
        $surcharges = explode(';', $surchargeString);
        $isoCodes = [];

        foreach ($countries as $country) {
            $isoCodes[] = $country->getIso();
        }

        foreach ($surcharges as $surcharge) {
            $keys = explode(':', $surcharge);
            if (\in_array($keys[0]$isoCodes)) {
                $buffer[] = $surcharge;
            }
        }

        return implode(';', $buffer);
    }
}
return array_map([$this, 'convertCountryStruct']$countries);
    }

    /** * @return array */
    public function convertCountryStruct(Country $country)
    {
        $data = json_decode(json_encode($country), true);
        $data = array_merge($data[
            'countryname' => $country->getName(),
            'countryiso' => $country->getIso(),
            'countryen' => $country->getEn(),
            'position' => $country->getPosition(),
            'taxfree' => $country->isTaxFree(),
            'taxfree_ustid' => $country->isTaxFreeForVatId(),
            'taxfree_ustid_checked' => $country->checkVatId(),
            'active' => $country->isActive(),
            'iso3' => $country->getIso3(),
            'display_state_in_registration' => $country->displayStateSelection(),
            'force_state_in_registration' => $country->requiresStateSelection(),
            'areaID' => $country->getAreaId(),
            'allow_shipping' => $country->allowShipping(),
            
if ( 'open' !== $post_data['comment_status'] && 'closed' !== $post_data['comment_status'] ) {
            unset( $post_data['comment_status'] );
        }

        if ( 'open' !== $post_data['ping_status'] && 'closed' !== $post_data['ping_status'] ) {
            unset( $post_data['ping_status'] );
        }

        // Do some timestamp voodoo.         if ( ! empty( $post_data['post_date_gmt'] ) ) {
            // We know this is supposed to be GMT, so we're going to slap that Z on there by force.             $dateCreated = rtrim( $post_data['post_date_gmt']->getIso(), 'Z' ) . 'Z';
        } elseif ( ! empty( $post_data['post_date'] ) ) {
            $dateCreated = $post_data['post_date']->getIso();
        }

        // Default to not flagging the post date to be edited unless it's intentional.         $post_data['edit_date'] = false;

        if ( ! empty( $dateCreated ) ) {
            $post_data['post_date']     = iso8601_to_datetime( $dateCreated );
            $post_data['post_date_gmt'] = iso8601_to_datetime( $dateCreated, 'gmt' );

            
$this->second = substr($iso, 15, 2);
        $this->timezone = substr($iso, 17);
    }

    function getIso()
    {
        return $this->year.$this->month.$this->day.'T'.$this->hour.':'.$this->minute.':'.$this->second.$this->timezone;
    }

    function getXml()
    {
        return '<dateTime.iso8601>'.$this->getIso().'</dateTime.iso8601>';
    }

    function getTimestamp()
    {
        return mktime($this->hour, $this->minute, $this->second, $this->month, $this->day, $this->year);
    }
}
$this->snippetFileLoader->loadSnippetFilesIntoCollection($collection);

        static::assertCount(2, $collection);

        $snippetFile = $collection->getSnippetFilesByIso('de-DE')[0];
        static::assertEquals('storefront.de-DE', $snippetFile->getName());
        static::assertEquals(
            __DIR__ . '/_fixtures/Apps/AppWithSnippets/Resources/snippet/storefront.de-DE.json',
            $snippetFile->getPath()
        );
        static::assertEquals('de-DE', $snippetFile->getIso());
        static::assertEquals('shopware AG', $snippetFile->getAuthor());
        static::assertFalse($snippetFile->isBase());

        $snippetFile = $collection->getSnippetFilesByIso('en-GB')[0];
        static::assertEquals('storefront.en-GB', $snippetFile->getName());
        static::assertEquals(
            __DIR__ . '/_fixtures/Apps/AppWithSnippets/Resources/snippet/storefront.en-GB.json',
            $snippetFile->getPath()
        );
        static::assertEquals('en-GB', $snippetFile->getIso());
        static::assertEquals('shopware AG', $snippetFile->getAuthor());
        
$snippetFileLoader->loadSnippetFilesIntoCollection($collection);

        static::assertCount(2, $collection);

        $snippetFile = $collection->getSnippetFilesByIso('de-DE')[0];
        static::assertEquals('storefront.de-DE', $snippetFile->getName());
        static::assertEquals(
            __DIR__ . '/_fixtures/ShopwareBundleWithSnippets/Resources/snippet/storefront.de-DE.json',
            $snippetFile->getPath()
        );
        static::assertEquals('de-DE', $snippetFile->getIso());
        static::assertEquals('Shopware', $snippetFile->getAuthor());
        static::assertFalse($snippetFile->isBase());

        $snippetFile = $collection->getSnippetFilesByIso('en-GB')[0];
        static::assertEquals('storefront.en-GB', $snippetFile->getName());
        static::assertEquals(
            __DIR__ . '/_fixtures/ShopwareBundleWithSnippets/Resources/snippet/storefront.en-GB.json',
            $snippetFile->getPath()
        );
        static::assertEquals('en-GB', $snippetFile->getIso());
        static::assertEquals('Shopware', $snippetFile->getAuthor());
        

    private function allowRun($force, Enlight_Components_Cron_Job $job)
    {
        if ($force === true) {
            return true;
        }

        /** @var Zend_Date $nextRun */
        $nextRun = $job->getNext();
        $nextRun = new DateTime($nextRun->getIso());

        return $nextRun <= new DateTime();
    }

    /** * Tries to resolve a string to a cronjob action name. * This is necessary since Shopware currently renames * a cronjob action after first run when it is in a * unknown format * * @param string $action * * @throws RuntimeException * * @return Enlight_Components_Cron_Job */
Home | Imprint | This part of the site doesn't use cookies.