Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/development' into feature/PC108-…
Browse files Browse the repository at this point in the history
…73/no-customer-before-search
  • Loading branch information
Sudo-Thijn committed Dec 31, 2024
2 parents 4ec66ee + ab784ee commit f564027
Show file tree
Hide file tree
Showing 59 changed files with 27,998 additions and 25,646 deletions.
15 changes: 9 additions & 6 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,14 @@
['name' => 'settings#create', 'url' => '/settings', 'verb' => 'POST'],
// User
['name' => 'users#me', 'url' => '/me', 'verb' => 'GET'],
['name' => 'objects#index', 'url' => '/api/objects/{_objectType}', 'verb' => 'GET', 'requirements' => ['_objectType' => '[^/]+']],
['name' => 'objects#show', 'url' => '/api/objects/{_objectType}/{id}', 'verb' => 'GET', 'requirements' => ['_objectType' => '[^/]+', 'id' => '[^/]+']],
['name' => 'objects#getAuditTrail', 'url' => '/api/objects/{_objectType}/{id}/audit_trail', 'verb' => 'GET', 'requirements' => ['_objectType' => '[^/]+', 'id' => '[^/]+']],
['name' => 'objects#create', 'url' => '/api/objects/{_objectType}', 'verb' => 'POST', 'requirements' => ['_objectType' => '[^/]+', 'id' => '[^/]+']],
['name' => 'objects#update', 'url' => '/api/objects/{_objectType}/{id}', 'verb' => 'PUT', 'requirements' => ['_objectType' => '[^/]+', 'id' => '[^/]+']],
['name' => 'objects#destroy', 'url' => '/api/objects/{_objectType}/{id}', 'verb' => 'DELETE', 'requirements' => ['_objectType' => '[^/]+', 'id' => '[^/]+']]
// Object API routes
['name' => 'objects#index', 'url' => 'api/objects/{objectType}', 'verb' => 'GET'],
['name' => 'objects#create', 'url' => 'api/objects/{objectType}', 'verb' => 'POST'],
['name' => 'objects#show', 'url' => 'api/objects/{objectType}/{id}', 'verb' => 'GET'],
['name' => 'objects#update', 'url' => 'api/objects/{objectType}/{id}', 'verb' => 'PUT'],
['name' => 'objects#delete', 'url' => 'api/objects/{objectType}/{id}', 'verb' => 'DELETE'],
['name' => 'objects#getAuditTrail', 'url' => 'api/objects/{objectType}/{id}/audit', 'verb' => 'GET'],
['name' => 'objects#getRelations', 'url' => 'api/objects/{objectType}/{id}/relations', 'verb' => 'GET'],
['name' => 'objects#getUses', 'url' => 'api/objects/{objectType}/{id}/uses', 'verb' => 'GET']
]
];
344 changes: 172 additions & 172 deletions lib/Controller/ContactMomentenController.php
Original file line number Diff line number Diff line change
@@ -1,172 +1,172 @@
<?php

namespace OCA\ZaakAfhandelApp\Controller;

use OCA\ZaakAfhandelApp\Service\ObjectService;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\JSONResponse;
use OCP\IRequest;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Http\ContentSecurityPolicy;

/**
* Controller for handling contact moments (contactmomenten) operations
*/
class ContactMomentenController extends Controller
{
public function __construct(
$appName,
IRequest $request,
private readonly ObjectService $objectService,
)
{
parent::__construct($appName, $request);
}

/**
* Return (and search) all contact moments
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @return JSONResponse
*/
public function index(): JSONResponse
{
// Retrieve all request parameters
$requestParams = $this->request->getParams();

// Fetch contact moments based on filters and order
$data = $this->objectService->getResultArrayForRequest('contactmomenten', $requestParams);

// Return JSON response
return new JSONResponse($data);
}

/**
* Render no page.
*
* @param string|null $getParameter Optional GET parameter
* @return TemplateResponse The rendered template response
*
* @NoAdminRequired
* @NoCSRFRequired
*/
public function page(?string $getParameter): TemplateResponse
{
try {
// Create a new TemplateResponse for the index page
$response = new TemplateResponse(
$this->appName,
'index',
[]
);

// Set up Content Security Policy
$csp = new ContentSecurityPolicy();
$csp->addAllowedConnectDomain('*');
$response->setContentSecurityPolicy($csp);

return $response;
} catch (\Exception $e) {
// Return an error template response if an exception occurs
return new TemplateResponse(
$this->appName,
'error',
['error' => $e->getMessage()],
'500'
);
}
}

/**
* Read a single contact moment
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @return JSONResponse
*/
public function show(string $id): JSONResponse
{
// Fetch the contact moment by its ID
$object = $this->objectService->getObject('contactmomenten', $id);

// Return the contact moment as a JSON response
return new JSONResponse($object);
}

/**
* Create a contact moment
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @return JSONResponse
*/
public function create(): JSONResponse
{
// Get all parameters from the request
$data = $this->request->getParams();

// Remove the 'id' field if it exists, as we're creating a new contact moment
unset($data['id']);

// Save the new contact moment
$object = $this->objectService->saveObject('contactmomenten', $data);

// Return the created contact moment as a JSON response
return new JSONResponse($object);
}

/**
* Update a contact moment
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @return JSONResponse
*/
public function update(string $id): JSONResponse
{
// Get all parameters from the request
$data = $this->request->getParams();

// Save the updated contact moment
$object = $this->objectService->saveObject('contactmomenten', $data);

// Return the updated contact moment as a JSON response
return new JSONResponse($object);
}

/**
* Delete a contact moment
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @return JSONResponse
*/
public function destroy(string $id): JSONResponse
{
// Delete the contact moment
$result = $this->objectService->deleteObject('contactmomenten', $id);

// Return the result as a JSON response
return new JSONResponse(['success' => $result], $result === true ? '200' : '404');
}

/**
* Get audit trail for a specific contact moment
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @return JSONResponse
*/
public function getAuditTrail(string $id): JSONResponse
{
$auditTrail = $this->objectService->getAuditTrail('contactmomenten', $id);
return new JSONResponse($auditTrail);
}
}
<?php

