Skip to content

Commit

Permalink
Merge pull request #49 from NotFoundNL/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
64knl authored Jul 17, 2023
2 parents 8b95d77 + 581f076 commit cfd3f5a
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 12 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"spatie/laravel-package-tools": "^1.14.0",
"spatie/laravel-honeypot": "^4.3.2",
"illuminate/contracts": "^10.0",
"notfoundnl/siteboss-layout": "^1.3.0",
"notfoundnl/siteboss-layout": "^1.4.1",
"mcamara/laravel-localization": "^1.8",
"xenolope/quahog": "^3.0",
"firebase/php-jwt": "^6.3",
Expand Down
25 changes: 24 additions & 1 deletion config/siteboss.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,28 @@
//this file is published by the siteboss-framework package

return [
'api_prefix' => env('API_PREFIX', '/siteboss/api'),
/*
|--------------------------------------------------------------------------
| SiteBoss® API prefix
|--------------------------------------------------------------------------
|
| Here you may specify the prefix for the calls made by the SiteBoss®
| framework to the API. There is no need to change this unless you
| are using a different API prefix for your application.
|
*/

'api_prefix' => env('SITEBOSS_BACKEND_API_PREFIX', '/siteboss/api'),

/*
|--------------------------------------------------------------------------
| API prefix
|--------------------------------------------------------------------------
|
| All calls in routes/api.php will be prefixed with this value.
|
*/

'frontend_api_prefix' => env('SITEBOSS_FRONTEND_API_PREFIX', 'api'),

];
50 changes: 50 additions & 0 deletions src/Helpers/LayoutInputDropdownHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace NotFound\Framework\Helpers;

use NotFound\Framework\Models\BaseModel;
use NotFound\Framework\Models\LegacyModel;
use NotFound\Layout\Inputs\LayoutInputDropdown;

class LayoutInputDropdownHelper
{
public LayoutInputDropdown $dropdown;

/**
* Easily create a dropdown based on a model
*
* @param $model Model to be queried
* @param $label Label for the dropdown
* @param $internal defaults to $model table name + '_id'
* @param $tableColumnName The column name of site table to get the readable name from
* @param $value default value for the dropdown
*/
public function __construct(
protected BaseModel|LegacyModel $model,
protected string $label = '',
protected ?string $internal = null,
protected string $tableColumnName = 'title',
protected mixed $value = null,
protected bool $disabled = false,
protected bool $required = false,
) {
if ($internal === null) {
$internal = $model->getTable().'_id';
}

$this->dropdown = new LayoutInputDropdown($internal, $label);
$this->dropdown->setDisabled($disabled);
$this->dropdown->setRequired($required);

foreach ($this->model->whereStatus('PUBLISHED')->get() as $modelItem) {
$this->dropdown->addItem(
$modelItem->{$this->model->getKeyName()},
$modelItem->{$tableColumnName}
);
}

if ($value !== null) {
$this->dropdown->setValue($value);
}
}
}
6 changes: 3 additions & 3 deletions src/Providers/Auth/OpenIDUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@ public function __construct(CmsUser $userModel)
*
* @param mixed $identifier
*/
public function retrieveById($identifier): Authenticatable|null
public function retrieveById($identifier): ?Authenticatable
{
return $this->model->where('enabled', true)->where('sub', $identifier)->first();
}

/**
* Retrieve a user by their e-mail address.
*/
public function retrieveByEmail(string $email): CmsUser|null
public function retrieveByEmail(string $email): ?CmsUser
{
return $this->model->where('email', $email)->first();
}

private function getEmailFromToken(object $token): null|string
private function getEmailFromToken(object $token): ?string
{
$mailClaim = config('openid.mail_claim');
if (! isset($token->$mailClaim)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function boot()
// Optionally load API routes
if (file_exists(base_path('routes/api.php'))) {
Route::middleware('api')
->prefix('api')
->prefix(config('siteboss.frontend_api_prefix'))
->group(base_path('routes/api.php'));
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Assets/AbstractAssetService.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function getLang(): Lang
/**
* Loops through all the table items and return them with the appropriate Input Class
*/
public function getFieldComponents(?int $recordId = null): Collection
public function getFieldComponents(int $recordId = null): Collection
{
$items = $this->assetModel->items()->where('enabled', 1)->orderBy('order')->get();

Expand Down
2 changes: 1 addition & 1 deletion src/Services/Assets/GlobalPageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected function getCacheKey(): string
/**
* Loops through all the table items and return them with the appropriate Input Class
*/
public function getFieldComponents(?int $recordId = null): Collection
public function getFieldComponents(int $recordId = null): Collection
{
$templateItems = TemplateItem::where('enabled', 1)
->where('global', 1)
Expand Down
8 changes: 4 additions & 4 deletions src/Services/Forms/UserDataTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,25 @@ class UserDataTransformer
* this array is an array of field ids. Populating this array will allow the function 'getDataArray' to dynamically fill
* array and remain the same order everytime. This also makes old data submitted to have the same headers as new data submitted.
*/
private array $headerIdArray = [];
private array $headerIdArray = [];

/**
* sometimes we don't want to return certain types. For example when exporting a csv. We don't want to show
* the files since a csv can't do anything with them.
*/
private array $ignoredTypes = [];
private array $ignoredTypes = [];

/**
* This array can be used to ignore certain ids. For example it is now used to either display deleted items or not.
*/
private array $filterIds = [];
private array $filterIds = [];

/**
* Contains all the \nfapi\formbuilder\fields\AbstractType fields based on their id.
*
* @var asspctiative array
*/
private array $idToTypeClass = [];
private array $idToTypeClass = [];

/**
* This will be set when the class is called. Mainly to chenge how the data is outputted.
Expand Down

0 comments on commit cfd3f5a

Please sign in to comment.