1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
4
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
5
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
6
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
7
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
8
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
9
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
10
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
11
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
12
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
13
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
14
|
|
|
* |
15
|
|
|
* This software consists of voluntary contributions made by many individuals |
16
|
|
|
* and is licensed under the MIT license. For more information, see |
17
|
|
|
* <http://www.doctrine-project.org>. |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
namespace Doctrine\ODM\MongoDB\Tools\Console\Command\Schema; |
21
|
|
|
|
22
|
|
|
use Doctrine\ODM\MongoDB\SchemaManager; |
23
|
|
|
use Symfony\Component\Console\Command\Command; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @author Bulat Shakirzyanov <[email protected]> |
27
|
|
|
*/ |
28
|
|
|
abstract class AbstractCommand extends Command |
29
|
|
|
{ |
30
|
|
|
const DB = 'db'; |
31
|
|
|
const COLLECTION = 'collection'; |
32
|
|
|
const INDEX = 'index'; |
33
|
|
|
|
34
|
|
|
abstract protected function processDocumentCollection(SchemaManager $sm, $document); |
35
|
|
|
|
36
|
|
|
abstract protected function processCollection(SchemaManager $sm); |
37
|
|
|
|
38
|
|
|
abstract protected function processDocumentDb(SchemaManager $sm, $document); |
39
|
|
|
|
40
|
|
|
abstract protected function processDb(SchemaManager $sm); |
41
|
|
|
|
42
|
|
|
abstract protected function processDocumentIndex(SchemaManager $sm, $document); |
43
|
|
|
|
44
|
|
|
abstract protected function processIndex(SchemaManager $sm); |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @return SchemaManager |
48
|
|
|
*/ |
49
|
|
|
protected function getSchemaManager() |
50
|
|
|
{ |
51
|
|
|
return $this->getDocumentManager()->getSchemaManager(); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @return \Doctrine\ODM\MongoDB\DocumentManager |
56
|
|
|
*/ |
57
|
|
|
protected function getDocumentManager() |
58
|
|
|
{ |
59
|
|
|
return $this->getHelper('documentManager')->getDocumentManager(); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @return \Doctrine\ODM\MongoDB\Mapping\ClassMetadataFactory |
64
|
|
|
*/ |
65
|
|
|
protected function getMetadataFactory() |
66
|
|
|
{ |
67
|
|
|
return $this->getDocumentManager()->getMetadataFactory(); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|