예제 #1
0
 /**
  * Generate the SDK
  */
 public function generate()
 {
     $this->printMessage("");
     $this->printMessage('Creating Models, Controllers, Requests, Responses, and Exceptions');
     /**
      * @var string $name
      * @var Config $entity
      */
     foreach ($this->config->apis as $version => $api) {
         $this->printMessage($version . '...');
         foreach ($api as $entityName => $entity) {
             $entity = $this->vaidateEntityConfig($entityName, $entity);
             Files::initializeFolders($version, $entityName);
             if (isset($entity->model)) {
                 // Models
                 Files::saveModel(new ModelGenerator($version, $entityName, $entity->model->columns));
                 // Responses
                 Files::saveResponse(new ResponseGenerator($version, $entityName, $entity->model->columns));
             }
             // Exceptions
             $exceptions = $this->getExceptionsFromEntityConfig($entity);
             foreach ($exceptions as $exception) {
                 Files::saveException(new ExceptionGenerator($version, $entityName, $exception->exception, $exception->message, $exception->extends));
             }
             // Controllers
             Files::saveController(new ControllerGenerator($version, $entityName, $entity));
         }
     }
     $this->printMessage("All done, Remember to add the files to VCS!");
 }
예제 #2
0
 /**
  * Generate the SDK
  */
 public function generate()
 {
     $this->printMessage('');
     $this->printMessage('Creating Collection config');
     Files::saveCollectionConfig((new ConfigGenerator($this->config))->create());
     $this->printMessage('Creating Models, Controllers, Requests, Responses, and Exceptions');
     /**
      * @var string $name
      * @var Config $entity
      */
     foreach ($this->config->versions as $version => $api) {
         $requests = [];
         $this->printMessage($version . '...');
         foreach ($api as $entityName => $entity) {
             $entity = $this->vaidateEntityConfig($entityName, $entity);
             Files::initializeFolders($version, $entityName);
             if (isset($entity->model)) {
                 $columns = $entity->model->columns;
                 // Models
                 Files::saveModel(new ModelGenerator($version, $entityName, $columns));
                 // Requests
                 foreach ($entity->requests as $requestMethod => $actions) {
                     foreach ($actions as $actionName => $action) {
                         if (empty($action)) {
                             continue;
                         }
                         $requests[] = Files::saveRequest(new RequestGenerator($version, $entityName, $entity->model, $requestMethod, $actionName, $action));
                     }
                 }
                 // Responses
                 Files::saveResponse(new ResponseGenerator($version, $entityName, $columns));
             }
             // Exceptions
             $exceptions = $this->getExceptionsFromEntityConfig($entity);
             foreach ($exceptions as $exception) {
                 Files::saveException(new ExceptionGenerator($version, $entityName, $exception));
             }
             // Controllers
             Files::saveController(new ControllerGenerator($version, $entityName, $entity));
         }
         Files::saveSDK(new SDKGenerator($version, $this->config->name, $requests));
     }
     $this->printMessage("All done, Remember to add the files to VCS!");
 }