Commit 95394d7c authored by bcizej's avatar bcizej Committed by dww

Issue #3087843 by benjamincizej, dww: Fix code style bugs

parent 84ef4d89
......@@ -28,12 +28,12 @@ final class AddressEvents {
/**
* Name of the event fired when altering initial values.
*
* @deprecated No longer fired since 1.5. Use hook_field_widget_form_alter()
* to change the address #default_value instead.
* @deprecated in address:8.x-1.5 and is removed from address:8.x-2.0. Use
* hook_field_widget_form_alter() to change the address #default_value.
*
* @Event
*
* @see \Drupal\address\Event\InitialValuesEvent
* @see https://www.drupal.org/project/address/issues/2838457
*/
const INITIAL_VALUES = 'address.widget.initial_values';
......
......@@ -8,8 +8,10 @@ use Symfony\Component\EventDispatcher\Event;
/**
* Defines the initial values event.
*
* @deprecated No longer fired since 1.5. Use hook_field_widget_form_alter()
* to change the address #default_value instead.
* @deprecated in address:8.x-1.5 and is removed from address:8.x-2.0. Use
* hook_field_widget_form_alter() to change the address #default_value.
*
* @see https://www.drupal.org/project/address/issues/2838457
*/
class InitialValuesEvent extends Event {
......
......@@ -201,7 +201,11 @@ class ZoneDefaultFormatter extends FormatterBase implements ContainerFactoryPlug
];
}
if ($dependent_locality = $territory->getDependentLocality()) {
$dependent_localities = $this->subdivisionRepository->getList([$country_code, $administrative_area, $locality]);
$dependent_localities = $this->subdivisionRepository->getList([
$country_code,
$administrative_area,
$locality,
]);
$dependent_locality_name = $dependent_locality;
if (isset($dependent_localities[$dependent_locality])) {
$dependent_locality_name = $dependent_localities[$dependent_locality];
......
......@@ -15,8 +15,25 @@ use CommerceGuys\Addressing\Validator\Constraints\AddressFormatConstraint as Ext
*/
class AddressFormatConstraint extends ExternalAddressFormatConstraint {
/**
* Validation message if a field must be blank.
*
* @var string
*/
public $blankMessage = '@name field must be blank.';
/**
* Validation message if a field is required.
*
* @var string
*/
public $notBlankMessage = '@name field is required.';
/**
* Validation message if a field has an invalid format.
*
* @var string
*/
public $invalidMessage = '@name field is not in the right format.';
}
......@@ -14,8 +14,25 @@ use Symfony\Component\Validator\Constraint;
*/
class CountryConstraint extends Constraint {
/**
* List of available countries.
*
* @var string[]
*/
public $availableCountries = [];
/**
* Validation message if a country is invalid.
*
* @var string
*/
public $invalidMessage = 'The country %value is not valid.';
/**
* Validation message if a country is not available.
*
* @var string
*/
public $notAvailableMessage = 'The country %value is not available.';
}
......@@ -2,13 +2,15 @@
namespace Drupal\address\Plugin\migrate\cckfield;
@trigger_error('AddressField is deprecated in Address 1.3 and will be be removed before Address 2.x. Use \Drupal\address\Plugin\migrate\field\AddressField instead.', E_USER_DEPRECATED);
@trigger_error('AddressField is deprecated in address:8.x-1.3 and is removed from address:8.x-2.0. Use \Drupal\address\Plugin\migrate\field\AddressField instead. See https://www.drupal.org/project/address/issues/2912087', E_USER_DEPRECATED);
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\address\Plugin\migrate\field\AddressField as BaseAddressField;
use Drupal\migrate_drupal\Plugin\MigrateCckFieldInterface;
/**
* Cck migration field.
*
* @MigrateCckField(
* id = "addressfield",
* core = {7},
......@@ -19,8 +21,10 @@ use Drupal\migrate_drupal\Plugin\MigrateCckFieldInterface;
* destination_module = "address"
* )
*
* @deprecated in 1.3, to be removed before 2.x. Use
* @deprecated in address:8.x-1.3 and is removed from address:8.x-2.0. Use
* \Drupal\address\Plugin\migrate\field\AddressField instead.
*
* @see https://www.drupal.org/project/address/issues/2912087
*/
class AddressField extends BaseAddressField implements MigrateCckFieldInterface {
......
......@@ -6,6 +6,8 @@ use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase;
/**
* Field migration plugin from D7 to D8.
*
* @MigrateField(
* id = "addressfield",
* core = {7},
......
......@@ -9,6 +9,8 @@ namespace Drupal\address\Plugin\views\field;
*
* @ViewsField("country_code")
*
* @deprecated in 1.5, to be removed before 2.x. Use the Country plugin instead.
* @deprecated in address:8.x-1.5 and is removed from address:8.x-2.0. Use the Country plugin instead.
*
* @see https://www.drupal.org/project/address/issues/3034122
*/
class CountryCode extends Country {}
......@@ -101,7 +101,8 @@ abstract class CountryAwareInOperatorBase extends InOperator {
* The field name, defaults to the current field name for this filter.
*
* @return array
* An array of available country codes, including the full list when unrestricted.
* An array of available country codes, including the full list when
* unrestricted.
*/
protected function getAvailableCountries(EntityTypeInterface $entity_type = NULL, $field_name = NULL) {
if (!isset($entity_type)) {
......
......@@ -9,6 +9,8 @@ namespace Drupal\address\Plugin\views\filter;
*
* @ViewsFilter("country_code")
*
* @deprecated in 1.5, to be removed before 2.x. Use the Country plugin instead.
* @deprecated in address:8.x-1.5 and is removed from address:8.x-2.0. Use the Country plugin instead.
*
* @see https://www.drupal.org/project/address/issues/3034122
*/
class CountryCode extends Country {}
......@@ -6,6 +6,11 @@ use Drupal\address\Event\AddressEvents;
use Drupal\address\Event\AvailableCountriesEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Subscribes to Address events for testing.
*
* @see \Drupal\Tests\address\FunctionalJavascript\AddressDefaultWidgetTest::testEvents()
*/
class AddressTestEventSubscriber implements EventSubscriberInterface {
/**
......@@ -33,7 +38,13 @@ class AddressTestEventSubscriber implements EventSubscriberInterface {
* The countries.
*/
public function getAvailableCountries() {
return ['AU' => 'AU', 'BR' => 'BR', 'CA' => 'CA', 'GB' => 'GB', 'US' => 'US'];
return [
'AU' => 'AU',
'BR' => 'BR',
'CA' => 'CA',
'GB' => 'GB',
'US' => 'US',
];
}
}
......@@ -93,7 +93,7 @@ class DefaultValueTestForm extends FormBase {
$payment_method = $values['payment_method'];
$address = $values[$payment_method]['address'];
$this->messenger()->addMessage(t('The street is "@street" and the country code is @country_code.', [
$this->messenger()->addMessage($this->t('The street is "@street" and the country code is @country_code.', [
'@street' => $address['address_line1'],
'@country_code' => $address['country_code'],
]));
......
......@@ -42,7 +42,7 @@ class ZoneTerritoryTestForm extends FormBase {
$values = $form_state->getValues();
$territory = new ZoneTerritory($values['territory']);
$this->messenger()->addMessage(t('Submitted: @country_code / @administrative_area / @included_postal_codes / @excluded_postal_codes.', [
$this->messenger()->addMessage($this->t('Submitted: @country_code / @administrative_area / @included_postal_codes / @excluded_postal_codes.', [
'@country_code' => $territory->getCountryCode(),
'@administrative_area' => $territory->getAdministrativeArea(),
'@included_postal_codes' => $territory->getIncludedPostalCodes(),
......
......@@ -431,7 +431,11 @@ class AddressDefaultWidgetTest extends WebDriverTestBase {
$locality = 'Chengde Shi';
$administrative_areas = $this->subdivisionRepository->getList([$country]);
$localities = $this->subdivisionRepository->getList([$country, $administrative_area]);
$dependent_localities = $this->subdivisionRepository->getList([$country, $administrative_area, $locality]);
$dependent_localities = $this->subdivisionRepository->getList([
$country,
$administrative_area,
$locality,
]);
// Confirm the presence and format of the administrative area dropdown.
$this->drupalGet($this->nodeAddUrl);
$this->getSession()->getPage()->fillField($field_name . '[0][address][country_code]', $country);
......
......@@ -193,7 +193,7 @@ class CountryNameTokenTest extends KernelTestBase {
* Tests [entity:country_name] tokens.
*/
public function testEntityCountryNameTokens() {
// Create a node with a value in its fields and test its country_name tokens.
// Create a node with address fields and test its country_name tokens.
$entity = Node::create([
'title' => 'Test node title',
'type' => 'article',
......
......@@ -14,7 +14,7 @@ use Drupal\KernelTests\KernelTestBase;
abstract class FormatterTestBase extends KernelTestBase {
/**
* @var array
* {@inheritdoc}
*/
public static $modules = [
'system',
......
......@@ -16,7 +16,7 @@ use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
class ZoneItemTest extends EntityKernelTestBase {
/**
* @var array
* {@inheritdoc}
*/
public static $modules = [
'address',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment