Commit e380edf1 authored by bojanz's avatar bojanz

Initial cleanup of commerce_store (entity, form).

parent b98f6104
name: Commerce Store
type: module
description: 'Defines the Store entities.'
description: 'Defines the Store entity and associated features.'
package: Commerce
core: 8.x
dependencies:
......@@ -9,8 +9,5 @@ dependencies:
- entity_reference
config_devel:
- commerce_store.commerce_store_type.online
- core.entity_form_display.commerce_store.online.default
- field.storage.commerce_store.currencies
- commerce_store.settings
- field.field.commerce_store.online.currencies
- views.view.commerce_stores
\ No newline at end of file
- views.view.commerce_stores
......@@ -146,8 +146,8 @@ class Store extends ContentEntityBase implements StoreInterface {
/**
* {@inheritdoc}
*/
public function setDefaultCurrency($currency_code) {
$this->set('default_currency', $currency_code);
public function setDefaultCurrency($currencyCode) {
$this->set('default_currency', $currencyCode);
return $this;
}
......@@ -166,7 +166,7 @@ class Store extends ContentEntityBase implements StoreInterface {
->setReadOnly(TRUE);
$fields['uid'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Store owner'))
->setLabel(t('Owner'))
->setDescription(t('The user that owns this store.'))
->setDefaultValueCallback('Drupal\commerce_store\Entity\Store::getCurrentUserId')
->setSetting('target_type', 'user')
......@@ -183,12 +183,11 @@ class Store extends ContentEntityBase implements StoreInterface {
])
->setDisplayOptions('form', [
'type' => 'language_select',
'weight' => 2,
'weight' => -1,
]);
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Store name'))
->setDescription(t('The name of the store.'))
->setLabel(t('Name'))
->setRequired(TRUE)
->setTranslatable(TRUE)
->setSettings([
......@@ -198,7 +197,10 @@ class Store extends ContentEntityBase implements StoreInterface {
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -10,
]);
'weight' => 0,
])
->setDisplayConfigurable('view', TRUE)
->setDisplayConfigurable('form', TRUE);
$fields['type'] = BaseFieldDefinition::create('string')
->setLabel(t('Type'))
......@@ -207,27 +209,28 @@ class Store extends ContentEntityBase implements StoreInterface {
$fields['mail'] = BaseFieldDefinition::create('email')
->setLabel(t('E-mail address'))
->setDescription(t('A valid e-mail address. Store e-mail notifications will be sent to and from this address.'))
->setDescription(t('Store e-mail notifications will be sent to and from this address.'))
->setRequired(TRUE)
->setDisplayOptions('form', [
'type' => 'email_default',
'weight' => 0,
]);
'weight' => 1,
])
->setDisplayConfigurable('view', TRUE)
->setDisplayConfigurable('form', TRUE);
$fields['default_currency'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Default currency'))
->setDescription(t('The default currency of this store.'))
->setCardinality(1)
->setRequired(TRUE)
->setRevisionable(TRUE)
->setSetting('target_type', 'commerce_currency')
->setSetting('handler', 'default')
->setTranslatable(TRUE)
->setDisplayOptions('form', [
'type' => 'options_select',
'weight' => 10,
'settings' => [],
]);
'weight' => 2,
])
->setDisplayConfigurable('view', TRUE)
->setDisplayConfigurable('form', TRUE);
return $fields;
}
......
......@@ -53,7 +53,7 @@ class StoreForm extends ContentEntityForm {
'#title' => $this->t('Default'),
'#default_value' => $isDefault,
'#disabled' => $isDefault || empty($defaultStore),
'#weight' => 0,
'#weight' => 99,
];
return $form;
......
......@@ -16,7 +16,7 @@ use Drupal\user\EntityOwnerInterface;
interface StoreInterface extends EntityInterface, EntityOwnerInterface {
/**
* Return the name of the store.
* Gets the name of the store.
*
* @return string
* The content of the field.
......@@ -35,7 +35,7 @@ interface StoreInterface extends EntityInterface, EntityOwnerInterface {
public function setName($name);
/**
* Return the e-mail address of the store.
* Gets the e-mail address of the store.
*
* @return string
* The content of the field.
......@@ -54,7 +54,7 @@ interface StoreInterface extends EntityInterface, EntityOwnerInterface {
public function setEmail($mail);
/**
* Return the default currency for the store.
* Gets the default currency for the store.
*
* @return string
* The content of the field.
......@@ -70,6 +70,6 @@ interface StoreInterface extends EntityInterface, EntityOwnerInterface {
* @return \Drupal\commerce_store\StoreInterface
* The class instance that this method is called on.
*/
public function setDefaultCurrency($currency_code);
public function setDefaultCurrency($currencyCode);
}
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