Browse Source

Remove continue_without_database_transactions

shalvah 4 years ago
parent
commit
8cff8047e0

+ 2 - 1
CHANGELOG.md

@@ -19,4 +19,5 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
 - Endpoints in views are now objects
 - Endpoints in views are now objects
 - moved body-parameters to components
 - moved body-parameters to components
 - index renamed to intro.blade.php
 - index renamed to intro.blade.php
-- views moved to markdown/
+- views moved to markdown/
+- Removed continue_without_database_transactions

+ 0 - 7
config/scribe.php

@@ -361,13 +361,6 @@ INTRO
      */
      */
     'routeMatcher' => \Knuckles\Scribe\Matching\RouteMatcher::class,
     'routeMatcher' => \Knuckles\Scribe\Matching\RouteMatcher::class,
 
 
-    /**
-     * [Advanced] If one of your app's database drivers does not support transactions,
-     * docs generation (instantiating Eloquent models and making response calls) will likely fail.
-     * To avoid that, you can add the driver class name here. Be warned: that means all database changes will persist.
-     */
-    'continue_without_database_transactions' => [],
-
     /**
     /**
      * For response calls, api resource responses and transformer responses, Scribe will try to start database transactions, so no changes are persisted to your database.
      * For response calls, api resource responses and transformer responses, Scribe will try to start database transactions, so no changes are persisted to your database.
      * Tell Scribe which connections should be transacted here. If you only use the default db connection, you can leave this as is.
      * Tell Scribe which connections should be transacted here. If you only use the default db connection, you can leave this as is.

+ 2 - 16
docs/config.md

@@ -247,25 +247,11 @@ The route matcher class provides the algorithm that determines what routes shoul
 ### `database_connections_to_transact`
 ### `database_connections_to_transact`
 Scribe tries to run response calls and example model creation (API Resource and Transformer strategies) in a database transaction, and then roll it back so no changes are persisted. This item is where you specify which connections Scribe should run in transactions for.
 Scribe tries to run response calls and example model creation (API Resource and Transformer strategies) in a database transaction, and then roll it back so no changes are persisted. This item is where you specify which connections Scribe should run in transactions for.
 
 
-By default, this is set to your default database connection (`[config('database.default)]`), so if you only use one database connections, you should be fine. If you use multiple connections, you can add the rest to the array:
+By default, this is set to your default database connection (`[config('database.default)]`), so if you only use one database connections, you should be fine. If you use multiple connections, you should add them to the array:
 
 
 ```php
 ```php
 'database_connections_to_transact' => [
 'database_connections_to_transact' => [
     config('database.default'),
     config('database.default'),
     'pgsql',
     'pgsql',
 ],
 ],
-```
-
-### `continue_without_database_transactions` [deprecated]
-
-```eval_rst
-.. Warning:: This config item is deprecated and going away in v3. Use :code:`database_connections_to_transact` instead.
-```
-
-By default, Scribe runs response calls and example model creation in a database transaction, and then rolls them back so no changes are persisted. If one of your database drivers does not support database transactions, Scribe will log an error and exit. If you would like Scribe to proceed (and persist the data), add the database driver class name to this array. For example:
-
-```php
-'continue_without_database_transactions' => [
-    Jenssegers\Mongodb\Connection::class,
-],
-```
+```

+ 2 - 2
docs/documenting/documenting-endpoint-responses.md

@@ -126,7 +126,7 @@ This JSON string will be parsed and merged with the response from the file.
 If you don't specify an example response using any of the other means described in this document, Scribe will attempt to get a sample response by making a HTTP request to the local endpoint (known as a "response call").
 If you don't specify an example response using any of the other means described in this document, Scribe will attempt to get a sample response by making a HTTP request to the local endpoint (known as a "response call").
 
 
 ```eval_rst
 ```eval_rst
-.. Note:: Response calls are done within a database transaction and changes are rolled back afterwards, so no data is persisted. If your database connection does not support transactions, you should add it to `continue_without_database_transactions`, but be warned that data from response calls will be persisted.
+.. Note:: Response calls are done within a database transaction and changes are rolled back afterwards, so no data is persisted. However, Scribe only knows of your default database connection. If you're using other connections, you'll need to add them to the `database_connections_to_transact` array.
 ```
 ```
 
 
 The configuration for response calls is located in the `apply.response_calls` section for each route group in `config/scribe.php`. This means that you can apply different settings for different sets of routes. Here are some important things to note:
 The configuration for response calls is located in the `apply.response_calls` section for each route group in `config/scribe.php`. This means that you can apply different settings for different sets of routes. Here are some important things to note:
@@ -293,7 +293,7 @@ When generating responses from `@apiResource` and `@transformer` tags, Scribe ne
 1. First, it tries the Eloquent model factory: `factory(YourModel::class)->create()`. 
 1. First, it tries the Eloquent model factory: `factory(YourModel::class)->create()`. 
 
 
 ```eval_rst
 ```eval_rst
-.. Note:: Scribe uses :code:`create()` instead of :code:`make()` when calling the factory, but runs it in a database transaction which is rolled back afterwards, so no data is persisted. If your database connection does not support transactions, you should add it to `continue_without_database_transactions`, but be warned that created models will be persisted.
+.. Note:: Scribe uses :code:`create()` instead of :code:`make()` when calling the factory, but runs it in a database transaction which is rolled back afterwards, so no data is persisted. However, Scribe only knows of your default database connection. If you're using other connections, you'll need to add them to the `database_connections_to_transact` array.
 ```
 ```
 
 
 2. If that fails, Scribe calls `YourModel::first()` to retrieve the first model from the database. 
 2. If that fails, Scribe calls `YourModel::first()` to retrieve the first model from the database. 

+ 0 - 20
src/Extracting/DatabaseTransactionHelpers.php

@@ -3,8 +3,6 @@
 namespace Knuckles\Scribe\Extracting;
 namespace Knuckles\Scribe\Extracting;
 
 
 use Knuckles\Scribe\Exceptions\DatabaseTransactionsNotSupported;
 use Knuckles\Scribe\Exceptions\DatabaseTransactionsNotSupported;
-use Knuckles\Scribe\Exceptions\ScribeException;
-use Knuckles\Scribe\Tools\ConsoleOutputUtils as c;
 use Knuckles\Scribe\Tools\DocumentationConfig;
 use Knuckles\Scribe\Tools\DocumentationConfig;
 use Knuckles\Scribe\Tools\Globals;
 use Knuckles\Scribe\Tools\Globals;
 use PDOException;
 use PDOException;
@@ -20,15 +18,11 @@ trait DatabaseTransactionHelpers
     {
     {
         $database = app('db');
         $database = app('db');
 
 
-        $excludedDrivers = $this->excludedDrivers();
         foreach ($this->connectionsToTransact() as $connection) {
         foreach ($this->connectionsToTransact() as $connection) {
             $driver = $database->connection($connection);
             $driver = $database->connection($connection);
 
 
             if (self::driverSupportsTransactions($driver)) {
             if (self::driverSupportsTransactions($driver)) {
                 try {
                 try {
-                    if (in_array(get_class($driver), $excludedDrivers)) {
-                        continue;
-                    }
                     $driver->beginTransaction();
                     $driver->beginTransaction();
                 } catch (PDOException $e) {
                 } catch (PDOException $e) {
                     throw new \Exception(
                     throw new \Exception(
@@ -75,20 +69,6 @@ trait DatabaseTransactionHelpers
         return true;
         return true;
     }
     }
 
 
-    private function excludedDrivers(): array
-    {
-        if (!is_null(Globals::$excludedDbDrivers)) {
-            return Globals::$excludedDbDrivers;
-        }
-
-        $excludedDrivers = $this->getConfig()->get('continue_without_database_transactions', []);
-        if (count($excludedDrivers)) {
-            c::deprecated('`continue_without_database_transactions`', '2.4.0', 'use `database_connections_to_transact`');
-        }
-
-        return Globals::$excludedDbDrivers = $excludedDrivers;
-    }
-
     /**
     /**
      * Returns an instance of the documentation config
      * Returns an instance of the documentation config
      *
      *