Exemplo n.º 1
0
 /**
  * Get a exporter driver instance
  *
  * @param string $type   The type to get (yml, xml, etc.)
  * @param string $source    The directory where the exporter will export to
  * @return AbstractExporter $exporter
  */
 public function getExporter($type, $dest = null)
 {
     if (!isset(self::$_exporterDrivers[$type])) {
         throw ExportException::invalidExporterDriverType($type);
     }
     $class = self::$_exporterDrivers[$type];
     return new $class($dest);
 }
Exemplo n.º 2
0
 /**
  * Export each ClassMetadata instance to a single Doctrine Mapping file
  * named after the entity
  *
  * @return void
  */
 public function export()
 {
     if (!is_dir($this->_outputDir)) {
         mkdir($this->_outputDir, 0777, true);
     }
     foreach ($this->_metadata as $metadata) {
         //In case output is returned, write it to a file, skip otherwise
         if ($output = $this->exportClassMetadata($metadata)) {
             $path = $this->_generateOutputPath($metadata);
             $dir = dirname($path);
             if (!is_dir($dir)) {
                 mkdir($dir, 0777, true);
             }
             if (file_exists($path) && !$this->_overwriteExistingFiles) {
                 throw ExportException::attemptOverwriteExistingFile($path);
             }
             file_put_contents($path, $output);
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Add a new mapping directory to the array of directories to convert and export
  * to another format
  *
  * @param string $source   The source for the mapping
  * @param string $type  The type of mapping files (yml, xml, etc.)
  * @return void
  */
 public function addMappingSource($source, $type = null)
 {
     if ($type === null) {
         $type = $this->_determineSourceType($source);
     }
     if (!isset(self::$_mappingDrivers[$type])) {
         throw ExportException::invalidMappingDriverType($type);
     }
     $source = $this->_getSourceByType($type, $source);
     $driver = $this->_getMappingDriver($type, $source);
     $this->_mappingSources[] = array($source, $driver);
 }