Skip to content
Snippets Groups Projects
Commit 212652a3 authored by yas's avatar yas
Browse files

Converted the array syntax from array(...) to [...]

parent 0cea8eb8
No related branches found
No related tags found
No related merge requests found
Showing
with 253 additions and 253 deletions
......@@ -19,7 +19,7 @@
* An array contain all the required information. The cloud_context is passed
* as one of the array elements.
*/
function hook_cloud_action($op, $params = array()) {
function hook_cloud_action($op, $params = []) {
switch ($op) {
case 'launch':
break;
......@@ -74,7 +74,7 @@ function hook_cloud_action($op, $params = array()) {
* @param array $filter
* An array of filters passed from the UI
*/
function hook_cloud_get_all_instances($cloud_context, $filter = array()) {
function hook_cloud_get_all_instances($cloud_context, $filter = []) {
// Return your instance information from the database.
}
......@@ -86,7 +86,7 @@ function hook_cloud_get_all_instances($cloud_context, $filter = array()) {
* @param array $filter
* An array of filters passed from the UI
*/
function hook_cloud_get_instance($cloud_context, $filter = array()) {
function hook_cloud_get_instance($cloud_context, $filter = []) {
// Return your sub-cloud information.
}
......@@ -125,23 +125,23 @@ function hook_cloud_update_data($cloud_context) {
* the different sub-clouds.
*/
function hook_cloud_set_info($cloud_context = '') {
return array(
return [
'cloud_display_name' => DISPLAY_NAME,
'cloud_name' => CONTEXT,
'module' => 'xcp',
'base_cloud' => 'xcp',
'instance_types' => array(
'instance_types' => [
XCP_DEFAULT_INSTANCE_TYPE => XCP_DEFAULT_INSTANCE_TYPE,
),
'cloud_pricing_data' => array(
XCP_DEFAULT_INSTANCE_TYPE => array(
],
'cloud_pricing_data' => [
XCP_DEFAULT_INSTANCE_TYPE => [
'instance_type' => XCP_DEFAULT_INSTANCE_TYPE,
'description' => t('Default'),
'linux_or_unix_cost' => '0.085',
'windows_cost' => '0.089',
),
),
);
],
],
];
}
/***** New hooks added to cloud module******/
......
......@@ -19,13 +19,13 @@ class CloudAlertListController extends CloudContentListBuilder {
*/
public function buildHeader() {
$header = array(
$header = [
// The header gives the table the information it needs in order to make
// the query calls for ordering. TableSort uses the field information
// to know what database column to sort by.
array('data' => t('Name'), 'specifier' => 'name', 'sort' => 'ASC'),
array('data' => t('Description'), 'specifier' => 'description'),
);
['data' => t('Name'), 'specifier' => 'name', 'sort' => 'ASC'],
['data' => t('Description'), 'specifier' => 'description'],
];
return $header + parent::buildHeader();
}
......@@ -41,9 +41,9 @@ class CloudAlertListController extends CloudContentListBuilder {
$row['name'] = \Drupal::l(
$this->getLabel($entity),
new Url(
'entity.cloud_alert.canonical', array(
'entity.cloud_alert.canonical', [
'cloud_alert' => $entity->id(),
)
]
)
);
$row['description'] = $entity->description();
......
......@@ -55,9 +55,9 @@ class CloudAlert extends ContentEntityBase implements CloudAlertInterface {
*/
public static function preCreate(EntityStorageInterface $storage_controller, array &$values) {
parent::preCreate($storage_controller, $values);
$values += array(
$values += [
'user_id' => \Drupal::currentUser()->id(),
);
];
}
/**
......@@ -141,37 +141,37 @@ class CloudAlert extends ContentEntityBase implements CloudAlertInterface {
->setSetting('handler', 'default')
->setDefaultValueCallback('Drupal\node\Entity\Node::getCurrentUserId')
->setTranslatable(TRUE)
->setDisplayOptions('view', array(
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'author',
'weight' => 0,
))
->setDisplayOptions('form', array(
])
->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
'weight' => 5,
'settings' => array(
'settings' => [
'match_operator' => 'CONTAINS',
'size' => '60',
'autocomplete_type' => 'tags',
'placeholder' => '',
),
))
],
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name'))
->setDescription(t('The name of the cloud alert entity.'))
->setSettings(array(
->setSettings([
'default_value' => '',
'max_length' => 255,
'text_processing' => 0,
))
->setDisplayOptions('view', array(
])
->setDisplayOptions('view', [
'label' => 'above',
'type' => 'string',
'weight' => -5,
))
])
/*
->setDisplayOptions('form', array(
'type' => 'string_textfield',
......
......@@ -16,11 +16,11 @@ class CloudAlertViewsData extends EntityViewsData implements EntityViewsDataInte
public function getViewsData() {
$data = parent::getViewsData();
$data['cloud_alert']['table']['base'] = array(
$data['cloud_alert']['table']['base'] = [
'field' => 'id',
'title' => t('Cloud Alert'),
'help' => t('The cloud_alert entity ID.'),
);
];
return $data;
}
......
......@@ -24,7 +24,7 @@ class CloudAlertEditForm extends CloudContentForm {
$entity = $this->entity;
$form['name'] = array(
$form['name'] = [
'#type' => 'textfield',
'#title' => $this->t('Name'),
'#maxlength' => 255,
......@@ -32,9 +32,9 @@ class CloudAlertEditForm extends CloudContentForm {
'#default_value' => $entity->label(),
'#required' => TRUE,
'#weight' => -5,
);
];
$form['description'] = array(
$form['description'] = [
'#type' => 'textarea',
'#title' => $this->t('Description'),
'#cols' => 60,
......@@ -42,14 +42,14 @@ class CloudAlertEditForm extends CloudContentForm {
'#default_value' => $entity->description(),
'#weight' => -5,
'#required' => FALSE,
);
];
$form['langcode'] = array(
$form['langcode'] = [
'#title' => t('Language'),
'#type' => 'language_select',
'#default_value' => $entity->getUntranslated()->language()->getId(),
'#languages' => Language::STATE_ALL,
);
];
$form['actions'] = $this->actions($form, $form_state);
......
......@@ -25,9 +25,9 @@ class CloudAlertTest extends WebTestBase {
*
* @var array
*/
public static $modules = array('cloud',
public static $modules = ['cloud',
'cloud_alert',
);
];
/**
* The profile to install as a basis for testing.
......@@ -42,13 +42,13 @@ class CloudAlertTest extends WebTestBase {
protected function setUp() {
parent::setUp();
$web_user = $this->drupalCreateUser(array(
$web_user = $this->drupalCreateUser([
'add cloud alert',
'list cloud alert',
'view cloud alert',
'edit cloud alert',
'delete cloud alert',
));
]);
$this->drupalLogin($web_user);
}
......@@ -77,33 +77,33 @@ class CloudAlertTest extends WebTestBase {
$this->drupalPostForm("/clouds/design/cloud_alert/add",
$add[$i],
t('Save'));
$this->assertResponse(200, t('HTTP 200: Add | A New Cloud Alert Form #@num', array('@num' => $num)));
$this->assertResponse(200, t('HTTP 200: Add | A New Cloud Alert Form #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('Warning'), t('Make sure w/o Warnings'));
$this->assertText(t('The Cloud Alert entity "@name" has been saved.', array(
$this->assertText(t('The Cloud Alert entity "@name" has been saved.', [
'@name' => $add[$i]['name'],
)),
]),
t('Confirm Message') . ': '
. t('The Cloud Alert entity "@name" has been saved.', array(
. t('The Cloud Alert entity "@name" has been saved.', [
'@name' => $add[$i]['name'],
))
])
);
$this->assertText($add[$i]['name'],
t('Name: @name ', array(
t('Name: @name ', [
'@name' => $add[$i]['name'],
)));
]));
// Make sure listing.
$this->drupalGet("/clouds/design/cloud_alert");
$this->assertResponse(200, t('HTTP 200: List | Cloud Alert #@num', array('@num' => $num)));
$this->assertResponse(200, t('HTTP 200: List | Cloud Alert #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
for ($j = 0; $j < $i + 1; $j++) {
$this->assertText($add[$j]['name'],
t("Make sure w/ Listing @num: @name", array(
t("Make sure w/ Listing @num: @name", [
'@num' => $j + 1,
'@name' => $add[$j]['name'],
)));
]));
}
}
......@@ -117,32 +117,32 @@ class CloudAlertTest extends WebTestBase {
$this->drupalPostForm("/clouds/design/cloud_alert/$num/edit",
$edit[$i],
t('Save'));
$this->assertResponse(200, t('HTTP 200: Edit | A New Cloud Alert Form #@num', array('@num' => $num)));
$this->assertResponse(200, t('HTTP 200: Edit | A New Cloud Alert Form #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
$this->assertText(t('The Cloud Alert entity "@name" has been saved.', array(
$this->assertText(t('The Cloud Alert entity "@name" has been saved.', [
'@name' => $edit[$i]['name'],
)),
]),
t('Confirm Message') . ': '
. t('The Cloud Alert entity "@name" has been saved.', array(
. t('The Cloud Alert entity "@name" has been saved.', [
'@name' => $edit[$i]['name'],
))
])
);
$this->assertText($edit[$i]['name'], t('Name: @name ', array(
$this->assertText($edit[$i]['name'], t('Name: @name ', [
'@name' => $edit[$i]['name'],
)));
]));
// Make sure listing.
$this->drupalGet("/clouds/design/cloud_alert");
$this->assertResponse(200, t('HTTP 200: List | Cloud Alert #@num', array('@num' => $num)));
$this->assertResponse(200, t('HTTP 200: List | Cloud Alert #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
for ($j = 0; $j < $i + 1; $j++) {
$this->assertText($edit[$j]['name'],
t("Make sure w/ Listing @num: @name", array(
t("Make sure w/ Listing @num: @name", [
'@num' => $j + 1,
'@name' => $edit[$j]['name'],
)));
]));
}
}
......@@ -153,23 +153,23 @@ class CloudAlertTest extends WebTestBase {
$this->drupalGet("/clouds/design/cloud_alert/$num/delete");
$this->drupalPostForm("/clouds/design/cloud_alert/$num/delete",
array(),
[],
t('Delete'));
$this->assertResponse(200, t('HTTP 200: Delete | Cloud Alert #@num', array('@num' => $num)));
$this->assertResponse(200, t('HTTP 200: Delete | Cloud Alert #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
// Make sure listing.
$this->drupalGet("/clouds/design/cloud_alert");
$this->assertResponse(200, t('HTTP 200: Delete | Cloud Alert #@num', array('@num' => $num)));
$this->assertResponse(200, t('HTTP 200: Delete | Cloud Alert #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
for ($j = 0; $j < $i + 1; $j++) {
$this->assertNoText($edit[$j]['name'],
t("Make sure w/ Listing @num: @name", array(
t("Make sure w/ Listing @num: @name", [
'@num' => $j + 1,
'@name' => $edit[$j]['name'],
)));
]));
}
}
......@@ -207,13 +207,13 @@ class CloudAlertTest extends WebTestBase {
$num = $i + 1;
// Input Fields.
$data[] = array(
$data[] = [
// 'cloud_context' => $cloud_context ,.
'name' => "Cloud Alert #$num - " . date('Y/m/d - ') . $random->name(16, TRUE),
'description' => "#$num: " . date('Y/m/d H:i:s - D M j G:i:s T Y')
. ' - SimpleTest Cloud Alert Description - '
. $random->string(32, TRUE),
);
];
}
return $data;
......
......@@ -19,13 +19,13 @@ class CloudClusterListController extends CloudContentListBuilder {
*/
public function buildHeader() {
$header = array(
$header = [
// The header gives the table the information it needs in order to make
// the query calls for ordering. TableSort uses the field information
// to know what database column to sort by.
array('data' => t('Name'), 'specifier' => 'name', 'sort' => 'ASC'),
array('data' => t('Description'), 'specifier' => 'description'),
);
['data' => t('Name'), 'specifier' => 'name', 'sort' => 'ASC'],
['data' => t('Description'), 'specifier' => 'description'],
];
return $header + parent::buildHeader();
}
......@@ -41,9 +41,9 @@ class CloudClusterListController extends CloudContentListBuilder {
$row['name'] = \Drupal::l(
$this->getLabel($entity),
new Url(
'entity.cloud_cluster.canonical', array(
'entity.cloud_cluster.canonical', [
'cloud_cluster' => $entity->id(),
)
]
)
);
$row['description'] = $entity->description();
......
......@@ -55,9 +55,9 @@ class CloudCluster extends ContentEntityBase implements CloudClusterInterface {
*/
public static function preCreate(EntityStorageInterface $storage_controller, array &$values) {
parent::preCreate($storage_controller, $values);
$values += array(
$values += [
'user_id' => \Drupal::currentUser()->id(),
);
];
}
/**
......@@ -141,37 +141,37 @@ class CloudCluster extends ContentEntityBase implements CloudClusterInterface {
->setSetting('handler', 'default')
->setDefaultValueCallback('Drupal\node\Entity\Node::getCurrentUserId')
->setTranslatable(TRUE)
->setDisplayOptions('view', array(
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'author',
'weight' => 0,
))
->setDisplayOptions('form', array(
])
->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
'weight' => 5,
'settings' => array(
'settings' => [
'match_operator' => 'CONTAINS',
'size' => '60',
'autocomplete_type' => 'tags',
'placeholder' => '',
),
))
],
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name'))
->setDescription(t('The name of the cloud cluster entity.'))
->setSettings(array(
->setSettings([
'default_value' => '',
'max_length' => 255,
'text_processing' => 0,
))
->setDisplayOptions('view', array(
])
->setDisplayOptions('view', [
'label' => 'above',
'type' => 'string',
'weight' => -5,
))
])
/*
->setDisplayOptions('form', array(
'type' => 'string_textfield',
......
......@@ -17,11 +17,11 @@ class CloudClusterViewsData extends EntityViewsData implements EntityViewsDataIn
public function getViewsData() {
$data = parent::getViewsData();
$data['cloud_cluster']['table']['base'] = array(
$data['cloud_cluster']['table']['base'] = [
'field' => 'id',
'title' => t('Cloud Cluster'),
'help' => t('The cloud_cluster entity ID.'),
);
];
return $data;
}
......
......@@ -24,7 +24,7 @@ class CloudClusterEditForm extends CloudContentForm {
$entity = $this->entity;
$form['name'] = array(
$form['name'] = [
'#type' => 'textfield',
'#title' => $this->t('Name'),
'#maxlength' => 255,
......@@ -32,9 +32,9 @@ class CloudClusterEditForm extends CloudContentForm {
'#default_value' => $entity->label(),
'#required' => TRUE,
'#weight' => -5,
);
];
$form['description'] = array(
$form['description'] = [
'#type' => 'textarea',
'#title' => $this->t('Description'),
'#cols' => 60,
......@@ -42,14 +42,14 @@ class CloudClusterEditForm extends CloudContentForm {
'#default_value' => $entity->description(),
'#weight' => -5,
'#required' => FALSE,
);
];
$form['langcode'] = array(
$form['langcode'] = [
'#title' => t('Language'),
'#type' => 'language_select',
'#default_value' => $entity->getUntranslated()->language()->getId(),
'#languages' => Language::STATE_ALL,
);
];
$form['actions'] = $this->actions($form, $form_state);
......
......@@ -25,9 +25,9 @@ class CloudClusterTest extends WebTestBase {
*
* @var array
*/
public static $modules = array('cloud',
public static $modules = ['cloud',
'cloud_cluster',
);
];
/**
* The profile to install as a basis for testing.
......@@ -42,13 +42,13 @@ class CloudClusterTest extends WebTestBase {
protected function setUp() {
parent::setUp();
$web_user = $this->drupalCreateUser(array(
$web_user = $this->drupalCreateUser([
'add cloud cluster',
'list cloud cluster',
'view cloud cluster',
'edit cloud cluster',
'delete cloud cluster',
));
]);
$this->drupalLogin($web_user);
}
......@@ -77,33 +77,33 @@ class CloudClusterTest extends WebTestBase {
$this->drupalPostForm("/clouds/design/cloud_cluster/add",
$add[$i],
t('Save'));
$this->assertResponse(200, t('HTTP 200: Add | A New Cloud Cluster Form #@num', array('@num' => $num)));
$this->assertResponse(200, t('HTTP 200: Add | A New Cloud Cluster Form #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('Warning'), t('Make sure w/o Warnings'));
$this->assertText(t('The Cloud Cluster entity "@name" has been saved.', array(
$this->assertText(t('The Cloud Cluster entity "@name" has been saved.', [
'@name' => $add[$i]['name'],
)),
]),
t('Confirm Message') . ': '
. t('The Cloud Cluster entity "@name" has been saved.', array(
. t('The Cloud Cluster entity "@name" has been saved.', [
'@name' => $add[$i]['name'],
))
])
);
$this->assertText($add[$i]['name'],
t('Name: @name ', array(
t('Name: @name ', [
'@name' => $add[$i]['name'],
)));
]));
// Make sure listing.
$this->drupalGet("/clouds/design/cloud_cluster");
$this->assertResponse(200, t('HTTP 200: List | Cloud Cluster #@num', array('@num' => $num)));
$this->assertResponse(200, t('HTTP 200: List | Cloud Cluster #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
for ($j = 0; $j < $i + 1; $j++) {
$this->assertText($add[$j]['name'],
t("Make sure w/ Listing @num: @name", array(
t("Make sure w/ Listing @num: @name", [
'@num' => $j + 1,
'@name' => $add[$j]['name'],
)));
]));
}
}
......@@ -117,32 +117,32 @@ class CloudClusterTest extends WebTestBase {
$this->drupalPostForm("/clouds/design/cloud_cluster/$num/edit",
$edit[$i],
t('Save'));
$this->assertResponse(200, t('HTTP 200: Edit | A New Cloud Cluster Form #@num', array('@num' => $num)));
$this->assertResponse(200, t('HTTP 200: Edit | A New Cloud Cluster Form #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
$this->assertText(t('The Cloud Cluster entity "@name" has been saved.', array(
$this->assertText(t('The Cloud Cluster entity "@name" has been saved.', [
'@name' => $edit[$i]['name'],
)),
]),
t('Confirm Message') . ': '
. t('The Cloud Cluster entity "@name" has been saved.', array(
. t('The Cloud Cluster entity "@name" has been saved.', [
'@name' => $edit[$i]['name'],
))
])
);
$this->assertText($edit[$i]['name'], t('Name: @name ', array(
$this->assertText($edit[$i]['name'], t('Name: @name ', [
'@name' => $edit[$i]['name'],
)));
]));
// Make sure listing.
$this->drupalGet("/clouds/design/cloud_cluster");
$this->assertResponse(200, t('HTTP 200: List | Cloud Cluster #@num', array('@num' => $num)));
$this->assertResponse(200, t('HTTP 200: List | Cloud Cluster #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
for ($j = 0; $j < $i + 1; $j++) {
$this->assertText($edit[$j]['name'],
t("Make sure w/ Listing @num: @name", array(
t("Make sure w/ Listing @num: @name", [
'@num' => $j + 1,
'@name' => $edit[$j]['name'],
)));
]));
}
}
......@@ -153,23 +153,23 @@ class CloudClusterTest extends WebTestBase {
$this->drupalGet("/clouds/design/cloud_cluster/$num/delete");
$this->drupalPostForm("/clouds/design/cloud_cluster/$num/delete",
array(),
[],
t('Delete'));
$this->assertResponse(200, t('HTTP 200: Delete | Cloud Cluster #@num', array('@num' => $num)));
$this->assertResponse(200, t('HTTP 200: Delete | Cloud Cluster #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
// Make sure listing.
$this->drupalGet("/clouds/design/cloud_cluster");
$this->assertResponse(200, t('HTTP 200: Delete | Cloud Cluster #@num', array('@num' => $num)));
$this->assertResponse(200, t('HTTP 200: Delete | Cloud Cluster #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
for ($j = 0; $j < $i + 1; $j++) {
$this->assertNoText($edit[$j]['name'],
t("Make sure w/ Listing @num: @name", array(
t("Make sure w/ Listing @num: @name", [
'@num' => $j + 1,
'@name' => $edit[$j]['name'],
)));
]));
}
}
......@@ -207,13 +207,13 @@ class CloudClusterTest extends WebTestBase {
$num = $i + 1;
// Input Fields.
$data[] = array(
$data[] = [
// 'cloud_context' => $cloud_context ,.
'name' => "Cloud Cluster #$num - " . date('Y/m/d - ') . $random->name(16, TRUE),
'description' => "#$num: " . date('Y/m/d H:i:s - D M j G:i:s T Y')
. ' - SimpleTest Cloud Cluster Description - '
. $random->string(32, TRUE),
);
];
}
return $data;
......
......@@ -19,17 +19,17 @@ class CloudPricingListBuilder extends CloudConfigListBuilder {
*/
public function buildHeader() {
$header = array(
$header = [
// The header gives the table the information it needs in order to make
// the query calls for ordering. TableSort uses the field information
// to know what database column to sort by.
array('data' => t('Instance Type'), 'specifier' => 'instance_type'),
array('data' => t('Description'), 'specifier' => 'description'),
array('data' => t('Linux Usage'), 'specifier' => 'linux_usage', 'sort' => 'ASC'),
array('data' => t('Windows Usage'), 'specifier' => 'windows_usage'),
array('data' => t('Date Created'), 'specifier' => 'created'),
array('data' => t('Date Updated'), 'specifier' => 'changed'),
);
['data' => t('Instance Type'), 'specifier' => 'instance_type'],
['data' => t('Description'), 'specifier' => 'description'],
['data' => t('Linux Usage'), 'specifier' => 'linux_usage', 'sort' => 'ASC'],
['data' => t('Windows Usage'), 'specifier' => 'windows_usage'],
['data' => t('Date Created'), 'specifier' => 'created'],
['data' => t('Date Updated'), 'specifier' => 'changed'],
];
return $header + parent::buildHeader();
}
......@@ -45,11 +45,11 @@ class CloudPricingListBuilder extends CloudConfigListBuilder {
$row['instance_type'] = \Drupal::l(
$entity->instance_type(),
new Url(
'entity.cloud_pricing.edit_form', array(
'entity.cloud_pricing.edit_form', [
'cloud_pricing' => $entity->id(),
// Need to add.
'cloud_context' => $entity->cloud_context(),
)
]
)
);
$row['description'] = $entity->description();
......
......@@ -18,9 +18,9 @@ class CloudPricingDeleteForm extends EntityConfirmFormBase {
*/
public function getQuestion() {
$entity = $this->entity;
return $this->t('Are you sure you want to delete %instance_type?', array(
return $this->t('Are you sure you want to delete %instance_type?', [
'%instance_type' => $entity->instance_type(),
));
]);
}
/**
......
......@@ -35,7 +35,7 @@ class CloudPricingEditForm extends CloudConfigForm {
// Get a parameter from the path.
$cloud_context = \Drupal::routeMatch()->getParameter('cloud_context');
$form['cloud_context'] = array(
$form['cloud_context'] = [
'#type' => 'textfield',
'#title' => $this->t('Cloud ID'),
'#maxlength' => 255,
......@@ -46,9 +46,9 @@ class CloudPricingEditForm extends CloudConfigForm {
: $entity->cloud_context(),
'#required' => TRUE,
'#disabled' => TRUE,
);
];
$form['instance_type'] = array(
$form['instance_type'] = [
'#type' => 'textfield',
'#title' => $this->t('Instance Type'),
'#type' => 'textfield',
......@@ -56,32 +56,32 @@ class CloudPricingEditForm extends CloudConfigForm {
'#default_value' => $entity->instance_type(),
'#required' => TRUE,
'#disabled' => !$entity->isNew(),
);
];
$form['description'] = array(
$form['description'] = [
'#type' => 'textarea',
'#title' => $this->t('Description'),
'#cols' => 60,
'#rows' => 3,
'#default_value' => $entity->description(),
'#required' => TRUE,
);
];
$form['linux_usage'] = array(
$form['linux_usage'] = [
'#type' => 'textfield',
'#title' => $this->t('Linux Usage Charge per Hour ($)'),
'#maxlength' => 20,
'#default_value' => $entity->linux_usage(),
'#required' => TRUE,
);
];
$form['windows_usage'] = array(
$form['windows_usage'] = [
'#type' => 'textfield',
'#title' => $this->t('Windows Usage Charge per Hour ($)'),
'#maxlength' => 20,
'#default_value' => $entity->windows_usage(),
'#required' => TRUE,
);
];
return $form;
}
......@@ -97,9 +97,9 @@ class CloudPricingEditForm extends CloudConfigForm {
// Check if ID exists.
if (($entity->isNew() && $this->exist($cloud_context))) {
$form_state->setError($form, $this->t('The %instance_type already exists.', array(
$form_state->setError($form, $this->t('The %instance_type already exists.', [
'%instance_type' => $entity->instance_type(),
)));
]));
}
if (!preg_match(CLOUD_PRICING_VALID_NUMBER, trim($entity->linux_usage()))) {
$form_state->setError($form, $this->t('Please enter valid usage for Linux'));
......@@ -146,17 +146,17 @@ class CloudPricingEditForm extends CloudConfigForm {
// TRUE or FALSE
if ($entity->save()) {
drupal_set_message(
$this->t('%instance_type pricing information has been saved.', array(
$this->t('%instance_type pricing information has been saved.', [
'%instance_type' => $instance_type,
)));
]));
}
else {
// @FIXME:
// $redirect = 'edit-form';
$form_state->setError(
$form, $this->t('The %instance_type pricing information was not saved.', array(
$form, $this->t('The %instance_type pricing information was not saved.', [
'%instance_type' => $instance_type,
)));
]));
}
$form_state
......
......@@ -26,9 +26,9 @@ class CloudPricingTest extends WebTestBase {
*
* @var array
*/
public static $modules = array('cloud',
public static $modules = ['cloud',
'cloud_pricing',
);
];
/**
* The profile to install as a basis for testing.
......@@ -43,13 +43,13 @@ class CloudPricingTest extends WebTestBase {
protected function setUp() {
parent::setUp();
$web_user = $this->drupalCreateUser(array(
$web_user = $this->drupalCreateUser([
'add cloud pricing',
'list cloud pricing',
'view cloud pricing',
'edit cloud pricing',
'delete cloud pricing',
));
]);
$this->drupalLogin($web_user);
}
......@@ -81,7 +81,7 @@ class CloudPricingTest extends WebTestBase {
$this->drupalPostForm("/admin/config/cloud/$cloud_context/pricing/add",
$add[$i],
t('Save'));
$this->assertResponse(200, t('HTTP 200: Add | A New CloudPricing Form #@num', array('@num' => $num)));
$this->assertResponse(200, t('HTTP 200: Add | A New CloudPricing Form #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('Warning'), t('Make sure w/o Warnings'));
$this->assertText($instance_type[$i] . ' ' . t('pricing information has been saved.'),
......@@ -89,35 +89,35 @@ class CloudPricingTest extends WebTestBase {
. $instance_type[$i] . ' ' . t('pricing information has been saved.'));
$this->assertText($instance_type[$i],
t('Instance Type: @instance_type', array(
t('Instance Type: @instance_type', [
'@instance_type' => $instance_type[$i],
)));
]));
$this->assertText(number_format($add[$i]['linux_usage'], 3),
t('Linux Usage: @linux_usage', array(
t('Linux Usage: @linux_usage', [
'@linux_usage' => $add[$i]['linux_usage'],
)));
]));
$this->assertText(number_format($add[$i]['windows_usage'], 3),
t('Windows Usage: @windows_usage', array(
t('Windows Usage: @windows_usage', [
'@windows_usage' => $add[$i]['windows_usage'],
)));
]));
// Make sure listing.
$this->drupalGet("/admin/config/cloud/$cloud_context/pricing");
$this->assertResponse(200, t('HTTP 200: List | Pricing #@num', array('@num' => $num)));
$this->assertResponse(200, t('HTTP 200: List | Pricing #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('Warning'), t('Make sure w/o Warnings'));
for ($j = 0; $j < $i + 1; $j++) {
$this->assertText($instance_type[$j],
t("Make sure w/ Listing @num: @instance_type", array(
t("Make sure w/ Listing @num: @instance_type", [
'@num' => $j + 1,
'@instance_type' => $instance_type[$j],
)));
]));
}
}
// Edit case.
$edit = $this->createPricingTestData();
$instance_type = array();
$instance_type = [];
// 3 times.
for ($i = 0; $i < CLOUD_PRICING_REPEAT_COUNT; $i++) {
......@@ -131,7 +131,7 @@ class CloudPricingTest extends WebTestBase {
$this->drupalPostForm("/admin/config/cloud/$cloud_context/pricing/$id",
$edit[$i],
t('Save'));
$this->assertResponse(200, t('HTTP 200: Edit | A New Pricing Form #@num', array('@num' => $num)));
$this->assertResponse(200, t('HTTP 200: Edit | A New Pricing Form #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
$this->assertText($instance_type[$i] . ' ' . t('pricing information has been saved.'),
......@@ -139,29 +139,29 @@ class CloudPricingTest extends WebTestBase {
. $instance_type[$i] . ' ' . t('pricing information has been saved.'));
$this->assertText($instance_type[$i],
t('Instance Type: @instance_type', array(
t('Instance Type: @instance_type', [
'@instance_type' => $instance_type[$i],
)));
]));
$this->assertText(number_format($edit[$i]['linux_usage'], 3),
t('Linux Usage: @linux_usage', array(
t('Linux Usage: @linux_usage', [
'@linux_usage' => $edit[$i]['linux_usage'],
)));
]));
$this->assertText(number_format($edit[$i]['windows_usage'], 3),
t('Windows Usage: @windows_usage', array(
t('Windows Usage: @windows_usage', [
'@windows_usage' => $edit[$i]['windows_usage'],
)));
]));
// Make sure listing.
$this->drupalGet("/admin/config/cloud/$cloud_context/pricing");
$this->assertResponse(200, t('HTTP 200: List | Pricing #@num', array('@num' => $num)));
$this->assertResponse(200, t('HTTP 200: List | Pricing #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
for ($j = 0; $j < $i + 1; $j++) {
$this->assertText($instance_type[$j],
t("Make sure w/ Listing @num: @instance_type", array(
t("Make sure w/ Listing @num: @instance_type", [
'@num' => $j + 1,
'@instance_type' => $instance_type[$j],
)));
]));
}
}
......@@ -175,23 +175,23 @@ class CloudPricingTest extends WebTestBase {
$this->drupalGet("/admin/config/cloud/$cloud_context/pricing/$id/delete");
$this->drupalPostForm("/admin/config/cloud/$cloud_context/pricing/$id/delete",
array(),
[],
t('Delete'));
$this->assertResponse(200, t('HTTP 200: Pricing | Delete #@num', array('@num' => $num)));
$this->assertResponse(200, t('HTTP 200: Pricing | Delete #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
// Make sure listing.
$this->drupalGet("/admin/config/cloud/$cloud_context/pricing");
$this->assertResponse(200, t('HTTP 200: List | Pricing #@num', array('@num' => $num)));
$this->assertResponse(200, t('HTTP 200: List | Pricing #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
for ($j = 0; $j < $i + 1; $j++) {
$this->assertNoText($instance_type[$j],
t("Make sure w/ Listing @num: @instance_type", array(
t("Make sure w/ Listing @num: @instance_type", [
'@num' => $j + 1,
'@instance_type' => $instance_type[$j],
)));
]));
}
}
// Filtering pricing information item
......@@ -227,7 +227,7 @@ class CloudPricingTest extends WebTestBase {
$num = $i + 1;
// Input Fields.
$data[] = array(
$data[] = [
'instance_type' => "m$num.xlarge",
// 12.34 (min . sec)
'linux_usage' => date('i.s'),
......@@ -236,7 +236,7 @@ class CloudPricingTest extends WebTestBase {
'description' => "#$num: " . date('Y/m/d H:i:s - D M j G:i:s T Y')
. ' - SimpleTest Pricing Description'
. $random->string(32, TRUE),
);
];
}
return $data;
......
......@@ -20,17 +20,17 @@ class CloudScriptListBuilder extends CloudContentListBuilder {
*/
public function buildHeader() {
$header = array(
$header = [
// The header gives the table the information it needs in order to make
// the query calls for ordering. TableSort uses the field information
// to know what database column to sort by.
array('data' => t('Name'), 'specifier' => 'name'),
array('data' => t('Description'), 'specifier' => 'description'),
array('data' => t('Type'), 'specifier' => 'type'),
array('data' => t('Input Parameters'), 'specifier' => 'input_parameters'),
array('data' => t('Date Created'), 'specifier' => 'created'),
array('data' => t('Date Updated'), 'specifier' => 'changed', 'sort' => 'DESC'),
);
['data' => t('Name'), 'specifier' => 'name'],
['data' => t('Description'), 'specifier' => 'description'],
['data' => t('Type'), 'specifier' => 'type'],
['data' => t('Input Parameters'), 'specifier' => 'input_parameters'],
['data' => t('Date Created'), 'specifier' => 'created'],
['data' => t('Date Updated'), 'specifier' => 'changed', 'sort' => 'DESC'],
];
return $header + parent::buildHeader();
}
......@@ -46,10 +46,10 @@ class CloudScriptListBuilder extends CloudContentListBuilder {
$row['name'] = \Drupal::l(
$this->getLabel($entity),
new Url(
'entity.cloud_script.canonical', array(
'entity.cloud_script.canonical', [
'cloud_script' => $entity->id(),
// 'cloud_context' => $entity->cloud_context(), // Need to add.
)
]
)
);
$row['description'] = $entity->description();
......
......@@ -56,9 +56,9 @@ class CloudScript extends ContentEntityBase implements CloudScriptInterface {
*/
public static function preCreate(EntityStorageInterface $storage_controller, array &$values) {
parent::preCreate($storage_controller, $values);
$values += array(
$values += [
'user_id' => \Drupal::currentUser()->id(),
);
];
}
/**
......@@ -184,16 +184,16 @@ class CloudScript extends ContentEntityBase implements CloudScriptInterface {
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name'))
->setDescription(t('The name of the CloudScript entity.'))
->setSettings(array(
->setSettings([
'default_value' => '',
'max_length' => 255,
'text_processing' => 0,
))
->setDisplayOptions('view', array(
])
->setDisplayOptions('view', [
'label' => 'above',
'type' => 'string',
'weight' => -5,
))
])
/*
->setDisplayOptions('form', array(
'type' => 'string_textfield',
......@@ -238,21 +238,21 @@ class CloudScript extends ContentEntityBase implements CloudScriptInterface {
->setSetting('handler', 'default')
->setDefaultValueCallback('Drupal\node\Entity\Node::getCurrentUserId')
->setTranslatable(TRUE)
->setDisplayOptions('view', array(
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'author',
'weight' => 0,
))
->setDisplayOptions('form', array(
])
->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
'weight' => 5,
'settings' => array(
'settings' => [
'match_operator' => 'CONTAINS',
'size' => '60',
'autocomplete_type' => 'tags',
'placeholder' => '',
),
))
],
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
......
......@@ -17,11 +17,11 @@ class CloudScriptViewsData extends EntityViewsData implements EntityViewsDataInt
public function getViewsData() {
$data = parent::getViewsData();
$data['cloud_script']['table']['base'] = array(
$data['cloud_script']['table']['base'] = [
'field' => 'id',
'title' => t('Cloud Scripts'),
'help' => t('The cloud_script entity ID.'),
);
];
return $data;
}
......
......@@ -25,7 +25,7 @@ class CloudScriptEditForm extends CloudContentForm {
$entity = $this->entity;
$form['name'] = array(
$form['name'] = [
'#type' => 'textfield',
'#title' => $this->t('Name'),
'#maxlength' => 255,
......@@ -33,7 +33,7 @@ class CloudScriptEditForm extends CloudContentForm {
'#default_value' => $entity->label(),
'#required' => TRUE,
'#weight' => -5,
);
];
/*
$form['cloud_context'] = array(
'#type' => 'textfield',
......@@ -48,7 +48,7 @@ class CloudScriptEditForm extends CloudContentForm {
'#disabled' => TRUE,
);
*/
$form['description'] = array(
$form['description'] = [
'#type' => 'textarea',
'#title' => $this->t('Description'),
'#cols' => 60,
......@@ -56,27 +56,27 @@ class CloudScriptEditForm extends CloudContentForm {
'#default_value' => $entity->description(),
'#weight' => -5,
'#required' => FALSE,
);
];
$form['type'] = array(
$form['type'] = [
'#type' => 'textfield',
'#title' => $this->t('Type'),
'#size' => 60,
'#default_value' => $entity->type(),
'#weight' => -5,
'#required' => FALSE,
);
];
$form['input_parameters'] = array(
$form['input_parameters'] = [
'#type' => 'textfield',
'#title' => $this->t('Input Prameters'),
'#size' => 60,
'#default_value' => $entity->input_parameters(),
'#weight' => -5,
'#required' => FALSE,
);
];
$form['script'] = array(
$form['script'] = [
'#type' => 'textarea',
'#title' => $this->t('Script'),
'#cols' => 60,
......@@ -84,14 +84,14 @@ class CloudScriptEditForm extends CloudContentForm {
'#default_value' => $entity->description(),
'#weight' => -5,
'#required' => FALSE,
);
];
$form['langcode'] = array(
$form['langcode'] = [
'#title' => t('Language'),
'#type' => 'language_select',
'#default_value' => $entity->getUntranslated()->language()->getId(),
'#languages' => Language::STATE_ALL,
);
];
$form['actions'] = $this->actions($form, $form_state, $cloud_context);
......
......@@ -29,9 +29,9 @@ class CloudScriptTest extends WebTestBase {
*
* @var array
*/
public static $modules = array('cloud',
public static $modules = ['cloud',
'cloud_script',
);
];
/**
* The profile to install as a basis for testing.
......@@ -46,13 +46,13 @@ class CloudScriptTest extends WebTestBase {
protected function setUp() {
parent::setUp();
$web_user = $this->drupalCreateUser(array(
$web_user = $this->drupalCreateUser([
'add cloud script',
'list cloud script',
'view cloud script',
'edit cloud script',
'delete cloud script',
));
]);
$this->drupalLogin($web_user);
}
......@@ -84,33 +84,33 @@ class CloudScriptTest extends WebTestBase {
$this->drupalPostForm('/clouds/design/script/add',
$add[$i],
t('Save'));
$this->assertResponse(200, t('HTTP 200: Add | A New CloudScript Form #@num', array('@num' => $num)));
$this->assertResponse(200, t('HTTP 200: Add | A New CloudScript Form #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('Warning'), t('Make sure w/o Warnings'));
$this->assertText(t('The scripts "@name" has been saved.', array(
$this->assertText(t('The scripts "@name" has been saved.', [
'@name' => $add[$i]['name'],
)),
]),
t('Confirm Message') . ': '
. t('The scripts "@name" has been saved.', array(
. t('The scripts "@name" has been saved.', [
'@name' => $add[$i]['name'],
))
])
);
$this->assertText($add[$i]['name'],
t('Name: @name ', array(
t('Name: @name ', [
'@name' => $add[$i]['name'],
)));
]));
// Make sure listing.
$this->drupalGet('/clouds/design/script');
$this->assertResponse(200, t('HTTP 200: List | Scripting #@num', array('@num' => $num)));
$this->assertResponse(200, t('HTTP 200: List | Scripting #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('Warning'), t('Make sure w/o Warnings'));
for ($j = 0; $j < $i + 1; $j++) {
$this->assertText($add[$j]['name'],
t("Make sure w/ Listing @num: @name", array(
t("Make sure w/ Listing @num: @name", [
'@num' => $j + 1,
'@name' => $add[$j]['name'],
)));
]));
}
}
......@@ -124,33 +124,33 @@ class CloudScriptTest extends WebTestBase {
$this->drupalPostForm("/clouds/design/script/$num/edit",
$edit[$i],
t('Save'));
$this->assertResponse(200, t('HTTP 200: Edit | A New Scripting Form #@num', array('@num' => $num)));
$this->assertResponse(200, t('HTTP 200: Edit | A New Scripting Form #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('Warning'), t('Make sure w/o Warnings'));
$this->assertText(t('The scripts "@name" has been saved.', array(
$this->assertText(t('The scripts "@name" has been saved.', [
'@name' => $edit[$i]['name'],
)),
]),
t('Confirm Message') . ': '
. t('The scripts "@name" has been saved.', array(
. t('The scripts "@name" has been saved.', [
'@name' => $edit[$i]['name'],
))
])
);
$this->assertText($edit[$i]['name'],
t('Name: @name ', array(
t('Name: @name ', [
'@name' => $edit[$i]['name'],
)));
]));
// Make sure listing.
$this->drupalGet('/clouds/design/script');
$this->assertResponse(200, t('HTTP 200: List | Scripting #@num', array('@num' => $num)));
$this->assertResponse(200, t('HTTP 200: List | Scripting #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
for ($j = 0; $j < $i + 1; $j++) {
$this->assertText($edit[$j]['name'],
t("Make sure w/ Listing @num: @name", array(
t("Make sure w/ Listing @num: @name", [
'@num' => $j + 1,
'@name' => $edit[$j]['name'],
)));
]));
}
}
......@@ -162,23 +162,23 @@ class CloudScriptTest extends WebTestBase {
$this->drupalGet("/clouds/design/script/$num/delete");
$this->drupalPostForm("/clouds/design/script/$num/delete",
array(),
[],
t('Delete'));
$this->assertResponse(200, t('HTTP 200: Delete | Scripting #@num', array('@num' => $num)));
$this->assertResponse(200, t('HTTP 200: Delete | Scripting #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
// Make sure listing.
$this->drupalGet('/clouds/design/script');
$this->assertResponse(200, t('HTTP 200: List | Scripting #@num', array('@num' => $num)));
$this->assertResponse(200, t('HTTP 200: List | Scripting #@num', ['@num' => $num]));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
for ($j = 0; $j < $i + 1; $j++) {
$this->assertNoText($edit[$j]['name'],
t("Make sure w/ Listing @num: @name", array(
t("Make sure w/ Listing @num: @name", [
'@num' => $j + 1,
'@name' => $edit[$j]['name'],
)));
]));
}
}
......@@ -210,14 +210,14 @@ class CloudScriptTest extends WebTestBase {
$random = new Random();
}
$data = array();
$data = [];
// 3 times.
for ($i = 0; $i < CLOUD_SCRIPTING_REPEAT_COUNT; $i++) {
$num = $i + 1;
// Input Fields.
$data[$i] = array(
$data[$i] = [
// 'cloud_context' => $cloud_context,.
'name' => "Script #$num - " . date('Y/m/d') . $random->name(8, TRUE),
'description' => "#$num: " . date('Y/m/d H:i:s - D M j G:i:s T Y') . $random->name(8, TRUE)
......@@ -227,7 +227,7 @@ class CloudScriptTest extends WebTestBase {
. ' - SimpleTest Scripting Input Parameters',
'script' => "#$num: " . date('Y/m/d H:i:s - D M j G:i:s T Y')
. ' - SimpleTest Scripting Script' . $random->string(32, TRUE),
);
];
}
return $data;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment