AttributeValueTop.php in Commerce Bulk 8
File
src/Plugin/Action/AttributeValueTop.php
View source
<?php
namespace Drupal\commerce_bulk\Plugin\Action;
use Drupal\Core\Action\ActionBase;
use Drupal\Core\Session\AccountInterface;
class AttributeValueTop extends ActionBase {
public function executeMultiple(array $attributes) {
if (($attribute = reset($attributes)) && ($values = $attribute
->getAttribute()
->getValues())) {
$attribute = reset($values);
unset($values);
$weight = $attribute
->getWeight();
foreach ($attributes as $attribute) {
$weight--;
$attribute
->setWeight($weight)
->save();
}
}
}
public function execute($attribute = NULL) {
}
public function access($attribute, AccountInterface $account = NULL, $return_as_object = FALSE) {
$result = $attribute
->access('update', $account, TRUE);
return $return_as_object ? $result : $result
->isAllowed();
}
}