Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oro 6.0.x compatibility added #12

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ OroCommerce Geo Detection Bundle

Facts
-----
- version: 5.0.0
- version: 6.0.0
- composer name: aligent/oro-geo-detection

Description
Expand Down
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"oro/commerce": "5.0.*",
"oro/commerce": "6.0.*",
"geoip2/geoip2": "~2.0",
"guzzlehttp/guzzle": "^7.2"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"phpstan/phpstan": "^1.7",
"phpmd/phpmd": "^2.12",
"friendsofphp/php-cs-fixer": "~2.18.2 || ~3.1.0 || ~3.4.0",
"nelmio/alice": "~3.8.0 || ~3.9.0",
"theofidry/alice-data-fixtures": "~1.4.0 || ~1.5.0",
"symfony/phpunit-bridge": "~4.4.24 || ~6.1.0",
"squizlabs/php_codesniffer": "^3.6"
"phpstan/phpstan": "~1.10.0",
"phpmd/phpmd": "^2.15",
"friendsofphp/php-cs-fixer": "~2.18.2 || ~3.1.0 || ~3.57.0",
"nelmio/alice": "~3.8.0 || ~3.12.1",
"theofidry/alice-data-fixtures": "~1.4.0 || ~1.6.0",
"symfony/phpunit-bridge": "~4.4.24 || ~6.4.0",
"squizlabs/php_codesniffer": "^3.10.1"
}
}
1 change: 0 additions & 1 deletion src/AligentGeoDetectionBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@

class AligentGeoDetectionBundle extends Bundle
{

}
9 changes: 5 additions & 4 deletions src/Cache/GeoIpCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use GuzzleHttp\Client;
use Oro\Bundle\ConfigBundle\Config\ConfigManager;
use PharData;
use PharFileInfo;
use Psr\Log\LoggerInterface;
use Symfony\Component\Filesystem\Exception\IOExceptionInterface;
use Symfony\Component\Filesystem\Filesystem;
Expand Down Expand Up @@ -70,7 +69,7 @@ public function __construct(
*
* @return bool true if the warmer is optional, false otherwise
*/
public function isOptional()
public function isOptional(): bool
{
return true;
}
Expand All @@ -80,12 +79,12 @@ public function isOptional()
*
* {@inheritdoc}
*/
public function warmUp($cacheDir): void
public function warmUp($cacheDir): array
{
//avoid downloading if db is up to date
if ($this->isGeoDatabaseUpToDate()) {
$this->logger->info('Geo Database still up to date, no new download triggered');
return;
return [];
}

$tempWorkingDir = dirname($cacheDir) . static::GEO_TEMP_DIR;
Expand All @@ -99,6 +98,8 @@ public function warmUp($cacheDir): void
$tempDownloadFilePath = $this->downloadGeoDatabase($databaseUrl, $tempWorkingDir);
$this->decompressAndMove($tempDownloadFilePath, $this->database, $tempWorkingDir);
$this->removeTempWorkingDir($tempWorkingDir);

return [];
}

protected function isGeoDatabaseUpToDate()
Expand Down
6 changes: 3 additions & 3 deletions src/DependencyInjection/AligentGeoDetectionExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

namespace Aligent\GeoDetectionBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

class AligentGeoDetectionExtension extends Extension
{
Expand Down Expand Up @@ -43,7 +43,7 @@ public function load(array $configs, ContainerBuilder $container)
/**
* @return string
*/
public function getAlias()
public function getAlias(): string
{
return static::ALIAS;
}
Expand Down
6 changes: 2 additions & 4 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ class Configuration implements ConfigurationInterface

/**
* Generates the configuration tree builder.
*
* @return TreeBuilder The tree builder
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder(AligentGeoDetectionExtension::ALIAS);
$rootNode = $treeBuilder->getRootNode();
Expand All @@ -60,7 +58,7 @@ public function getConfigTreeBuilder()
* @param string $name
* @return string
*/
public static function getConfigKeyByName($name)
public static function getConfigKeyByName($name): string
{
return sprintf(
AligentGeoDetectionExtension::ALIAS . '%s%s',
Expand Down
4 changes: 2 additions & 2 deletions src/Form/Type/GeoDetectionCountriesCollectionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function configureOptions(OptionsResolver $resolver)
/**
* @return string
*/
public function getParent()
public function getParent(): ?string
{
return CollectionType::class;
}
Expand All @@ -52,7 +52,7 @@ public function getName()
/**
* {@inheritdoc}
*/
public function getBlockPrefix()
public function getBlockPrefix(): string
{
return self::NAME;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Form/Type/GeoDetectionCountriesSystemConfigType.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function configureOptions(OptionsResolver $resolver)
/**
* @return string
*/
public function getParent()
public function getParent(): ?string
{
return GeoDetectionCountriesCollectionType::class;
}
Expand All @@ -55,7 +55,7 @@ public function getName()
/**
* {@inheritdoc}
*/
public function getBlockPrefix()
public function getBlockPrefix(): string
{
return static::NAME;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Form/Type/GeoDetectionCountryType.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function configureOptions(OptionsResolver $resolver)
/**
* @return string
*/
public function getBlockPrefix()
public function getBlockPrefix(): string
{
return $this->getName();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Layout/Extension/GeoDetectionContextConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function __construct(
RedirectionConfigurationProvider $configurationProvider,
RequestStack $requestStack
) {

$this->reader = $reader;
$this->frontendHelper = $frontendHelper;
$this->redirectionConfigProvider = $configurationProvider;
Expand Down
3 changes: 1 addition & 2 deletions src/Providers/GeoDetectionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
namespace Aligent\GeoDetectionBundle\Providers;

use Doctrine\Common\Cache\CacheProvider;
use GeoIp2\Exception\AddressNotFoundException;
use GeoIp2\Database\Reader;
use Oro\Bundle\FrontendBundle\Request\FrontendHelper;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use GeoIp2\Database\Reader;

/**
* Class GeoDetectionProvider
Expand Down
5 changes: 2 additions & 3 deletions src/Providers/RedirectionConfigurationProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public function getSuggestedSite($currentCountry)
return $site;
}
}
return;
}

/**
Expand All @@ -74,7 +73,7 @@ public function getDefaultWebsite()
/**
* @return array
*/
public function getEnabledWebsites()
public function getEnabledWebsites(): array
{
return $this->enabledRedirects;
}
Expand All @@ -90,7 +89,7 @@ public function isEnabled()
/**
* @return bool
*/
public function hasRedirects()
public function hasRedirects(): bool
{
return count($this->enabledRedirects) > 0;
}
Expand Down
7 changes: 4 additions & 3 deletions src/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ services:

# Cache Provider
aligent_geo_detection.cache:
parent: oro.cache.abstract
calls:
- [ setNamespace, [ 'geo_ip' ] ]
# public: false
parent: oro.data.cache
tags:
- { name: 'cache.pool', namespace: 'geo_ip' }

# Blocks
aligent_geo_detection.layout.block_type.redirection_block:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* @license
* @link http://www.aligent.com.au/
*/

namespace Aligent\GeoDetectionBundle\Tests\Unit\DependencyInjection;

use Aligent\GeoDetectionBundle\DependencyInjection\AligentGeoDetectionExtension;
Expand Down
1 change: 1 addition & 0 deletions src/Tests/Unit/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* @license
* @link http://www.aligent.com.au/
*/

namespace Aligent\GeoDetectionBundle\Tests\Unit\DependencyInjection;

use Aligent\GeoDetectionBundle\DependencyInjection\Configuration;
Expand Down