src/Generator.php
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!");
  }
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!");
  }
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!" ) ; }
Generate the SDK
Generate the SDK