-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
[Core] Provide Schema Loaders for supporting different Formats #115
Comments
This is what a JSON Format would look like: {
"name": "news",
"fields": {
"id": {
"type": "id"
},
"title": {
"type": "text"
},
"header": {
"type": "typed",
"typeField": "type",
"types": {
"image": {
"media": {
"type": "integer"
}
},
"video": {
"media": {
"type": "string",
"searchable": false
}
},
}
},
"article": {
"type": "text"
},
"blocks": {
"type": "typed",
"typeField": "type",
"types": {
"text": {
"title": {
"type": "text"
},
"description": {
"type": "text"
},
"media": {
"type": "integer",
"multiple": true
}
},
"embed": {
"title": {
"type": "text"
}
"embed": {
"type": "text",
"searchable": false
}
}
}
},
"footer": {
"type": "object",
"fields": {
"title": {
"type": "text"
}
}
},
"created": {
"type": "date"
},
"rating": {
"type": "integer",
"sortable": true
},
"commentsCount": {
"type": "integer"
},
"comments": {
"type": "object",
"fields": {
"email": {
"type": "text",
"searchable": false
},
"text": {
"type": "text"
},
}
},
"tags": {
"type": "text",
"multiple": true
},
"categoryIds": {
"type": "integer",
"multiple": true,
"filterable": true
}
}
} |
This is what a XML Format would look like: <index name="news">
<id name="id" />
<text name="title" />
<typed name="header" type-field="type">
<type name="image">
<integer name="media" />
</type>
<type name="video">
<text name="media" />
</type>
</typed>
<text name="article" />
<typed name="blocks" type-field="type">
<type name="image">
<text name="title" />
<text name="description" />
<integer name="media" multiple="true" />
</type>
<type name="embed">
<text name="title" />
<text name="media" searchable="false" />
</type>
</typed>
<object name="footer">
<text name="title" />
</object>
<integer name="commentsCount" />
<integer name="rating" sortable="true" />
<object name="comments" multiple="true">
<text name="email" searchable="false" />
<text name="text" />
</object>
<text name="tags" multiple="true" filterable="true" />
<integer name="categoryIds" multiple="true" filterable="true" />
</index> |
The PHP classes could also in future be used as attributes for the ODM #81 implementation: <?php
use Schranz\Search\SEAL\Schema\Field;
use Schranz\Search\SEAL\Schema\Index;
#[Index(name: 'page')]
class Page {
#[Field\IdentifierField('id')]
private string $id;
#[Field\TextField('title')]
private string $title;
#[Field\TypedField('header', 'type', [
'image' => [
'media' => new Field\IntegerField('media'),
],
'video' => [
'media' => new Field\TextField('media', searchable: false),
],
])]
private array $header;
// ...
} |
alexander-schranz
changed the title
Provide Schema Loaders for supporting different Formats
[Core] Provide Schema Loaders for supporting different Formats
May 10, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The Schema is currently created via PHP but maybe like in doctrine it make sense to create a Schema via other Formats like
XML
,YAML
,JSON
?Current PHP Schema:
Which other formats should be supported:
Is the
Core
responsible for this formats or should the Core not care about additional Formats and Example the Symfony Bundle could us Symfony configuration tree instead, which out of the box supports Yaml, Xml, PHP Array, PHP Builder configuration.But that would mean the definition would be framework specific, so own Schema Loaders which are not Framework specific maybe would make sense.
Maybe also other formats as the current PHP representation are not required?
In doctrine
DBAL
is also not responsible for this formats theORM
provide something so maybe theSEAL CORE
should also not handle different formats or Schema Loaders, and maybe a future ODM would handle that, but that is another Ticket #81.What also should be keep in mind does providing different formats improve a better developer experience or even hurt it as some answers to stackoverflow, github discussions, ... are written in just one format and not in another.
The text was updated successfully, but these errors were encountered: