mirror of
https://github.com/verdigado/organization_folders.git
synced 2024-12-06 11:22:41 +01:00
added include functionality and update endpoint to resource controller
This commit is contained in:
parent
9ebae48238
commit
7679506494
3 changed files with 111 additions and 8 deletions
34
lib/Traits/ApiObjectController.php
Normal file
34
lib/Traits/ApiObjectController.php
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace OCA\OrganizationFolders\Traits;
|
||||
|
||||
trait ApiObjectController {
|
||||
public const MODEL_INCLUDE = 'model';
|
||||
|
||||
/**
|
||||
* @param string $include
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function parseIncludesString(?string $include): array {
|
||||
if (isset($include)) {
|
||||
$includes = array_filter(explode('+', $include));
|
||||
|
||||
if (!!$includes) {
|
||||
return $includes;
|
||||
}
|
||||
}
|
||||
|
||||
return [self::MODEL_INCLUDE];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $test
|
||||
* @param array $includes
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function shouldInclude(string $test, array $includes): bool {
|
||||
return in_array($test, $includes);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue