BackendInterface.php 3.06 KB
Newer Older
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the TYPO3 CMS project.
7
 *
8
9
10
 * It is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, either version 2
 * of the License, or any later version.
11
 *
12
13
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
14
 *
15
16
 * The TYPO3 project - inspiring people to share!
 */
17

18
19
namespace TYPO3\CMS\Extbase\Persistence\Generic\Storage;

20
21
22
use TYPO3\CMS\Extbase\DomainObject\AbstractValueObject;
use TYPO3\CMS\Extbase\Persistence\QueryInterface;

Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
23
24
25
/**
 * Storage backend interface
 */
26
27
28
29
30
31
32
33
34
35
interface BackendInterface
{
    /**
     * Adds a row to the storage
     *
     * @param string $tableName The database table name
     * @param array $fieldValues The fieldValues to insert
     * @param bool $isRelation TRUE if we are currently inserting into a relation table, FALSE by default
     * @return int the UID of the inserted row
     */
36
    public function addRow(string $tableName, array $fieldValues, bool $isRelation = false): int;
37

38
39
40
41
42
43
44
    /**
     * Updates a row in the storage
     *
     * @param string $tableName The database table name
     * @param array $fieldValues The fieldValues to update
     * @param bool $isRelation TRUE if we are currently inserting into a relation table, FALSE by default
     */
45
    public function updateRow(string $tableName, array $fieldValues, bool $isRelation = false): void;
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
46

47
48
49
50
51
52
    /**
     * Updates a relation row in the storage
     *
     * @param string $tableName The database relation table name
     * @param array $fieldValues The fieldValues to be updated
     */
53
    public function updateRelationTableRow(string $tableName, array $fieldValues): void;
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
54

55
56
57
58
59
60
61
    /**
     * Deletes a row in the storage
     *
     * @param string $tableName The database table name
     * @param array $where An array of where array('fieldname' => value). This array will be transformed to a WHERE clause
     * @param bool $isRelation TRUE if we are currently inserting into a relation table, FALSE by default
     */
62
    public function removeRow(string $tableName, array $where, bool $isRelation = false): void;
63

64
65
66
67
68
69
    /**
     * Returns the number of items matching the query.
     *
     * @param \TYPO3\CMS\Extbase\Persistence\QueryInterface $query
     * @return int
     */
70
    public function getObjectCountByQuery(QueryInterface $query): int;
71

72
73
74
75
76
77
    /**
     * Returns the object data matching the $query.
     *
     * @param \TYPO3\CMS\Extbase\Persistence\QueryInterface $query
     * @return array
     */
78
    public function getObjectDataByQuery(QueryInterface $query): array;
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
79

80
81
82
83
    /**
     * Checks if a Value Object equal to the given Object exists in the data base
     *
     * @param \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject $object The Value Object
84
     * @return int|null The matching uid if an object was found, else null
85
86
     * @todo this is the last monster in this persistence series. refactor!
     */
87
    public function getUidOfAlreadyPersistedValueObject(AbstractValueObject $object): ?int;
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
88
}