Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 399 | Zur aktuellen Revision | Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Illuminate\Database\Schema;
4
 
5
use Illuminate\Database\Connection;
6
use Illuminate\Filesystem\Filesystem;
7
use Symfony\Component\Process\Process;
8
 
9
abstract class SchemaState
10
{
11
    /**
12
     * The connection instance.
13
     *
14
     * @var \Illuminate\Database\Connection
15
     */
16
    protected $connection;
17
 
18
    /**
19
     * The filesystem instance.
20
     *
21
     * @var \Illuminate\Filesystem\Filesystem
22
     */
23
    protected $files;
24
 
25
    /**
26
     * The name of the application's migration table.
27
     *
28
     * @var string
29
     */
30
    protected $migrationTable = 'migrations';
31
 
32
    /**
33
     * The process factory callback.
34
     *
35
     * @var callable
36
     */
37
    protected $processFactory;
38
 
39
    /**
40
     * The output callable instance.
41
     *
42
     * @var callable
43
     */
44
    protected $output;
45
 
46
    /**
47
     * Create a new dumper instance.
48
     *
49
     * @param  \Illuminate\Database\Connection  $connection
50
     * @param  \Illuminate\Filesystem\Filesystem|null  $files
51
     * @param  callable|null  $processFactory
52
     * @return void
53
     */
54
    public function __construct(Connection $connection, Filesystem $files = null, callable $processFactory = null)
55
    {
56
        $this->connection = $connection;
57
 
58
        $this->files = $files ?: new Filesystem;
59
 
60
        $this->processFactory = $processFactory ?: function (...$arguments) {
61
            return Process::fromShellCommandline(...$arguments)->setTimeout(null);
62
        };
63
 
64
        $this->handleOutputUsing(function () {
65
            //
66
        });
67
    }
68
 
69
    /**
70
     * Dump the database's schema into a file.
71
     *
72
     * @param  \Illuminate\Database\Connection  $connection
73
     * @param  string  $path
74
     * @return void
75
     */
76
    abstract public function dump(Connection $connection, $path);
77
 
78
    /**
79
     * Load the given schema file into the database.
80
     *
81
     * @param  string  $path
82
     * @return void
83
     */
84
    abstract public function load($path);
85
 
86
    /**
87
     * Create a new process instance.
88
     *
89
     * @param  array  $arguments
90
     * @return \Symfony\Component\Process\Process
91
     */
92
    public function makeProcess(...$arguments)
93
    {
94
        return call_user_func($this->processFactory, ...$arguments);
95
    }
96
 
97
    /**
98
     * Specify the name of the application's migration table.
99
     *
100
     * @param  string  $table
101
     * @return $this
102
     */
103
    public function withMigrationTable(string $table)
104
    {
105
        $this->migrationTable = $table;
106
 
107
        return $this;
108
    }
109
 
110
    /**
111
     * Specify the callback that should be used to handle process output.
112
     *
113
     * @param  callable  $output
114
     * @return $this
115
     */
116
    public function handleOutputUsing(callable $output)
117
    {
118
        $this->output = $output;
119
 
120
        return $this;
121
    }
122
}