-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented helper for recounting the lines in files (#1045)
- Loading branch information
Showing
4 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
use DBA\File; | ||
|
||
require_once(dirname(__FILE__) . "/../common/AbstractHelperAPI.class.php"); | ||
|
||
class RecountFileFilesHelperAPI extends AbstractHelperAPI { | ||
public static function getBaseUri(): string { | ||
return "/api/v2/helper/recountFileLines"; | ||
} | ||
|
||
public static function getAvailableMethods(): array { | ||
return ['POST']; | ||
} | ||
|
||
public function getRequiredPermissions(string $method): array | ||
{ | ||
return [File::PERM_UPDATE]; | ||
} | ||
|
||
public function getFormFields(): array | ||
{ | ||
return [ | ||
File::FILE_ID => ["type" => "int"], | ||
]; | ||
} | ||
|
||
public function actionPost($data): array|null { | ||
// first retrieve the file, as fileCountLines does not check any permissions, therfore to be sure call getFile() first, even if it is not required technically | ||
FileUtils::getFile($data[File::FILE_ID], $this->getCurrentUser()); | ||
|
||
FileUtils::fileCountLines($data[File::FILE_ID]); | ||
|
||
return $this->object2Array(FileUtils::getFile($data[File::FILE_ID], $this->getCurrentUser())); | ||
} | ||
} | ||
|
||
RecountFileFilesHelperAPI::register($app); |