You are here

ProductAttributesForm.php in Ubercart 8.4

File

uc_attribute/src/Form/ProductAttributesForm.php
View source
<?php

namespace Drupal\uc_attribute\Form;

use Drupal\Core\Form\FormStateInterface;
use Drupal\node\NodeInterface;

/**
 * Defines the product attribute overview form.
 */
class ProductAttributesForm extends ObjectAttributesFormBase {

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state, NodeInterface $node = NULL) {
    $this->attributeTable = 'uc_product_attributes';
    $this->optionTable = 'uc_product_options';
    $this->idField = 'nid';
    $this->idValue = $node
      ->id();
    $this->attributes = uc_product_get_attributes($this->idValue);
    return parent::buildBaseForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  protected function attributesRemoved() {
    \Drupal::database()
      ->delete('uc_product_adjustments')
      ->condition('nid', $this->idValue)
      ->execute();
  }

}

Classes

Namesort descending Description
ProductAttributesForm Defines the product attribute overview form.