BackendInterface.php 3.49 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;

Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
20
21
22
/**
 * Storage backend interface
 */
23
24
25
26
27
28
29
30
31
32
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
     */
33
    public function addRow(string $tableName, array $fieldValues, bool $isRelation = false): int;
34

35
36
37
38
39
40
41
    /**
     * 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
     */
42
    public function updateRow(string $tableName, array $fieldValues, bool $isRelation = false): void;
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
43

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

52
53
54
55
56
57
58
    /**
     * 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
     */
59
    public function removeRow(string $tableName, array $where, bool $isRelation = false): void;
60

61
62
63
64
65
66
67
68
    /**
     * Fetches maximal value for given table column
     *
     * @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 string $columnName column name to get the max value from
     * @return mixed the max value
     */
69
    public function getMaxValueFromTable(string $tableName, array $where, string $columnName);
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
70

71
72
73
74
75
76
    /**
     * Returns the number of items matching the query.
     *
     * @param \TYPO3\CMS\Extbase\Persistence\QueryInterface $query
     * @return int
     */
77
    public function getObjectCountByQuery(\TYPO3\CMS\Extbase\Persistence\QueryInterface $query): int;
78

79
80
81
82
83
84
    /**
     * Returns the object data matching the $query.
     *
     * @param \TYPO3\CMS\Extbase\Persistence\QueryInterface $query
     * @return array
     */
85
    public function getObjectDataByQuery(\TYPO3\CMS\Extbase\Persistence\QueryInterface $query): array;
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
86

87
88
89
90
    /**
     * 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
91
     * @return int|null The matching uid if an object was found, else null
92
93
     * @todo this is the last monster in this persistence series. refactor!
     */
94
    public function getUidOfAlreadyPersistedValueObject(\TYPO3\CMS\Extbase\DomainObject\AbstractValueObject $object): ?int;
Sebastian Kurfürst's avatar
Sebastian Kurfürst committed
95
}