Jarves\Propel\PropelHelper::moveClasses PHP Метод

moveClasses() публичный Метод

public moveClasses ( ) : string
Результат string
    public function moveClasses()
    {
        $fs = $this->cacheFilesystem;
        $tmp = $this->getJarves()->getCacheDir() . '/';
        $result = '';
        if ($fs->has('propel-classes')) {
            $fs->delete('propel-classes');
        }
        $fs->rename('propel/build/classes', 'propel-classes');
        $bundles = $this->getJarves()->getBundles();
        foreach ($bundles as $bundleName => $bundle) {
            $source = $tmp . 'propel-classes/' . str_replace('\\', '/', ucfirst($bundle->getNamespace())) . '/Model';
            if (!is_dir($source)) {
                continue;
            }
            $files = Finder::create()->files()->in($source)->depth(0)->name('*.php');
            $result .= "{$source}" . "\n";
            /** @var \SplFileInfo $file */
            foreach ($files as $file) {
                $target = $bundle->getPath() . '/Model/' . basename($file->getPathname());
                //$result .= "$file => " . (file_exists($target) + 0) . "\n";
                if (!file_exists($target)) {
                    try {
                        if (!is_dir(dirname($target))) {
                            mkdir(dirname($target));
                        }
                    } catch (\Exception $e) {
                        throw new \Exception(sprintf('Can not create directory `%s`.', dirname($target)), 0, $e);
                    }
                    if (!copy($file->getPathname(), $target)) {
                        throw new FileNotWritableException(sprintf('Can not move file %s to %s', $source, $target));
                    }
                }
                unlink($file->getPathname());
            }
        }
        return $result;
    }