basz / SlmLocale

Auto detection of locale through different strategies for Zend Framework 2
Other
67 stars 34 forks source link

Fix issue #67 - New AssetStrategy #93

Closed koseduhemak closed 6 years ago

koseduhemak commented 7 years ago

Fixing problems of issue #67, which describes problems by using SlmLocale in combination with the famous https://github.com/RWOverdijk/AssetManager module.

Problem

When using asset manager to manage assets in your project, uris of assets getting rewritten to locale aware uris. This leads to 404 not found, because the assetmanager is not able to resolve them anymore. Therefore we need a strategy to cope such uris.

Solution

The provided AssetStrategy checks if the requested uri is an asset and prevents url rewriting through other strategies.

Example config

return [
    'slm_locale' => [
        'default' => 'de_DE',

        'supported' => ['en_GB', 'de_DE'],

        'strategies' => [
           [
                'name' => SlmLocale\Strategy\AssetStrategy::class,
                'options' => [
                    'file_extensions' => [
                        'css', 'js'
                    ]
                ]
            ],
            'query',
            [
                'name' => \SlmLocale\Strategy\UriPathStrategy::class,
                'options' => [
                    'redirect_when_found' => true,
                    'aliases' => array('de' => 'de_DE', 'en' => 'en_GB'),
                ]
            ],
            'cookie',
            'acceptlanguage'
        ],

        'mappings' => [
            'en' => 'en_GB',
            'de' => 'de_DE',
        ]
    ],
];
koseduhemak commented 7 years ago

Why is travis failing? I am not experienced in pull requests... Please provide some hint so I can fix...

basz commented 7 years ago

Cause you have code style errors.

See log: https://travis-ci.org/basz/SlmLocale/jobs/298633316

You are able to run those checks yourself before committing with this command

vendor/bin/php-cs-fixer fix -v --diff --dry-run

basz commented 7 years ago

One of your tests isnt passing

koseduhemak commented 7 years ago

By fixing code style issues I accidentally removed a line of code... Now everything should be working.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.4%) to 80.211% when pulling 85f13fda7ff46067c3a1fee8129d351660aa8f42 on koseduhemak:master into 7df75ebd30baa0238e0f4ae895656b3ff3a491f3 on basz:master.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.6%) to 80.423% when pulling ed76a86b797e4267cc82f1d7a2242ad03663d432 on koseduhemak:master into 7df75ebd30baa0238e0f4ae895656b3ff3a491f3 on basz:master.

svycka commented 6 years ago

refactored here https://github.com/basz/SlmLocale/pull/97