-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIUnitOfWork.php
More file actions
84 lines (72 loc) · 2.24 KB
/
IUnitOfWork.php
File metadata and controls
84 lines (72 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
/*
* Opulence
*
* @link https://www.opulencephp.com
* @copyright Copyright (C) 2021 David Young
* @license https://github.com/opulencephp/Opulence/blob/1.2/LICENSE.md
*/
namespace Opulence\Orm;
use Opulence\Databases\IConnection;
use Opulence\Orm\DataMappers\IDataMapper;
/**
* Defines the interface for units of work to implement
*/
interface IUnitOfWork
{
/**
* Commits any entities that have been scheduled for insertion/updating/deletion
*
* @throws OrmException Thrown if there was an error committing the transaction
*/
public function commit();
/**
* Detaches an entity from being managed
*
* @param object $entity The entity to detach
*/
public function detach($entity);
/**
* Disposes of all data in this unit of work
*/
public function dispose();
/**
* Gets the unit of work's entity registry
*
* @return IEntityRegistry The entity registry used by the unit of work
*/
public function getEntityRegistry() : IEntityRegistry;
/**
* Registers a data mapper for a class
* Registering a data mapper for a class will overwrite any previously-set data mapper for that class
*
* @param string $className The name of the class whose data mapper we're registering
* @param IDataMapper $dataMapper The data mapper for the class
*/
public function registerDataMapper(string $className, IDataMapper $dataMapper);
/**
* Schedules an entity for deletion
*
* @param object $entity The entity to schedule for deletion
*/
public function scheduleForDeletion($entity);
/**
* Schedules an entity for insertion
*
* @param object $entity The entity to schedule for insertion
*/
public function scheduleForInsertion($entity);
/**
* Schedules an entity for insertion
*
* @param object $entity The entity to schedule for insertion
*/
public function scheduleForUpdate($entity);
/**
* Sets the database connection
*
* @param IConnection $connection The connection to use
* @deprecated 1.1.0 Connections should only be passed into the unit of work's constructor
*/
public function setConnection(IConnection $connection);
}