Commit a71d71cd authored by bojanz's avatar bojanz

Sync the CommerceProductType create_body code with latest core.

parent 35f5b24d
......@@ -83,24 +83,6 @@ class ProductType extends ConfigEntityBundleBase implements ProductTypeInterface
*/
protected $digital;
/**
* Indicates whether a body field should be created for this product type.
*
* This property affects entity creation only. It allows default configuration
* of modules and installation profiles to specify whether a Body field should
* be created for this bundle.
*
* @var bool
*/
protected $createBody = TRUE;
/**
* The label to use for the body field upon entity creation.
*
* @var string
*/
protected $createBodyLabel = 'Body';
/**
* {@inheritdoc}
*/
......@@ -131,18 +113,4 @@ class ProductType extends ConfigEntityBundleBase implements ProductTypeInterface
return $this;
}
/**
* {@inheritdoc}
*/
public function postSave(EntityStorageInterface $storage, $update = TRUE) {
parent::postSave($storage, $update);
// Create a body if the create_body property is true and we're not in
// the syncing process.
if ($this->get('create_body') && !$this->isSyncing()) {
$label = $this->get('create_body_label');
commerce_product_add_body_field($this->id, $label);
}
}
}
......@@ -55,9 +55,13 @@ class ProductTypeForm extends EntityForm {
*/
public function save(array $form, FormStateInterface $form_state) {
try {
$this->entity->save();
$status = $this->entity->save();
drupal_set_message($this->t('The product type %product_type_label has been successfully saved.', ['%product_type_label' => $this->entity->label()]));
$form_state->setRedirect('entity.commerce_product_type.collection');
if ($status == SAVED_NEW) {
commerce_product_add_body_field($this->id);
}
}
catch (\Exception $e) {
drupal_set_message($this->t('The product type %product_type_label could not be saved.', ['%product_type_label' => $this->entity->label()]), 'error');
......
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