Ejemplo n.º 1
0
 public static function diffRevisionUUIDs(Entity $entity, $revision_a, $revision_b)
 {
     $revision_a = self::prepareRevisionArgument($revision_a);
     $revision_b = self::prepareRevisionArgument($revision_b);
     $old_revision_ids = entity_get_id_by_uuid($entity->type(), array($revision_a), true);
     $old_revision_id = count($old_revision_ids) > 0 ? reset($old_revision_ids) : null;
     $new_revision_ids = entity_get_id_by_uuid($entity->type(), array($revision_b), true);
     $new_revision_id = count($new_revision_ids) > 0 ? reset($new_revision_ids) : null;
     return new self($entity, $old_revision_id, $new_revision_id);
 }
Ejemplo n.º 2
0
 public function receive($endpoint, $payload = array())
 {
     if (!array_key_exists('entities', $payload)) {
         throw new MalformedRequestException('The payload must contain entities to delete, but it does not.');
     }
     $deleted[] = array();
     foreach ($payload['entities'] as $to_delete) {
         if (Entity::exists($to_delete['entity_uuid'], $to_delete['entity_type'])) {
             publisher_set_flag('publisher_deleting');
             $entity_ids = entity_get_id_by_uuid($to_delete['entity_type'], array($to_delete['entity_uuid']));
             $entity_id = count($entity_ids) > 0 ? reset($entity_ids) : false;
             if ($entity_id === false) {
                 continue;
             }
             entity_delete($to_delete['entity_type'], $entity_id);
             drupal_set_message(t('<strong>:type</strong> @title deleted successfully.', array(':type' => $to_delete['entity_type'], '@title' => $to_delete['entity_title'])));
             $deleted[] = $to_delete;
         } else {
             drupal_set_message(t('<strong>:type</strong> @title did not exist.', array(':type' => $to_delete['entity_type'], '@title' => $to_delete['entity_title'])));
             $deleted[] = $to_delete;
         }
     }
     return array('deleted' => $deleted);
 }
Ejemplo n.º 3
0
 public static function loadByUUID($entity_uuid, $type)
 {
     $entities = entity_get_id_by_uuid($type, array($entity_uuid));
     foreach ($entities as $entity_id) {
         return self::load($entity_id, $type);
     }
     return false;
 }
Ejemplo n.º 4
0
 /**
  * Given a relationship, gets the destination entity ID.
  *
  * @param array $relationship The relationship.
  *
  * @return mixed|null Either the ID or null if it couldn't be found.
  */
 protected function getDestinationEntityID(array $relationship)
 {
     $destination_entity_ids = entity_get_id_by_uuid($relationship['destination_type'], array($relationship['destination_uuid']));
     return count($destination_entity_ids) > 0 ? reset($destination_entity_ids) : null;
 }