|
Entities
EntitiesWhat is an entity?An entity is a persistent Actionscript object - that is to say an object which is capable of being loaded and saved to the database using Flextrine. Entities are defined in PHP within your Flextrine server-side component, and then their matching AS3 classes are generated using the Flextrine Manager. Writing entitiesEntities are defined in Doctrine 2 docblock annotation format, so read the documentation at Basic Mapping and Association Mapping for specific details. A basic entity looks something like this: <?php
namespace vo;
/**
* @Entity
*/
class Doctor {
/** @Id @Column(type="integer") @GeneratedValue(strategy="IDENTITY") */
public $id;
/** @Column(length=100, type="string") */
public $name;
}
?>All properties must be publicAll persistent properties in your entity must be public. This actually goes against Doctrine 2 best practices, but is necessary for Flextrine to work. Don't use fetch="eager"Flextrine itself takes care of eager and lazy loading so you shouldn't ever use fetch="eager" on your association. At best it will have no effect, and at worse could cause unexpected behaviour. Cascades don't affect FlextrineUsing Doctrine cascades in your associations has no effect on Flextrine. In fact, Flextrine will disable the cascades before performing operations, then reset them to their original values afterwards. AS3 Generated EntitiesWhen you generate the matching AS3 entities using Flextrine manager, two classes are created for each entity - in our example vo.DoctorEntityBase and vo.Doctor will be created. The DoctorEntityBase is the parent of Doctor, and contains the bits that make Flextrine go. There are two classes for each entity rather than one so that you can regenerate entities without losing any extra application logic you may have placed in the main entity class. |