Currently, the use of Drupal\address\Repository\CountryRepository is hardcoded in the constructor of the CreateStoreCommand class.
This way, it's impossible to replace the CountryRepository with an own version of the service.
I replaced the CountryRepository with a my own version so it sorts sorts the countries in the list according to their usage on the site.
Works perfectly for the most part, but when I run drupal console, it crashes with:
TypeError: Argument 3 passed to Drupal\commerce_store\Command\CreateStoreCommand::__construct() must be an instance of Drupal\address\Repository\CountryRepository, instance of Drupal\mymodule\Repository\SortedCountryRepository given in modules/contrib/commerce/modules/store/src/Command/CreateStoreCommand.php on line 85
It should be sufficient to use
CommerceGuys\Addressing\Country\CountryRepositoryInterface
instead.
Comment | File | Size | Author |
---|---|---|---|
#8 | 2949406-8-country-interface.patch | 2.46 KB | alianov |
| |||
#6 | 2949406-6-country-interface.patch | 2.46 KB | alianov |
| |||
#4 | 2949406-4-country-interface.patch | 2.47 KB | alianov |
|
Comments
Comment #2
agoradesign CreditAttribution: agoradesign commentedIt's also implementing CommerceGuys\Intl\Country\CountryRepositoryInterface, which overlaps with the only function of the CommerceGuys\Addressing\Country\CountryRepositoryInterface, but has some additional functions, which are also used by the command... I guess that this was the reason, why the class was used. The author may have thought, that in doubt better to use the class, or so...
Comment #3
alianov CreditAttribution: alianov commentedComment #4
alianov CreditAttribution: alianov commentedComment #5
bojanz CreditAttribution: bojanz at Centarro commentedI see what agoradesign means now :(
Our plan is to move the intl Country code into addressing, but since that hasn't happened yet, we'll need to use the intl interface, not the addressing one.
Comment #6
alianov CreditAttribution: alianov commentedComment #7
bojanz CreditAttribution: bojanz at Centarro commentedThis is still the Addressing, not the intl one interface.
Should be $country_repository, not $address_country.
Comment #8
alianov CreditAttribution: alianov commentedComment #9
bojanz CreditAttribution: bojanz at Centarro commentedThis is the country repository, the previous description was correct. We don't inject interfaces, we just use them for typehints.
Fixed on commit. Thanks!
Comment #12
aestigarribia CreditAttribution: aestigarribia commentedUpdated version of address module (8.x-1.4) cause this issue again on commerce (8.x-2.6) when you run Drupal Console.
Comment #13
jungleSame here.
Comment #14
bojanz CreditAttribution: bojanz at Centarro commentedComment #15
bojanz CreditAttribution: bojanz at Centarro commentedResolving in #2975007: Update for Address 8.x-1.4.
Comment #16
mrhappymac CreditAttribution: mrhappymac commentedDrupal console version 1.8.0 not working following basic install "composer create-project drupalcommerce/project-base mystore --stability dev"
Comment #17
John.nie CreditAttribution: John.nie commentedI have saw the patch code on floor #8, my commerce version is 8.x-2.7, but it still reported this error when I do this code:
Comment #18
John.nie CreditAttribution: John.nie commentedComment #19
John.nie CreditAttribution: John.nie commentedI found it's error from this,
should not be @address.country_repository service name.
but none CommerceGuys\Intl\Country\CountryRepositoryInterface service, what can I do this?
Comment #20
John.nie CreditAttribution: John.nie commentedsee https://www.drupal.org/project/address/issues/2975584#comment-12630389