namespace OCA\ZaakAfhandelApp\Controller;

use OCA\ZaakAfhandelApp\Service\ObjectService;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\JSONResponse;
use OCP\IRequest;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Http\ContentSecurityPolicy;

/**
* Controller for handling contact moments (contactmomenten) operations
*/
class ContactMomentenController extends Controller
{
public function __construct(
$appName,
IRequest $request,
private readonly ObjectService $objectService,
)
{
parent::__construct($appName, $request);
}

/**
* Return (and search) all contact moments
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @return JSONResponse
*/
public function index(): JSONResponse
{
// Retrieve all request parameters
$requestParams = $this->request->getParams();

// Fetch contact moments based on filters and order
$data = $this->objectService->getResultArrayForRequest('contactmomenten', $requestParams);

// Return JSON response
return new JSONResponse($data);
}

/**
* Render no page.
*
* @param string|null $getParameter Optional GET parameter
* @return TemplateResponse The rendered template response
*
* @NoAdminRequired
* @NoCSRFRequired
*/
public function page(?string $getParameter): TemplateResponse
{
try {
// Create a new TemplateResponse for the index page
$response = new TemplateResponse(
$this->appName,
'index',
[]
);

// Set up Content Security Policy
$csp = new ContentSecurityPolicy();
$csp->addAllowedConnectDomain('*');
$response->setContentSecurityPolicy($csp);

return $response;
} catch (\Exception $e) {
// Return an error template response if an exception occurs
return new TemplateResponse(
$this->appName,
'error',
['error' => $e->getMessage()],
'500'
);
}
}

/**
* Read a single contact moment
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @return JSONResponse
*/
public function show(string $id): JSONResponse
{
// Fetch the contact moment by its ID
$object = $this->objectService->getObject('contactmomenten', $id);

// Return the contact moment as a JSON response
return new JSONResponse($object);
}

/**
* Create a contact moment
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @return JSONResponse
*/
public function create(): JSONResponse
{
// Get all parameters from the request
$data = $this->request->getParams();

// Remove the 'id' field if it exists, as we're creating a new contact moment
unset($data['id']);

// Save the new contact moment
$object = $this->objectService->saveObject('contactmomenten', $data);

// Return the created contact moment as a JSON response
return new JSONResponse($object);
}

/**
* Update a contact moment
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @return JSONResponse
*/
public function update(string $id): JSONResponse
{
// Get all parameters from the request
$data = $this->request->getParams();

// Save the updated contact moment
$object = $this->objectService->saveObject('contactmomenten', $data);

// Return the updated contact moment as a JSON response
return new JSONResponse($object);
}

/**
* Delete a contact moment
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @return JSONResponse
*/
public function destroy(string $id): JSONResponse
{
// Delete the contact moment
$result = $this->objectService->deleteObject('contactmomenten', $id);

// Return the result as a JSON response
return new JSONResponse(['success' => $result], $result === true ? '200' : '404');
}

/**
* Get audit trail for a specific contact moment
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @return JSONResponse
*/
public function getAuditTrail(string $id): JSONResponse
{
$auditTrail = $this->objectService->getAuditTrail('contactmomenten', $id);
return new JSONResponse($auditTrail);
}
}
Loading

0 comments on commit f564027

Please sign in to comment.