XOOPS  2.6.0
ExportVisitor.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
13 
21 
35 class ExportVisitor implements Visitor
36 {
37 
38  protected $schemaArray;
39 
43  public function __construct()
44  {
45  $this->schemaArray = array();
46  }
47 
53  public function getSchemaArray()
54  {
55  return $this->schemaArray;
56  }
57 
65  public function acceptSchema(Schema $schema)
66  {
67 
68  }
69 
77  public function acceptTable(Table $table)
78  {
79  $this->schemaArray['tables'][$table->getName()]['options'] = $table->getOptions();
80  }
81 
90  public function acceptColumn(Table $table, Column $column)
91  {
92  $this->schemaArray['tables'][$table->getName()]['columns'][$column->getName()] = $column->toArray();
93  $this->schemaArray['tables'][$table->getName()]['columns'][$column->getName()]['type'] =
94  $column->getType()->getName();
95  }
96 
105  public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint)
106  {
107  if (!isset($this->schemaArray['tables'][$localTable->getName()]['constraint'])) {
108  $this->schemaArray['tables'][$localTable->getName()]['constraint']=array();
109  }
110  $this->schemaArray['tables'][$localTable->getName()]['constraint'][] = array(
111  'name' => $fkConstraint->getName(),
112  'localcolumns' => $fkConstraint->getLocalColumns(),
113  'foreigntable' => $fkConstraint->getForeignTableName(),
114  'foreigncolumns' => $fkConstraint->getForeignColumns(),
115  'options' => $fkConstraint->getOptions()
116  );
117 
118  }
119 
128  public function acceptIndex(Table $table, Index $index)
129  {
130  $this->schemaArray['tables'][$table->getName()]['indexes'][$index->getName()] = array(
131  'name' => $index->getName(),
132  'columns' => $index->getColumns(),
133  'unique' => $index->isUnique(),
134  'primary' => $index->isPrimary()
135  );
136  }
137 
145  public function acceptSequence(Sequence $sequence)
146  {
147  $this->schemaArray['sequence'][$sequence->getName()] = array(
148  'name' => $sequence->getName(),
149  'allocationsize' => $sequence->getAllocationSize(),
150  'initialvalue' => $sequence->getInitialValue()
151  );
152  }
153 }
acceptIndex(Table $table, Index $index)
$index
Definition: menu.php:41
acceptColumn(Table $table, Column $column)
acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint)