Goetas\Xsd\XsdToPhp\Jms\PathGenerator\Psr4PathGenerator::getPath PHP Method

getPath() public method

public getPath ( $yaml )
    public function getPath($yaml)
    {
        $ns = key($yaml);
        foreach ($this->namespaces as $namespace => $dir) {
            $pos = strpos($ns, $namespace);
            if ($pos === 0) {
                if (!is_dir($dir) && !mkdir($dir, 0777, true)) {
                    throw new PathGeneratorException("Can't create the folder '{$dir}'");
                }
                $f = strtr(substr($ns, strlen($namespace)), "\\/", "..");
                return $dir . "/" . $f . ".yml";
            }
        }
        throw new PathGeneratorException("Can't find a defined location where save '{$ns}' metadata");
    }

Usage Example

Beispiel #1
0
 protected function convert(AbstractConverter $converter, array $schemas, array $targets, OutputInterface $output)
 {
     $items = $converter->convert($schemas);
     $dumper = new Dumper();
     $pathGenerator = new Psr4PathGenerator($targets);
     $progress = new ProgressBar($output, count($items));
     $progress->start();
     foreach ($items as $item) {
         $progress->advance();
         $output->write(" Item <info>" . key($item) . "</info>... ");
         $source = $dumper->dump($item, 10000);
         $output->write("created source... ");
         $path = $pathGenerator->getPath($item);
         $bytes = file_put_contents($path, $source);
         $output->writeln("saved source <comment>{$bytes} bytes</comment>.");
     }
 }
All Usage Examples Of Goetas\Xsd\XsdToPhp\Jms\PathGenerator\Psr4PathGenerator::getPath
Psr4PathGenerator