//Set the request
$req = <<<SQL
SELECT COUNT(DISTINCT a.album_id) AS count
-FROM Rapsys\TreeBundle\Entity\Asset AS a
+FROM Rapsys\TreeBundle\Entity\Element AS a
WHERE $userSql
SQL;
public function findAllAsArray(?int $id, int $page, int $count): array {
//Set user sql
$userSql = <<<SQL
-s.user_id = :id
+e.user_id = :id
SQL;
//With null id
if ($id === null) {
//Set user sql
$userSql = <<<SQL
-s.user_id IS NULL
+e.user_id IS NULL
SQL;
}
SELECT
a.id,
a.path,
- GROUP_CONCAT(s.id ORDER BY s.id SEPARATOR "\\n") AS s_ids,
- GROUP_CONCAT(IFNULL(s.path, '/') ORDER BY s.id SEPARATOR "\\n") AS s_paths,
+ GROUP_CONCAT(e.id ORDER BY e.id SEPARATOR "\\n") AS s_ids,
+ GROUP_CONCAT(IFNULL(e.path, '/') ORDER BY e.id SEPARATOR "\\n") AS s_paths,
a.slug,
- GREATEST(a.created, s.created) AS created,
- GREATEST(a.updated, s.updated) AS updated,
- GREATEST(a.created, s.created, a.updated, s.updated) AS modified
+ GREATEST(a.created, e.created) AS created,
+ GREATEST(a.updated, e.updated) AS updated,
+ GREATEST(a.created, e.created, a.updated, e.updated) AS modified
FROM Rapsys\TreeBundle\Entity\Album AS a
-JOIN Rapsys\TreeBundle\Entity\Asset AS s ON (s.album_id = a.id AND {$userSql})
+JOIN Rapsys\TreeBundle\Entity\Element AS e ON (e.album_id = a.id AND {$userSql})
GROUP BY a.id
ORDER BY updated, created DESC, a.id
LIMIT :offset, :count
'updated' => $data['updated'],
'modified' => $data['modified'],
'link' => $this->router->generate('rapsystree_album', ['id' => $id, 'slug' => $slug, 'path' => '/']),
- 'assets' => []
+ 'elements' => []
];
- //Explode asset ids
+ //Explode element ids
$data['s_ids'] = explode("\n", $data['s_ids']);
- //Explode asset paths
+ //Explode element paths
$data['s_paths'] = explode("\n", $data['s_paths']);
foreach($data['s_ids'] as $s => $id) {
- $return[$data['id']]['assets'][$id] = [
+ $return[$data['id']]['elements'][$id] = [
'id' => $id,
'path' => $path = $data['s_paths'][$s],
- 'link' => $this->router->generate('rapsystree_asset', ['id' => $id, 'path' => $path]),
+ 'link' => $this->router->generate('rapsystree_element', ['id' => $id, 'path' => $path]),
];
}
}