1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @package org.openpsa.invoices |
4
|
|
|
* @author The Midgard Project, http://www.midgard-project.org |
5
|
|
|
* @copyright The Midgard Project, http://www.midgard-project.org |
6
|
|
|
* @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
use midcom\datamanager\datamanager; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Invoice management MidCOM interface class. |
13
|
|
|
* |
14
|
|
|
* @package org.openpsa.invoices |
15
|
|
|
*/ |
16
|
|
|
class org_openpsa_invoices_interface extends midcom_baseclasses_components_interface |
17
|
|
|
implements midcom_services_permalinks_resolver |
18
|
|
|
{ |
19
|
|
|
public function resolve_object_link(midcom_db_topic $topic, midcom_core_dbaobject $object) : ?string |
20
|
|
|
{ |
21
|
|
|
if ($object instanceof org_openpsa_invoices_invoice_dba) { |
22
|
|
|
return "invoice/{$object->guid}/"; |
23
|
|
|
} |
24
|
|
|
return null; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Handle deletes of "parent" objects |
29
|
|
|
*/ |
30
|
11 |
|
public function _on_watched_dba_delete(midcom_core_dbaobject $object) |
31
|
|
|
{ |
32
|
11 |
|
midcom::get()->auth->request_sudo($this->_component); |
33
|
11 |
|
$qb = org_openpsa_invoices_billing_data_dba::new_query_builder(); |
34
|
11 |
|
$qb->add_constraint('linkGuid', '=', $object->guid); |
35
|
11 |
|
foreach ($qb->execute() as $billing_data) { |
36
|
|
|
debug_add("Delete billing data with guid:" . $billing_data->guid . " for object with guid:" . $object->guid); |
37
|
|
|
$billing_data->delete(); |
38
|
|
|
} |
39
|
11 |
|
midcom::get()->auth->drop_sudo(); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Prepare the indexer client |
44
|
|
|
*/ |
45
|
|
|
public function _on_reindex($topic, midcom_helper_configuration $config, midcom_services_indexer $indexer) |
46
|
|
|
{ |
47
|
|
|
$qb = org_openpsa_invoices_invoice_dba::new_query_builder(); |
48
|
|
|
$dm = datamanager::from_schemadb($config->get('schemadb')); |
|
|
|
|
49
|
|
|
|
50
|
|
|
$indexer = new org_openpsa_invoices_midcom_indexer($topic, $indexer); |
51
|
|
|
$indexer->add_query('invoices', $qb, $dm); |
52
|
|
|
|
53
|
|
|
return $indexer; |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|