Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Remove dbal requirement #225

Merged
merged 5 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Http/Controllers/CmsEditor/CmsEditorTableController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace NotFound\Framework\Http\Controllers\CmsEditor;

use Illuminate\Http\Request as HttpRequest;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use NotFound\Framework\Http\Requests\FormDataRequest;
use NotFound\Framework\Models\Table;
Expand Down Expand Up @@ -323,7 +322,9 @@ private function checkColumn(string $table, object $field): string
$fieldClass = new $className(new stdClass());

if (Schema::hasColumn($table, $field->internal)) {
return $fieldClass->checkColumnType(DB::getDoctrineColumn($this->setDatabasePrefix($table), $field->internal)->getType());
return $fieldClass->checkColumnType(
Schema::getColumnType($table, $field->internal)
);
} else {
return $fieldClass->checkColumnType(null);
}
Expand Down
7 changes: 0 additions & 7 deletions src/Services/Assets/Components/ComponentText.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,6 @@ protected function customProperties(): object
$customProperties['editorSettings'] = json_decode($setting->settings);
}
}
if (
$this->assetItem->properties->type == 'richtext' &&
isset($this->assetItem->server_properties->editModal) &&
$this->assetItem->server_properties->editModal === true
) {
$customProperties['editModal'] = true;
}

return (object) $customProperties;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Editor/Fields/Button.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function serverProperties(): void
{
}

public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string
public function checkColumnType(?string $type): string
{
return '';
}
Expand Down
6 changes: 3 additions & 3 deletions src/Services/Editor/Fields/Checkbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ public function serverProperties(): void
{
}

public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string
public function checkColumnType(?string $type): string
{
if ($type === null) {
return 'COLUMN MISSING';
}

if (! in_array($type->getName(), ['tinyint', 'boolean'])) {
return 'TYPE ERROR: '.$type->getName().' is not a valid type for a text field';
if (! in_array($type, ['tinyint', 'int', 'boolean'])) {
return 'TYPE ERROR: '.$type.' is not a valid type for a text field';
}

return '';
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Editor/Fields/ChildTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected function rename(): array
];
}

