https://wiki.partkeepr.org/index.php?title=Developers/Entities&feed=atom&action=history
Developers/Entities - Revision history
2024-03-28T17:38:15Z
Revision history for this page on the wiki
MediaWiki 1.31.0
https://wiki.partkeepr.org/index.php?title=Developers/Entities&diff=303&oldid=prev
Felicitus at 15:59, 4 November 2015
2015-11-04T15:59:29Z
<p></p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #222; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #222; text-align: center;">Revision as of 15:59, 4 November 2015</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l50" >Line 50:</td>
<td colspan="2" class="diff-lineno">Line 50:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>The ExtJS entity generator then puts additional fields in the resulting model file.</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>The ExtJS entity generator then puts additional fields in the resulting model file.</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">= Frontend Object Handling =</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">In the ExtJS frontend, you can create objects as you usually would in PHP code. You can even create objects with associations and send them to the REST API in one go.</ins></div></td></tr>
<!-- diff cache key partkeepr_wiki:diff::1.12:old-302:rev-303 -->
</table>
Felicitus
https://wiki.partkeepr.org/index.php?title=Developers/Entities&diff=302&oldid=prev
Felicitus: Created page with "= Introduction = PartKeepr uses [http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/working-with-objects.html Doctrine Entities] to map PHP objects to..."
2015-11-04T15:41:12Z
<p>Created page with "= Introduction = PartKeepr uses [http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/working-with-objects.html Doctrine Entities] to map PHP objects to..."</p>
<p><b>New page</b></p><div>= Introduction =<br />
<br />
PartKeepr uses [http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/working-with-objects.html Doctrine Entities] to map PHP objects to the database.<br />
<br />
No manual database queries are required - all queries are handled by Doctrine. Custom queries must be written using [http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/dql-doctrine-query-language.html DQL], the Doctrine Query Language.<br />
<br />
= Creating new entities and registering it with the REST API =<br />
<br />
In order to create a new entity, simply create an entity file as per Doctrine documentation. Then you need to register a Dunglas API resource in the '''app/config/config_partkeepr.yml''' file:<br />
<br />
{{note|This is an example and the resource definition entry might change. Refer to the '''config_partkeepr.yml''' for up-to-date examples.}}<br />
<pre><br />
resource.part_manufacturer:<br />
parent: "api.resource"<br />
arguments: [ "PartKeepr\\PartBundle\\Entity\\PartManufacturer" ]<br />
tags: [ { name: "api.resource" } ]<br />
calls:<br />
- method: "initNormalizationContext"<br />
arguments: [ { groups: [ "default" ] } ]<br />
- method: "initDenormalizationContext"<br />
arguments:<br />
- { groups: [ "default" ] }<br />
</pre><br />
<br />
= ExtJS Model Syncing =<br />
<br />
The PartKeepr frontend uses [https://www.sencha.com/products/extjs/ ExtJS], a full-stack JavaScript framework. ExtJS allows PartKeepr to operate on entities (called models in ExtJS) and relations. PartKeepr generates the ExtJS Model files for you.<br />
<br />
This means that if you create or change any Doctrine Entity, you need to execute the following command:<br />
<br />
<pre><br />
php app/console generate:extjs:entities<br />
</pre><br />
<br />
That command extracts all fields and relations from your entity and generates a model file.<br />
<br />
== Virtual Fields ==<br />
<br />
Sometimes you need to pass fields over the REST API which shouldn't persisted to the database. For that purpose, you can use the '''@VirtualField''' annotation on any property:<br />
<br />
<pre><br />
class MyEntity<br />
{<br />
/**<br />
* @VirtualProperty(type="string")<br />
*/<br />
protected $myVirtualField;<br />
}<br />
</pre><br />
<br />
The ExtJS entity generator then puts additional fields in the resulting model file.</div>
Felicitus