1
|
|
|
<?php declare(strict_types = 1); |
2
|
|
|
namespace ApacheSolrForTypo3\Solr\Domain\Index\Queue; |
3
|
|
|
|
4
|
|
|
/*************************************************************** |
5
|
|
|
* Copyright notice |
6
|
|
|
* |
7
|
|
|
* (c) 2010-2017 dkd Internet Service GmbH <[email protected]> |
8
|
|
|
* All rights reserved |
9
|
|
|
* |
10
|
|
|
* This script is part of the TYPO3 project. The TYPO3 project is |
11
|
|
|
* free software; you can redistribute it and/or modify |
12
|
|
|
* it under the terms of the GNU General Public License as published by |
13
|
|
|
* the Free Software Foundation; either version 2 of the License, or |
14
|
|
|
* (at your option) any later version. |
15
|
|
|
* |
16
|
|
|
* The GNU General Public License can be found at |
17
|
|
|
* http://www.gnu.org/copyleft/gpl.html. |
18
|
|
|
* |
19
|
|
|
* This script is distributed in the hope that it will be useful, |
20
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
21
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22
|
|
|
* GNU General Public License for more details. |
23
|
|
|
* |
24
|
|
|
* This copyright notice MUST APPEAR in all copies of the script! |
25
|
|
|
***************************************************************/ |
26
|
|
|
|
27
|
|
|
use ApacheSolrForTypo3\Solr\System\Records\AbstractRepository; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Class IndexQueueIndexingPropertyRepository |
31
|
|
|
* Handles all CRUD operations to tx_solr_indexqueue_indexing_property table |
32
|
|
|
*/ |
33
|
|
|
class IndexQueueIndexingPropertyRepository extends AbstractRepository |
34
|
|
|
{ |
35
|
|
|
/** |
36
|
|
|
* @var string |
37
|
|
|
*/ |
38
|
|
|
protected $table = 'tx_solr_indexqueue_indexing_property'; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Removes existing indexing properties. |
42
|
|
|
* |
43
|
|
|
* @param int $rootPid |
44
|
|
|
* @param int $indexQueueUid |
45
|
|
|
* @return int |
46
|
|
|
*/ |
47
|
|
|
public function removeByRootPidAndIndexQueueUid(int $rootPid, int $indexQueueUid) : int |
48
|
|
|
{ |
49
|
|
|
$queryBuider = $this->getQueryBuilder(); |
50
|
|
|
return $queryBuider |
51
|
|
|
->delete($this->table) |
52
|
|
|
->where( |
53
|
|
|
$queryBuider->expr()->eq('root', $queryBuider->createNamedParameter($rootPid, \PDO::PARAM_INT)), |
54
|
|
|
$queryBuider->expr()->eq('item_id', $queryBuider->createNamedParameter($indexQueueUid, \PDO::PARAM_INT)) |
55
|
|
|
)->execute(); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Inserts a list of given properties |
60
|
|
|
* |
61
|
|
|
* @param array $properties assoc array with column names as key |
62
|
|
|
* @return int |
63
|
|
|
*/ |
64
|
|
|
public function bulkInsert(array $properties) : int |
65
|
|
|
{ |
66
|
|
|
return $this->getQueryBuilder()->getConnection()->bulkInsert($this->table, $properties, ['root', 'item_id', 'property_key', 'property_value']); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Fetches a list of properties related to index queue item |
71
|
|
|
* |
72
|
|
|
* @param int $indexQueueUid |
73
|
|
|
* @return array list of records for searched index queue item |
74
|
|
|
*/ |
75
|
|
|
public function findAllByIndexQueueUid(int $indexQueueUid) : array |
76
|
|
|
{ |
77
|
|
|
$queryBuider = $this->getQueryBuilder(); |
78
|
|
|
return $queryBuider |
79
|
|
|
->select('property_key', 'property_value') |
80
|
|
|
->from($this->table) |
81
|
|
|
->where( |
82
|
|
|
$queryBuider->expr()->eq('item_id', $queryBuider->createNamedParameter($indexQueueUid, \PDO::PARAM_INT)) |
83
|
|
|
) |
84
|
|
|
->execute()->fetchAll(); |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|