Esempio n. 1
0
 /**
  * Creates a new instance of the class specified
  *
  * @example $mString = MObject::newInstanceOfClass(S("mango.system.MString"));
  * // $mString is a new instance of MString
  *
  * @param MString $className The fully qualified class name you wish to create an instance of
  *
  * @return MObject|mixed A new instance of the class specified by $className
  */
 public static function newInstanceOfClass(MString $className)
 {
     return MObject::newInstanceOfClassWithParameters($className);
 }
Esempio n. 2
0
 /**
  * This function needs to be called after creating your instance of MApplication.
  * This is the entry point for your application's execution
  *
  * When you call this function, the Mango environment parses all the information
  * it needs, sets itself up and boots up its classes
  *
  * This is also where routing occours. The system finds the controller class for
  * the specified URL and loads it
  *
  * The system takes care of handling top-level errors that may occur. For example,
  * if the URL requested by the user has no registered controllers, the system returns
  * a 404 View to the user and responds with the appropriate HTTP code.
  *
  * The same thing happens if an exception is thrown and not caught or if another error
  * occurs in the execution of your code. The system catches the error, outputs the
  * appropriate error information to the error log and returns an 500 Internal Server
  * Error view to the client
  *
  * @return void
  */
 public function run()
 {
     $response = null;
     $returnCode = 0;
     if ($this->isRunningFromCommandLine()) {
         $returnCode = $this->delegate()->didFinishLaunchingFromCommandLineWithArguments($this->commandLineArguments());
     } else {
         $viewController = null;
         try {
             $this->delegate()->didFinishLaunching();
             $viewController = $this->rootViewController();
         } catch (MBadRequestException $e) {
             logException($e);
             $viewController = MObject::newInstanceOfClassWithParameters($this->errorViewControllerClass(), A(MHTTPResponse::RESPONSE_BAD_REQUEST, N(MHTTPResponse::RESPONSE_BAD_REQUEST), S("Bad Request"), $e->description()));
         } catch (MException $e) {
             logException($e);
             $viewController = MObject::newInstanceOfClassWithParameters($this->errorViewControllerClass(), A(MHTTPResponse::RESPONSE_INTERNAL_SERVER_ERROR, N(MHTTPResponse::RESPONSE_INTERNAL_SERVER_ERROR), S("Internal Server Error"), S("Sorry but the page you are looking for could not be loaded due to an internal server error")));
         }
         if (!$viewController) {
             $viewController = MObject::newInstanceOfClassWithParameters($this->errorViewControllerClass(), A(MHTTPResponse::RESPONSE_NOT_FOUND, N(MHTTPResponse::RESPONSE_NOT_FOUND), S("Not Found"), S("Sorry but the page you are looking for could not be found")));
         }
         $response = new MHTTPViewControllerResponse($viewController);
     }
     MDie($response, $returnCode);
 }
 /**
  * Creates a new Managed Object instance with the class type specified by the entity
  *
  * This creates a new instance of an MManagedObject subclass specified in entity,
  * inserts it into this context and returns it.
  *
  * @param MEntityDescription $entity The entity to create a new instance of
  * @param int $objectID An optional ID to use for the object. This should only
  * be used when manullay constructing a representation of the object from the
  * data store.
  *
  * @return MManagedObject The new MManagedObject subclass instance
  */
 public function newObjectForEntity(MEntityDescription $entity, $objectID = MManagedObject::UNKNOWN_ID)
 {
     MAssertTypes('int', $objectID);
     return MObject::newInstanceOfClassWithParameters($entity->entityClassName(), A(array($entity, $this, $objectID)));
 }