ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\WOPI\Discovery\AppDBRepository Class Reference
+ Inheritance diagram for ILIAS\WOPI\Discovery\AppDBRepository:
+ Collaboration diagram for ILIAS\WOPI\Discovery\AppDBRepository:

Public Member Functions

 __construct (private \ilDBInterface $db)
 
 getApps (ActionRepository $action_repository)
 
 storeCollection (Apps $apps, ActionRepository $action_repository)
 
 clear (ActionRepository $action_repository)
 
 store (App $app, ActionRepository $action_repository)
 
 getApps (ActionRepository $action_repository)
 
 storeCollection (Apps $apps, ActionRepository $action_repository)
 
 store (App $app, ActionRepository $action_repository)
 
 clear (ActionRepository $action_repository)
 

Protected Attributes

const TABLE_NAME = 'wopi_app'
 

Private Member Functions

 fromDBRow (array $row, ActionRepository $action_repository)
 

Detailed Description

Author
Fabian Schmid fabia.nosp@m.n@sr.nosp@m..solu.nosp@m.tion.nosp@m.s

Definition at line 28 of file AppDBRepository.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\WOPI\Discovery\AppDBRepository::__construct ( private \ilDBInterface  $db)

Definition at line 32 of file AppDBRepository.php.

34 {
35 }

Member Function Documentation

◆ clear()

ILIAS\WOPI\Discovery\AppDBRepository::clear ( ActionRepository  $action_repository)

Implements ILIAS\WOPI\Discovery\AppRepository.

Definition at line 70 of file AppDBRepository.php.

70 : void
71 {
72 $query = 'DELETE FROM ' . self::TABLE_NAME;
73 $this->db->manipulate($query);
74 $action_repository->clear();
75 }

References ILIAS\WOPI\Discovery\ActionRepository\clear(), and ILIAS\WOPI\Discovery\AppDBRepository\TABLE_NAME.

+ Here is the call graph for this function:

◆ fromDBRow()

ILIAS\WOPI\Discovery\AppDBRepository::fromDBRow ( array  $row,
ActionRepository  $action_repository 
)
private

Definition at line 49 of file AppDBRepository.php.

49 : App
50 {
51 return new App(
52 (int) $row['id'],
53 (string) $row['name'],
54 $action_repository->getActionsForApp($row['id']),
55 $row['favicon'] ? new URI($row['favicon']) : null
56 );
57 }

Referenced by ILIAS\WOPI\Discovery\AppDBRepository\getApps().

+ Here is the caller graph for this function:

◆ getApps()

ILIAS\WOPI\Discovery\AppDBRepository::getApps ( ActionRepository  $action_repository)
Returns
App[]

Implements ILIAS\WOPI\Discovery\AppRepository.

Definition at line 37 of file AppDBRepository.php.

37 : array
38 {
39 $apps = [];
40 $query = 'SELECT * FROM ' . self::TABLE_NAME;
41 $result = $this->db->query($query);
42 while ($row = $this->db->fetchAssoc($result)) {
43 $apps[] = $this->fromDBRow($row, $action_repository);
44 }
45
46 return $apps;
47 }
fromDBRow(array $row, ActionRepository $action_repository)

References ILIAS\WOPI\Discovery\AppDBRepository\fromDBRow(), and ILIAS\WOPI\Discovery\AppDBRepository\TABLE_NAME.

+ Here is the call graph for this function:

◆ store()

ILIAS\WOPI\Discovery\AppDBRepository::store ( App  $app,
ActionRepository  $action_repository 
)

Implements ILIAS\WOPI\Discovery\AppRepository.

Definition at line 77 of file AppDBRepository.php.

77 : void
78 {
79 if ($app->getId() === 0) {
80 // check if there is an app with same name
81 $query = 'SELECT * FROM ' . self::TABLE_NAME . ' WHERE name = %s';
82 $result = $this->db->queryF($query, ['text'], [$app->getName()]);
83 if ($this->db->numRows($result) > 0) {
84 $row = $this->db->fetchAssoc($result);
85 $app = new App(
86 (int) $row['id'],
87 $app->getName(),
88 $app->getActions(),
89 $app->getFavicon()
90 );
91 }
92 }
93
94 if ($app->getId() === 0 || $this->db->queryF(
95 'SELECT * FROM ' . self::TABLE_NAME . ' WHERE id = %s',
96 ['integer'],
97 [$app->getId()]
98 )->numRows() === 0) {
99 $app = new App(
100 $this->db->nextId(self::TABLE_NAME),
101 $app->getName(),
102 $app->getActions(),
103 $app->getFavicon()
104 );
105
106 $query = 'INSERT INTO ' . self::TABLE_NAME . ' (id, name, favicon) VALUES (%s, %s, %s)';
107 $this->db->manipulateF(
108 $query,
109 ['integer', 'text', 'text'],
110 [$app->getId(), $app->getName(), $app->getFavicon()]
111 );
112 } else {
113 $query = 'UPDATE ' . self::TABLE_NAME . ' SET name = %s, favicon = %s WHERE id = %s';
114 $this->db->manipulateF(
115 $query,
116 ['text', 'text', 'integer'],
117 [$app->getName(), $app->getFavicon(), $app->getId()]
118 );
119 }
120
121 foreach ($app->getActions() as $action) {
122 $action_repository->store($action, $app);
123 }
124 }
store(Action $action, App $for_app)

References ILIAS\WOPI\Discovery\App\getActions(), ILIAS\WOPI\Discovery\App\getFavicon(), ILIAS\WOPI\Discovery\App\getId(), ILIAS\WOPI\Discovery\App\getName(), and ILIAS\WOPI\Discovery\ActionRepository\store().

Referenced by ILIAS\WOPI\Discovery\AppDBRepository\storeCollection().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ storeCollection()

ILIAS\WOPI\Discovery\AppDBRepository::storeCollection ( Apps  $apps,
ActionRepository  $action_repository 
)

Implements ILIAS\WOPI\Discovery\AppRepository.

Definition at line 59 of file AppDBRepository.php.

59 : void
60 {
61 $actions = [];
62 foreach ($apps->getApps() as $app) {
63 $actions = array_merge($actions, $app->getActions());
64 $this->store($app, $action_repository);
65 $actions += $app->getActions();
66 }
67 $action_repository->clearSuperfluous(...$actions);
68 }
store(App $app, ActionRepository $action_repository)
clearSuperfluous(Action ... $actions)

References ILIAS\WOPI\Discovery\ActionRepository\clearSuperfluous(), ILIAS\WOPI\Discovery\Apps\getApps(), and ILIAS\WOPI\Discovery\AppDBRepository\store().

+ Here is the call graph for this function:

Field Documentation

◆ TABLE_NAME

const ILIAS\WOPI\Discovery\AppDBRepository::TABLE_NAME = 'wopi_app'
protected

The documentation for this class was generated from the following file: