/**
  * Creates a new MEntityProviderViewController instance
  *
  * Creates a new instance of the MEntityProviderViewController class which
  * you can use to serve your entities directly to your clients using
  * RESTful standards
  *
  * @param MEntityDescription $entity The entity you wish to create an interface for
  * @param MManagedObjectContext $context The Managed Object Context to connect this
  * entity provider to
  *
  * @return MEntityProviderViewController A new instance of the MEntityProviderViewController class
  */
 public function __construct(MEntityDescription $entity, MManagedObjectContext $context)
 {
     parent::__construct();
     $this->entity = $entity;
     $this->context = $context;
     $this->objectID = null;
     $this->predicate = null;
     $this->outputType = MEntityProviderViewController::OUTPUT_TYPE_XML;
     foreach ($entity->properties()->toArray() as $property) {
         if ($property->type() == MEntityDescriptionProperty::StringType) {
             $this->addFormField(new MFormViewControllerField($property->name(), MFormViewControllerField::StringType));
         } else {
             if ($property->type() == MEntityDescriptionProperty::IntegerType) {
                 $this->addFormField(new MFormViewControllerField($property->name(), MFormViewControllerField::IntegerType));
             } else {
                 if ($property->type() == MEntityDescriptionProperty::FloatType) {
                     $this->addFormField(new MFormViewControllerField($property->name(), MFormViewControllerField::FloatType));
                 } else {
                     if ($property->type() == MEntityDescriptionProperty::BooleanType) {
                         $this->addFormField(new MFormViewControllerField($property->name(), MFormViewControllerField::BooleanType));
                     } else {
                         if ($property->type() == MEntityDescriptionProperty::DateType) {
                             $this->addFormField(new MFormViewControllerField($property->name(), MFormViewControllerField::DateType));
                         } else {
                             if ($property->type() == MEntityDescriptionProperty::BinaryType) {
                                 $this->addFormField(new MFormViewControllerField($property->name(), MFormViewControllerField::BinaryType));
                             } else {
                                 throw new MManagedObjectException($object, Sf("Unknown attribute type '%s'", $attribute->type()));
                             }
                         }
                     }
                 }
             }
         }
     }
 }