/**
  * Permanently deletes the entity.
  */
 public function delete()
 {
     // Notify any interested modules before we delete, in case there's data needed.
     // @todo D8: this can be replaced by a hook_entity_delete(?)
     module_invoke_all('workflow', 'transition delete', $this->tid, NULL, NULL, FALSE);
     return parent::delete();
 }
Exemplo n.º 2
0
 function testEntity()
 {
     global $_PA;
     // Dal::register_query_callback("explain_query");
     // see if our test entity already exists
     $entity = Entity::load("PHPUnit", "TestEntity", "#1");
     $this->assertNull($entity, "we shouldn't have any Entites in the service PHPUnit at this point.");
     $myEntity = new TestEntity('#1');
     echo "sync #1\n";
     Entity::sync($myEntity);
     // create a second
     $myEntity2 = new TestEntity('#2');
     echo "sync #2\n";
     Entity::sync($myEntity2);
     // modify #1
     $myEntity->attributes['ThreeAttribute'] = array('value' => "Baz");
     Entity::sync($myEntity);
     // remove an attribute from #2
     unset($myEntity2->attributes['OneAttribute']);
     Entity::sync($myEntity2);
     $myEntity3 = new TestEntity('#3');
     Entity::sync($myEntity3);
     $myEntity4 = new TestEntity('#4');
     $myEntity4->attributes['ThreeAttribute'] = array('value' => "Baz");
     $myEntity4->attributes['fourAttribute'] = array('value' => "4");
     Entity::sync($myEntity4);
     // test attribute search
     // Dal::register_query_callback("explain_query");
     $foundEntities = Entity::search(array('entity_service' => 'PHPUnit', 'entity_type' => 'TestEntity'), array('OneAttribute' => 'F', 'TwoAttribute' => 'b', 'ThreeAttribute' => 'b', 'FourAttribute' => '4'));
     // Dal::unregister_query_callback("explain_query");
     echo "\nfound " . count($foundEntities) . " entities by attribute search:\n";
     foreach ($foundEntities as $i => $e) {
         echo "entity: '{$e['entity_service']}:{$e['entity_type']}:{$e['entity_id']}\n";
     }
     // Dal::register_query_callback("explain_query");
     $foundEntities = Entity::search(array(), array('FourAttribute' => '4'));
     // Dal::unregister_query_callback("explain_query");
     echo "\nfound " . count($foundEntities) . " entities by attribute search:\n";
     foreach ($foundEntities as $i => $e) {
         echo "entity: '{$e['entity_service']}:{$e['entity_type']}:{$e['entity_id']}\n";
     }
     $testEntities = Entity::search(array('entity_service' => 'PHPUnit', 'entity_type' => 'TestEntity'));
     echo "\nfound " . count($testEntities) . " test entities:\n";
     // load test entities
     foreach ($testEntities as $i => $e) {
         echo "entity: '{$e['entity_service']}:{$e['entity_type']}:{$e['entity_id']}\n";
         // print_r(Entity::load($e['entity_service'], $e['entity_type'], $e['entity_id'])); echo "\n";
     }
     // clean up test entities
     foreach ($testEntities as $i => $e) {
         Entity::delete($e['entity_service'], $e['entity_type'], $e['entity_id']);
     }
     // test again
     $testEntities = Entity::search(array('entity_service' => 'PHPUnit'));
     $this->assertEquals(count($testEntities), 0, "There should no longer be any Entities in the PHPUnit service.");
 }
 public function delete()
 {
     $transaction = $this->beginTransaction();
     try {
         $idTemplate = $this->getId();
         $idEntity = $this->getIdEntity();
         // remove entry
         $entry = new Entry();
         $entry->deleteEntry($this->getEntry());
         // remove related FEs
         //Base::deleteEntity2Relation($idEntity, 'rel_elementof');
         $fe = new FrameElement();
         $fes = $this->listFEforDeletion()->asQuery()->getResult();
         foreach ($fes as $row) {
             $fe->getById($row['idFrameElement']);
             $fe->delete();
         }
         // remove this template
         parent::delete();
         // remove entity
         $entity = new Entity($idEntity);
         $entity->delete();
         $transaction->commit();
     } catch (\Exception $e) {
         $transaction->rollback();
         throw new \Exception($e->getMessage());
     }
 }
Exemplo n.º 4
0
require_once 'Entity.class.php';
getStatics();
if (isset($_POST['img'])) {
    $cid = $_POST['img'];
    $entity = Entity::reincarnateByCid($cid);
    $entity->commentObjs[$cid]->deleteImage();
    $entity->updated = $entity->commentObjs[$cid]->timeStamp;
    $entity->commentObjs[$cid]->persist();
    $entity->persist();
} else {
    if (isset($_POST['cid'])) {
        $cid = $_POST['cid'];
        $entity = Entity::reincarnateByCid($cid);
        $entity->deleteComment($cid);
        //redirect
        $host = $_SERVER['HTTP_HOST'];
        $page = "T2B/Post_Central.php";
        $query = "id=" . $entity->id;
        header("Location: http://{$host}/{$page}?{$query}");
    } else {
        if (isset($_POST['eid'])) {
            $Eid = $_POST['eid'];
            Entity::delete($Eid);
            //redirect
            $host = $_SERVER['HTTP_HOST'];
            $page = "T2B/Home.php";
            header("Location: http://{$host}/{$page}");
        }
    }
}
setStatics();
 public function delete()
 {
     $transaction = $this->beginTransaction();
     try {
         $idEntity = $this->getIdEntity();
         // remove entry
         $entry = new Entry();
         $entry->deleteEntry($this->getEntry());
         // remove frame-relations
         Base::deleteAllEntityRelation($idEntity);
         // remove this frame
         parent::delete();
         // remove entity
         $entity = new Entity($idEntity);
         $entity->delete();
         $transaction->commit();
     } catch (\Exception $e) {
         $transaction->rollback();
         throw new \Exception($e->getMessage());
     }
 }
 public function delete()
 {
     $transaction = $this->beginTransaction();
     try {
         $hasChildren = count($this->listChildren($this->getId())->asQuery()->getResult()) > 0;
         if ($hasChildren) {
             throw new \Exception("Type has subtypes; it can't be removed.");
         } else {
             Base::deleteAllEntityRelation($this->getIdEntity());
             parent::delete();
             $entity = new Entity($this->getIdEntity());
             $entity->delete();
             $entry = new Entry();
             $entry->deleteEntry($this->getEntry());
             $transaction->commit();
         }
     } catch (\Exception $e) {
         $transaction->rollback();
         throw new \Exception($e->getMessage());
     }
 }
Exemplo n.º 7
0
 function delete()
 {
     $sql = 'DELETE FROM ' . EQUIPMENT_TICKET_TABLE . ' WHERE equipment_id=' . db_input($this->getId());
     $success = db_query($sql);
     if ($success) {
         return parent::delete();
     }
 }