/** * @param string $word * @return mixed */ private function interpret($word) { switch ($word) { case "getName": if ($this->stack[count($this->stack) - 1] == "list") { if ($this->stack[count($this->stack) - 3] == "sample") { // [...] } } else { switch ($this->stack[count($this->stack) - 2]) { case "sample": if ($this->sample instanceof Sample) { $this->result = $this->sample->get_name(); } else { $this->sample = new Sample($this->stack[count($this->stack) - 1]); $this->result = $this->sample->get_name(); } return $this->result; break; } } break; case "item": $sample_item = new SampleItem($this->sample_id); $this->temp = $sample_item->get_sample_items(); array_push($this->stack, "item"); $item_value_var = new ItemValueVar(); $this->result = $item_value_var->get_content($this->string_array, $this->stack, $this->result, $this->temp); $this->stack = $item_value_var->get_stack(); $this->string_array = $item_value_var->get_string_array(); break; default: break; } if (count($this->string_array) == 0) { return $this->result; } else { return $this->get_content(null, null, null, null); } }
/** * @see SampleInterface::delete() * @return bool * @throws SampleDeleteLocationException * @throws SampleDeleteUserException * @throws SampleDeleteOrganisationUnitException * @throws SampleDeleteItemException * @throws SampleDeleteFolderException * @throws SampleDeleteEventFailedException * @throws SampleDeleteFailedException * @throws SampleDeleteItemLinkException * @throws SampleNoInstanceException */ public function delete() { global $transaction; if ($this->sample_id and $this->sample) { $transaction_id = $transaction->begin(); try { array_push(self::$sample_delete_array, $this->sample_id); $tmp_sample_id = $this->sample_id; // Location Relations $sample_has_location_array = SampleHasLocation_Access::list_entries_by_sample_id($tmp_sample_id); if (is_array($sample_has_location_array) and count($sample_has_location_array) >= 1) { foreach ($sample_has_location_array as $key => $value) { $sample_has_location = new SampleHasLocation_Access($value); if ($sample_has_location->delete() == false) { throw new SampleDeleteLocationException(); } } } // Organisation Unit and User Relations $sample_security = new SampleSecurity($tmp_sample_id); $organisation_unit_array = $sample_security->list_organisation_unit_entries(); if (is_array($organisation_unit_array) and count($organisation_unit_array) >= 1) { foreach ($organisation_unit_array as $key => $value) { if ($sample_security->delete_organisation_unit($value) == false) { throw new SampleDeleteOrganisationUnitException(); } } } $user_array = $sample_security->list_user_entries(); if (is_array($user_array) and count($user_array) >= 1) { foreach ($user_array as $key => $value) { if ($sample_security->delete_user($value) == false) { throw new SampleDeleteUserException(); } } } // Items $sample_item = new SampleItem($tmp_sample_id); $item_array = $sample_item->get_sample_items(); if (is_array($item_array) and count($item_array) >= 1) { foreach ($item_array as $item_key => $item_value) { $sample_item = new SampleItem($tmp_sample_id); $sample_item->set_item_id($item_value); if ($sample_item->unlink_item() == false) { throw new SampleDeleteItemException(); } } } // Parent-Sample-Sub-Item-Links if (SampleItem::delete_remaining_sample_entries($tmp_sample_id) == false) { throw new SampleDeleteItemException(); } parent::delete(); $sample_delete_event = new SampleDeleteEvent($tmp_sample_id); $event_handler = new EventHandler($sample_delete_event); if ($event_handler->get_success() == false) { throw new SampleDeleteEventFailedException(); } $sample_is_item = new SampleIsItem_Access($tmp_sample_id); if ($sample_is_item->delete() == false) { throw new SampleDeleteItemLinkException(); } if ($this->sample->delete() == false) { throw new SampleDeleteFailedException(); } else { $this->__destruct(); $folder_id = SampleFolder::get_folder_by_sample_id($tmp_sample_id); $folder = Folder::get_instance($folder_id); if ($folder->delete(true, true) == false) { throw new SampleDeleteFolderException(); } } } catch (BaseException $e) { if ($transaction_id != null) { $transaction->rollback($transaction_id); } throw $e; } if ($transaction_id != null) { $transaction->commit($transaction_id); } return true; } else { throw new SampleNoInstanceException(); } }