protected function TestController::createAttribute in Dropdown Attributes 8
Creates an attribute.
Parameters
array $data: Attribute data.
bool $save: TRUE if attribute should be saved.
3 calls to TestController::createAttribute()
- TestController::product in uc_dropdown_test/
src/ Controller/ TestController.php - TestController::productClass in uc_dropdown_test/
src/ Controller/ TestController.php - TestController::productKit in uc_dropdown_test/
src/ Controller/ TestController.php
File
- uc_dropdown_test/
src/ Controller/ TestController.php, line 638
Class
- TestController
- Additional test of Dropdown Attributes UI.
Namespace
Drupal\uc_dropdown_test\ControllerCode
protected function createAttribute(array $data = array(), $save = TRUE) {
$attribute = $data + array(
'name' => $this
->randGen(8),
'label' => $this
->randGen(8),
'description' => $this
->randGen(8),
'required' => mt_rand(0, 1) ? TRUE : FALSE,
'display' => mt_rand(0, 3),
'ordering' => mt_rand(-10, 10),
);
$attribute = (object) $attribute;
if ($save) {
uc_attribute_save($attribute);
}
return $attribute;
}