summaryrefslogtreecommitdiffstats
path: root/lib/Service/FolderService.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Service/FolderService.php')
-rw-r--r--lib/Service/FolderService.php87
1 files changed, 53 insertions, 34 deletions
diff --git a/lib/Service/FolderService.php b/lib/Service/FolderService.php
index 8eebf60ba..75aa294e1 100644
--- a/lib/Service/FolderService.php
+++ b/lib/Service/FolderService.php
@@ -5,10 +5,10 @@
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
- * @author Alessandro Cosentino <cosenal@gmail.com>
- * @author Bernhard Posselt <dev@bernhard-posselt.com>
- * @copyright Alessandro Cosentino 2012
- * @copyright Bernhard Posselt 2012, 2014
+ * @author Alessandro Cosentino <cosenal@gmail.com>
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright 2012 Alessandro Cosentino
+ * @copyright 2012-2014 Bernhard Posselt
*/
namespace OCA\News\Service;
@@ -20,7 +20,8 @@ use OCA\News\Config\Config;
use OCA\News\Utility\Time;
-class FolderService extends Service {
+class FolderService extends Service
+{
private $l10n;
private $timeFactory;
@@ -28,9 +29,10 @@ class FolderService extends Service {
private $folderMapper;
public function __construct(FolderMapper $folderMapper,
- IL10N $l10n,
- Time $timeFactory,
- Config $config){
+ IL10N $l10n,
+ Time $timeFactory,
+ Config $config
+ ) {
parent::__construct($folderMapper);
$this->l10n = $l10n;
$this->timeFactory = $timeFactory;
@@ -41,21 +43,25 @@ class FolderService extends Service {
/**
* Returns all folders of a user
- * @param string $userId the name of the user
+ *
+ * @param string $userId the name of the user
* @return array of folders
*/
- public function findAll($userId) {
+ public function findAll($userId)
+ {
return $this->folderMapper->findAllFromUser($userId);
}
- private function validateFolder($folderName, $userId){
+ private function validateFolder($folderName, $userId)
+ {
$existingFolders =
$this->folderMapper->findByName($folderName, $userId);
- if(count($existingFolders) > 0){
+ if(count($existingFolders) > 0) {
throw new ServiceConflictException(
- $this->l10n->t('Can not add folder: Exists already'));
+ $this->l10n->t('Can not add folder: Exists already')
+ );
}
if(mb_strlen($folderName) === 0) {
@@ -68,15 +74,17 @@ class FolderService extends Service {
/**
* Creates a new folder
- * @param string $folderName the name of the folder
- * @param string $userId the name of the user for whom it should be created
- * @param int $parentId the parent folder id, deprecated we don't nest
- * folders
+ *
+ * @param string $folderName the name of the folder
+ * @param string $userId the name of the user for whom it should be created
+ * @param int $parentId the parent folder id, deprecated we don't nest
+ * folders
* @throws ServiceConflictException if name exists already
* @throws ServiceValidationException if the folder has invalid parameters
* @return Folder the newly created folder
*/
- public function create($folderName, $userId, $parentId=0) {
+ public function create($folderName, $userId, $parentId=0)
+ {
$this->validateFolder($folderName, $userId);
$folder = new Folder();
@@ -91,7 +99,8 @@ class FolderService extends Service {
/**
* @throws ServiceException if the folder does not exist
*/
- public function open($folderId, $opened, $userId){
+ public function open($folderId, $opened, $userId)
+ {
$folder = $this->find($folderId, $userId);
$folder->setOpened($opened);
$this->folderMapper->update($folder);
@@ -100,15 +109,17 @@ class FolderService extends Service {
/**
* Renames a folder
- * @param int $folderId the id of the folder that should be deleted
- * @param string $folderName the new name of the folder
- * @param string $userId the name of the user for security reasons
+ *
+ * @param int $folderId the id of the folder that should be deleted
+ * @param string $folderName the new name of the folder
+ * @param string $userId the name of the user for security reasons
* @throws ServiceConflictException if name exists already
* @throws ServiceValidationException if the folder has invalid parameters
* @throws ServiceNotFoundException if the folder does not exist
* @return Folder the updated folder
*/
- public function rename($folderId, $folderName, $userId){
+ public function rename($folderId, $folderName, $userId)
+ {
$this->validateFolder($folderName, $userId);
$folder = $this->find($folderId, $userId);
@@ -119,11 +130,13 @@ class FolderService extends Service {
/**
* Use this to mark a folder as deleted. That way it can be un-deleted
- * @param int $folderId the id of the folder that should be deleted
- * @param string $userId the name of the user for security reasons
+ *
+ * @param int $folderId the id of the folder that should be deleted
+ * @param string $userId the name of the user for security reasons
* @throws ServiceNotFoundException when folder does not exist
*/
- public function markDeleted($folderId, $userId) {
+ public function markDeleted($folderId, $userId)
+ {
$folder = $this->find($folderId, $userId);
$folder->setDeletedAt($this->timeFactory->getTime());
$this->folderMapper->update($folder);
@@ -132,11 +145,13 @@ class FolderService extends Service {
/**
* Use this to restore a folder
- * @param int $folderId the id of the folder that should be restored
- * @param string $userId the name of the user for security reasons
+ *
+ * @param int $folderId the id of the folder that should be restored
+ * @param string $userId the name of the user for security reasons
* @throws ServiceNotFoundException when folder does not exist
*/
- public function unmarkDeleted($folderId, $userId) {
+ public function unmarkDeleted($folderId, $userId)
+ {
$folder = $this->find($folderId, $userId);
$folder->setDeletedAt(0);
$this->folderMapper->update($folder);
@@ -145,12 +160,14 @@ class FolderService extends Service {
/**
* Deletes all deleted folders
- * @param string $userId if given it purges only folders of that user
+ *
+ * @param string $userId if given it purges only folders of that user
* @param boolean $useInterval defaults to true, if true it only purges
- * entries in a given interval to give the user a chance to undo the
- * deletion
+ * entries in a given interval to give the user a chance to undo the
+ * deletion
*/
- public function purgeDeleted($userId=null, $useInterval=true) {
+ public function purgeDeleted($userId=null, $useInterval=true)
+ {
$deleteOlderThan = null;
if ($useInterval) {
@@ -168,9 +185,11 @@ class FolderService extends Service {
/**
* Deletes all folders of a user
+ *
* @param string $userId the name of the user
*/
- public function deleteUser($userId) {
+ public function deleteUser($userId)
+ {
$this->folderMapper->deleteUser($userId);
}