public function save($entity, DatabaseTransaction $transaction = NULL)
 {
     $workflow = $entity->getWorkflow();
     // To avoid double posting, check if this transition already exist.
     if (empty($entity->tid)) {
         if ($workflow) {
             $config_transitions = $workflow->getTransitionsBySidTargetSid($entity->sid, $entity->target_sid);
             $config_transition = reset($config_transitions);
             if ($config_transition) {
                 $entity->tid = $config_transition->tid;
             }
         }
     }
     // Create the machine_name. This can be used to rebuild/revert the Feature in a target system.
     if (empty($entity->name)) {
         $entity->name = $entity->sid . '_' . $entity->target_sid;
     }
     $return = parent::save($entity, $transaction);
     if ($return) {
         // Save in current workflow for the remainder of this page request.
         // Keep in sync with Workflow::getTransitions() !
         $workflow = $entity->getWorkflow();
         if ($workflow) {
             $workflow->transitions[$entity->tid] = $entity;
             // $workflow->sortTransitions();
         }
     }
     // Reset the cache for the affected workflow, to force reload upon next page_load.
     workflow_reset_cache($entity->wid);
     return $return;
 }
 public function buildContent($entity, $view_mode = 'full', $langcode = NULL, $content = array())
 {
     $wrapper = entity_metadata_wrapper('spotify_playlist_track', $entity);
     $content['author'] = array('#markup' => t('Created by: !author', array('!author' => $wrapper->uid->name->value(array('sanitize' => TRUE)))));
     // Make Description and Status themed like default fields.
     $content['description'] = array('#theme' => 'field', '#weight' => 0, '#title' => t('Track Description'), '#access' => TRUE, '#label_display' => 'above', '#view_mode' => 'full', '#language' => LANGUAGE_NONE, '#field_name' => 'field_fake_description', '#field_type' => 'text', '#entity_type' => 'spotify_playlist_track', '#bundle' => $entity->type, '#items' => array(array('value' => $entity->description)), '#formatter' => 'text_default', 0 => array('#markup' => check_plain($entity->description)));
     return parent::buildContent($entity, $view_mode, $langcode, $content);
 }
 /**
  * Saves a fundraiser sustainers series entity.
  *
  * @param Entity $fundraiser_sustainers_series
  *   The fundraiser sustainers series to save.
  *
  * @return Entity
  *   The saved fundraiser sustainers series.
  */
 public function save($fundraiser_sustainers_series)
 {
     $fundraiser_sustainers_series->updated = time();
     if (isset($fundraiser_sustainers_series->is_new) && $fundraiser_sustainers_series->is_new) {
         $fundraiser_sustainers_series->created = time();
     }
     parent::save($fundraiser_sustainers_series);
     return $fundraiser_sustainers_series;
 }
 /**
  * Override save method.
  *
  * Populate created and updated dates automatically.
  */
 public function save($entity, DatabaseTransaction $transaction = NULL)
 {
     if (isset($entity->is_new)) {
         $entity->created_at = REQUEST_TIME;
     }
     $entity->updated_at = REQUEST_TIME;
     // Always save new revisions.
     $entity->is_new_revision = TRUE;
     return parent::save($entity, $transaction);
 }
 public function delete($ids, \DatabaseTransaction $transaction = NULL)
 {
     $transaction = isset($transaction) ? $transaction : db_transaction();
     try {
         parent::delete($ids, $transaction);
         db_delete('observers')->condition('observable_id', $ids, 'IN')->execute();
     } catch (\Exception $e) {
         watchdog_exception($this->entityType, $e);
         $transaction->rollback();
         throw $e;
     }
 }
 /**
  * Insert (no update) a transition.
  *
  * @deprecated workflow_insert_workflow_node_history() --> WorkflowTransition::save()
  */
 public function save($entity, DatabaseTransaction $transaction = NULL)
 {
     // Check for no transition.
     if ($entity->old_sid == $entity->new_sid) {
         if (!$entity->comment) {
             // Write comment into history though.
             return;
         }
     }
     // Make sure we haven't already inserted history for this update.
     $last_history = workflow_transition_load_single($entity->entity_type, $entity->entity_id, $entity->field_name, $entity->language);
     if ($last_history && $last_history->stamp == REQUEST_TIME && $last_history->new_sid == $entity->new_sid) {
         return;
     } else {
         unset($entity->hid);
         $entity->stamp = REQUEST_TIME;
         return parent::save($entity, $transaction);
     }
 }
Ejemplo n.º 7
0
 public function save($entity, DatabaseTransaction $transaction = NULL)
 {
     // Create the machine_name.
     if (empty($entity->name)) {
         if ($label = $entity->state) {
             $entity->name = str_replace(' ', '_', strtolower($label));
         } else {
             $entity->name = 'state_' . $entity->sid;
         }
     }
     $return = parent::save($entity, $transaction);
     if ($return) {
         $workflow = $entity->getWorkflow();
         // Maintain the new object in the workflow.
         $workflow->states[$entity->sid] = $entity;
     }
     // Reset the cache for the affected workflow.
     workflow_reset_cache($entity->wid);
     return $return;
 }
 /**
  * Default values when create new entity instance.
  */
 public function create(array $values = array())
 {
     global $user;
     $values += array('domain' => '', 'status' => 1, 'uid' => $user->uid, 'description' => '');
     return parent::create($values);
 }
Ejemplo n.º 9
0
 public function buildContent($entity, $view_mode = 'default', $langcode = NULL, $content = array())
 {
     $build = parent::buildContent($entity, $view_mode, $langcode, $content);
     return $build;
 }
Ejemplo n.º 10
0
 /**
  * Insert (no update) a transition.
  *
  * deprecated workflow_insert_workflow_node_history() --> WorkflowTransition::save()
  */
 public function save($entity, DatabaseTransaction $transaction = NULL)
 {
     // Check for no transition.
     if ($entity->old_sid == $entity->new_sid) {
         if (!$entity->comment) {
             // Write comment into history though.
             return;
         }
     }
     if (empty($entity->hid)) {
         // Insert the transition. Make sure it hasn't already been inserted.
         $last_history = workflow_transition_load_single($entity->entity_type, $entity->entity_id, $entity->field_name, $entity->language);
         if ($last_history && $last_history->stamp == REQUEST_TIME && $last_history->new_sid == $entity->new_sid) {
             return;
         } else {
             unset($entity->hid);
             $entity->stamp = isset($entity->stamp) ? $entity->stamp : REQUEST_TIME;
             return parent::save($entity, $transaction);
         }
     } else {
         // Update the transition.
         return parent::save($entity, $transaction);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function delete($ids, \DatabaseTransaction $transaction = NULL)
 {
     if ($this->isFastDeleteEnabled()) {
         $this->fastDelete($ids, $transaction);
         return;
     }
     parent::delete($ids, $transaction);
 }