/**
  * {@inheritdoc}
  */
 public function buildContent(array $entities, array $displays, $view_mode, $langcode = NULL)
 {
     parent::buildContent($entities, $displays, $view_mode, $langcode);
     foreach ($entities as $product) {
         $product->content['qty'] = array('#theme' => 'uc_qty', '#qty' => $product->qty->value, '#cell_attributes' => array('class' => array('qty')));
         $node = node_load($product->nid->target_id);
         $title = $node->access('view') ? \Drupal::l($product->title->value, new Url('entity.node.canonical', array('node' => $product->nid->target_id))) : $product->title->value;
         $product->content['product'] = array('#markup' => $title . uc_product_get_description($product), '#cell_attributes' => array('class' => array('product')));
         $product->content['model'] = array('#markup' => $product->model->value, '#cell_attributes' => array('class' => array('sku')));
         $account = \Drupal::currentUser();
         if ($account->hasPermission('administer products')) {
             $product->content['cost'] = array('#theme' => 'uc_price', '#price' => $product->cost->value, '#cell_attributes' => array('class' => array('cost')));
         }
         $product->content['price'] = array('#theme' => 'uc_price', '#price' => $product->price->value, '#suffixes' => array(), '#cell_attributes' => array('class' => array('price')));
         $product->content['total'] = array('#theme' => 'uc_price', '#price' => $product->price->value * $product->qty->value, '#suffixes' => array(), '#cell_attributes' => array('class' => array('total')));
     }
 }
Example #2
0
 /**
  * @inheritdoc
  */
 public function buildContent(array $entities, array $displays, $view_mode, $langcode = NULL)
 {
     // If we can get domain_field_extra_fields() working here, we may not even
     // need this override class and can do everything via formatters.
     parent::buildContent($entities, $displays, $view_mode, $langcode);
     $fields = domain_field_extra_fields();
     $list = array_keys($fields['domain']['domain']['display']);
     foreach ($entities as $entity) {
         // Add the fields.
         // @TODO: get field sort order.
         $display = $displays[$entity->bundle()];
         foreach ($list as $key) {
             if (!empty($entity->{$key}) && $display->getComponent($key)) {
                 $class = str_replace('_', '-', $key);
                 $entity->content[$key] = array('#markup' => SafeMarkup::checkPlain($entity->{$key}), '#prefix' => '<div class="domain-' . $class . '">' . '<strong>' . SafeMarkup::checkPlain($key) . ':</strong><br />', '#suffix' => '</div>');
             }
         }
     }
 }