Esempio n. 1
0
 public static function copy($style, $old, $new)
 {
     $gantry = Gantry::instance();
     /** @var UniformResourceLocator $locator */
     $locator = $gantry['locator'];
     $oldPath = $locator->findResource('gantry-config://' . $old, true, true);
     $newPath = $locator->findResource('gantry-config://' . $new, true, true);
     if (file_exists($oldPath)) {
         Folder::copy($oldPath, $newPath);
     }
     $installer = new TemplateInstaller($style->extension_id);
     $installer->updateStyle($new, ['configuration' => $new]);
 }
Esempio n. 2
0
 public function duplicate($id)
 {
     $gantry = $this->container;
     /** @var UniformResourceLocator $locator */
     $locator = $gantry['locator'];
     $path = $locator->findResource("gantry-config://{$id}");
     if (!$path || !is_dir($path)) {
         throw new \RuntimeException('Outline not found', 404);
     }
     $folder = $this->findFreeName(trim(preg_replace('|[^a-z\\d_-]|ui', '_', $id), '_'));
     $newPath = $locator->findResource("gantry-config://{$folder}", true, true);
     try {
         Folder::copy($path, $newPath);
     } catch (\Exception $e) {
         throw new \RuntimeException(sprintf('Duplicating Outline failed: ', $e->getMessage()), 500, $e);
     }
 }