public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string
public function checkColumnType(?string $type): string
{
if ($type !== null) {
return 'COLUMN NOT NEEDED';
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Editor/Fields/ContentBlocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function serverProperties(): void

}

public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string
public function checkColumnType(?string $type): string
{
if ($type !== null) {
return 'COLUMN NOT NEEDED';
Expand Down
10 changes: 5 additions & 5 deletions src/Services/Editor/Fields/DatePicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ protected function rename(): array
];
}

public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string
public function checkColumnType(?string $type): string
{
if ($type === null) {
return 'COLUMN MISSING';
}
if ($type->getName() === 'int') {
return 'TYPE WARNING: '.$type->getName().' should be converted to datetime';
if ($type === 'int') {
return 'TYPE WARNING: '.$type.' should be converted to datetime';
}

if ($type->getName() !== 'datetime') {
return 'TYPE ERROR: '.$type->getName().' is not a valid type for a date field';
if ($type !== 'datetime') {
return 'TYPE ERROR: '.$type.' is not a valid type for a date field';
}

return '';
Expand Down
6 changes: 3 additions & 3 deletions src/Services/Editor/Fields/DateTimePicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ public function serverProperties(): void
{
}

public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string
public function checkColumnType(?string $type): string
{
if ($type === null) {
return 'COLUMN MISSING';
}
if (! in_array($type->getName(), ['datetime'])) {
return 'TYPE ERROR: '.$type->getName().' is not a valid type for a date field';
if (! in_array($type, ['datetime'])) {
return 'TYPE ERROR: '.$type.' is not a valid type for a date field';
}

return '';
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Editor/Fields/Description.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function serverProperties(): void
{
}

public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string
public function checkColumnType(?string $type): string
{

return '';
Expand Down
3 changes: 1 addition & 2 deletions src/Services/Editor/Fields/DropDown.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace NotFound\Framework\Services\Editor\Fields;

use Doctrine\DBAL\Types\Type;
use NotFound\Framework\Services\Editor\Properties;
use NotFound\Framework\Services\Editor\Repeatable;
use stdClass;
Expand Down Expand Up @@ -30,7 +29,7 @@ public function serverProperties(): void
{
}

public function checkColumnType(?Type $type): string
public function checkColumnType(?string $type): string
{
if ($type === null) {
return 'COLUMN MISSING';
Expand Down
6 changes: 3 additions & 3 deletions src/Services/Editor/Fields/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ public function serverProperties(): void
{
}

public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string
public function checkColumnType(?string $type): string
{
if ($type === null) {
return 'COLUMN MISSING';
}

if (! in_array($type->getName(), ['string'])) {
return 'TYPE ERROR: '.$type->getName().' is not a valid type for a text field';
if (! in_array($type, ['varchar'])) {
return 'TYPE ERROR: '.$type.' is not a valid type for a text field';
}

return '';
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Editor/Fields/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function serverProperties(): void
{
}

public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string
public function checkColumnType(?string $type): string
{
return '';
}
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Editor/Fields/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function serverProperties(): void
{
}

public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string
public function checkColumnType(?string $type): string
{
return '';
}
Expand Down
3 changes: 1 addition & 2 deletions src/Services/Editor/Fields/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace NotFound\Framework\Services\Editor\Fields;

use Doctrine\DBAL\Types\Type;
use NotFound\Framework\Services\Editor\Properties;
use NotFound\Framework\Services\Editor\Repeatable;
use stdClass;
Expand Down Expand Up @@ -36,7 +35,7 @@ public function serverProperties(): void
$this->addCheckbox('createPNG', 'Create PNG');
}

public function checkColumnType(?Type $type): string
public function checkColumnType(?string $type): string
{
if ($type === null) {
return 'COLUMN MISSING';
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Editor/Fields/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function serverProperties(): void
{
}

public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string
public function checkColumnType(?string $type): string
{
if ($type === null) {
return 'COLUMN MISSING';
Expand Down
6 changes: 3 additions & 3 deletions src/Services/Editor/Fields/ModelSelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ public function serverProperties(): void
$this->addText('methodName', 'Method', true);
}

public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string
public function checkColumnType(?string $type): string
{
if ($type === null) {
return 'COLUMN MISSING';
}
if (! in_array($type->getName(), ['string', 'integer'])) {
return 'TYPE ERROR: '.$type->getName().' is not a valid type for a table select field';
if (! in_array($type, ['varchar', 'int'])) {
return 'TYPE ERROR: '.$type.' is not a valid type for a table select field';
}

return '';
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Editor/Fields/Number.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function serverProperties(): void
{
}

public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string
public function checkColumnType(?string $type): string
{
if ($type === null) {
return 'COLUMN MISSING';
Expand Down
6 changes: 3 additions & 3 deletions src/Services/Editor/Fields/Slug.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ public function serverProperties(): void
$this->addText('source', 'Source field internal name', false);
}

public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string
public function checkColumnType(?string $type): string
{
if ($type === null) {
return 'COLUMN MISSING';
}
if (! in_array($type->getName(), ['string'])) {
return 'TYPE ERROR: '.$type->getName().' is not a valid type for a slug field';
if (! in_array($type, ['varchar'])) {
return 'TYPE ERROR: '.$type.' is not a valid type for a slug field';
}

return '';
Expand Down
6 changes: 3 additions & 3 deletions src/Services/Editor/Fields/TableSelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ protected function rename(): array
];
}

public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string
public function checkColumnType(?string $type): string
{
if ($type === null) {
return 'COLUMN MISSING';
}
if (! in_array($type->getName(), ['string', 'integer'])) {
return 'TYPE ERROR: '.$type->getName().' is not a valid type for a table select field';
if (! in_array($type, ['int', 'tinyint', 'varchar'])) {
return 'TYPE ERROR: '.$type.' is not a valid type for a table select field';
}

return '';
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Editor/Fields/Tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected function rename(): array
];
}

public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string
public function checkColumnType(?string $type): string
{
if ($type !== null) {
return 'COLUMN NOT NEEDED';
Expand Down
8 changes: 4 additions & 4 deletions src/Services/Editor/Fields/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public function properties(): void
(object) ['value' => 'richtext', 'label' => 'Rich Text'],
]);
$this->addNumber('maxlength', 'Maximum length');
$this->addCheckbox('editModal', 'Edit texts in popup (required for ContentBlock/Childtable)');
}

public function serverProperties(): void
Expand All @@ -36,7 +37,6 @@ public function serverProperties(): void
$this->addDropDown('editorSettings', 'Editor settings (for rich text editor)', $options);
// BUG: TODO: editModal should just be a property,
// not a server property
$this->addCheckbox('editModal', 'Edit texts in popup (required for ContentBlock/Childtable)');
$this->addTitle('Validation');

$this->addDropDown('regExTemplate', 'Built in validations', [
Expand All @@ -54,13 +54,13 @@ public function rename(): array
return ['texttype' => 'type'];
}

public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string
public function checkColumnType(?string $type): string
{
if ($type === null) {
return 'COLUMN MISSING';
}
if (! in_array($type->getName(), ['string', 'text'])) {
return 'TYPE ERROR: '.$type->getName().' is not a valid type for a text field';
if (! in_array($type, ['varchar', 'text'])) {
return 'TYPE ERROR: '.$type.' is not a valid type for a text field';
}

return '';
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Editor/Properties.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ abstract public function serverProperties(): void;

abstract public function description(): string;

abstract public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string;
abstract public function checkColumnType(?string $type): string;

protected function addText($property_name, $display_name, $required = false, $default = null)
{
Expand Down
4 changes: 1 addition & 3 deletions src/Services/Editor/Repeatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace NotFound\Framework\Services\Editor;

use Doctrine\DBAL\Types\Type;

class Repeatable extends Properties
{
public function description(): string
Expand All @@ -19,7 +17,7 @@ public function serverProperties(): void
{
}

public function checkColumnType(?Type $type): string
public function checkColumnType(?string $type): string
{
trigger_error('This should never be called', E_USER_ERROR);

Expand Down
Loading