protected function overviewTableRow($conditions, $id, $entity, $additional_cols = array())
 {
     // Avoid the 'delete' operation if the Workflow is used somewhere.
     $status = $entity->status;
     // @see parent::overviewTableRow() how to determine a deletable entity.
     if (!entity_has_status($this->entityType, $entity, ENTITY_IN_CODE) && !$entity->isDeletable()) {
         // Set to a state that does not allow deleting, but allows other actions.
         $entity->status = ENTITY_IN_CODE;
     }
     $row = parent::overviewTableRow($conditions, $id, $entity, $additional_cols);
     // Just to be sure: reset status.
     $entity->status = $status;
     return $row;
 }
 protected function overviewTableRow($conditions, $id, $entity, $additional_cols = array())
 {
     $entity_uri = entity_uri($this->entityType, $entity);
     $row[] = array('data' => array('#theme' => 'entity_ui_overview_item', '#label' => entity_label($this->entityType, $entity), '#name' => !empty($this->entityInfo['exportable']) ? entity_id($this->entityType, $entity) : FALSE, '#url' => $entity_uri ? $entity_uri : FALSE, '#entity_type' => $this->entityType));
     // Add in any passed additional cols.
     foreach ($additional_cols as $col) {
         $row[] = $col;
     }
     // Add a row for the exportable status.
     if (!empty($this->entityInfo['exportable'])) {
         $row[] = array('data' => array('#theme' => 'entity_status', '#status' => $entity->{$this->statusKey}));
     }
     // In case this is a bundle, we add links to the field ui tabs.
     $field_ui = !empty($this->entityInfo['bundle of']) && entity_type_is_fieldable($this->entityInfo['bundle of']) && module_exists('field_ui');
     // For exportable entities we add an export link.
     $exportable = !empty($this->entityInfo['exportable']);
     // If i18n integration is enabled, add a link to the translate tab.
     $i18n = !empty($this->entityInfo['i18n controller class']);
     // Add operations depending on the status.
     if (entity_has_status($this->entityType, $entity, ENTITY_FIXED)) {
         $row[] = array('data' => l(t('clone'), $this->path . '/manage/' . $id . '/clone'), 'colspan' => $this->operationCount());
     } else {
         $row[] = l(t('edit'), $this->path . '/manage/' . $id);
         if (empty($this->entityInfo['exportable']) || !entity_has_status($this->entityType, $entity, ENTITY_IN_CODE)) {
             $row[] = l(t('delete'), $this->path . '/manage/' . $id . '/delete', array('query' => drupal_get_destination()));
         } else {
             $row[] = '';
         }
     }
     if ($exportable) {
         $row[] = l(t('export'), $this->path . '/manage/' . $id . '/export');
     }
     $row[] = $entity->product_quantity;
     $row[] = l(t('quick+1'), '/product/' . $id . '/add/1');
     $row[] = l(t('quick-1'), '/product/' . $id . '/sub/1');
     return $row;
 }
 /**
  * Deletes the entities then rebuilds defaults if needed.
  *
  * @param $bids
  *  Can be an array of numeric BIDS, names, or combo as sutiable for load().
  */
 public function delete($bids)
 {
     $transaction = db_transaction();
     if (!empty($bids) && ($entities = command_buttons_load_multiple($bids, array()))) {
         try {
             foreach ($entities as $bid => $entity) {
                 // Call the entity-specific callback (if any):
                 module_invoke_all('entity_delete', $entity, 'command_button');
                 field_attach_delete('command_button', $entity);
             }
             // Delete after calling hooks so that they can query entity tables as needed.
             db_delete('command_buttons')->condition('bid', array_keys($entities), 'IN')->execute();
             // Clear the page and block and entity_load_multiple caches.
             entity_get_controller('command_button')->resetCache();
             foreach ($entities as $id => $entity) {
                 if (entity_has_status($this->entityType, $entity, ENTITY_IN_CODE)) {
                     entity_defaults_rebuild(array($this->entityType));
                     break;
                 }
             }
         } catch (Exception $e) {
             $transaction->rollback();
             watchdog_exception('command_button', $e);
             throw $e;
         }
     }
 }