Overview

Namespaces

  • Mapbender
    • Component
      • HTTP
    • CoreBundle
      • Command
      • Component
        • Exception
      • Controller
      • DataFixtures
        • ORM
      • DependencyInjection
      • Element
        • Type
      • Entity
      • EventListener
      • Extension
      • Form
        • DataTransformer
        • EventListener
        • Type
      • Security
      • Template
    • DrupalIntegrationBundle
      • DependencyInjection
      • Security
        • Authentication
          • Provider
          • Token
        • Authorization
          • Voter
        • Factory
        • Firewall
        • User
      • Session
    • KmlBundle
      • Element
    • ManagerBundle
      • Controller
      • Form
        • DataTransformer
        • Type
    • MonitoringBundle
      • Command
      • Component
      • Controller
      • DependencyInjection
      • Entity
      • EventListener
      • Form
    • PrintBundle
      • Component
      • Controller
    • WmcBundle
      • Component
        • Exception
      • Element
        • Type
      • Entity
      • Form
        • EventListener
        • Type
    • WmsBundle
      • Component
        • Exception
      • Controller
      • DependencyInjection
      • Element
        • Type
      • Entity
      • Event
      • Form
        • EventListener
        • Type
    • WmtsBundle
      • Component
        • Exception
      • Controller
      • Entity
      • Form
        • Type
  • None
  • PHP

Classes

  • ElementGenerator
  • GenerateElementCommand
  • GenerateTemplateCommand
  • TemplateGenerator
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  • Download
 1: <?php
 2: 
 3: namespace Mapbender\CoreBundle\Command;
 4: 
 5: use Sensio\Bundle\GeneratorBundle\Generator\Generator;
 6: 
 7: class TemplateGenerator extends Generator {
 8:     public function create($container, $bundle, $bundleDir, $bundleNamespace, $className, $type) {
 9:         $files = Array();
10: 
11:         $classNameLower = strtolower($className);
12: 
13:         // Copy skeleton files
14:         $filesystem = $container->get('filesystem');
15: 
16:         $files = array(
17:             'class' => sprintf('%s/Template/%s.php', $bundleDir, $className),
18:             'js' => sprintf('%s/Resources/public/mapbender.template.%s.js',
19:                 $bundleDir, $classNameLower),
20:             'css' => sprintf('%s/Resources/public/mapbender.template.%s.js',
21:                 $bundleDir, $classNameLower),
22:             'twig' => sprintf('%s/Resources/views/Template/%s.html.twig',
23:                 $bundleDir, $classNameLower));
24: 
25:         $exists = array();
26:         foreach($files as $type => $file) {
27:             if(file_exists($file)) {
28:                 $exists[] = $file;
29:             }
30:         }
31:         if(count($exists) > 0) {
32:             $msg = array();
33:             $msg[] = 'The following file(s) exist and would be overwritten. '
34:                 .'Aborting.';
35:             $msg = array_merge($msg, $exists);
36:             throw new \RuntimeException($msg);
37:         }
38: 
39:         foreach($files as $type => $file) {
40:             $skeletonFile = pathinfo($file, PATHINFO_FILENAME);
41:             $this->renderFile(__DIR__ . '/../Resources/skeleton/template',
42:                 $skeletonFile, array(
43:                     'bundleNamespace' => $bundleNamespace,
44:                     'className' => $className,
45:                     'classNameLower' => $classNameLower,
46:                     'bundle' => $bundle));
47:         }
48: 
49:         return $files;
50:     }
51: }
52: 
Mapbender3 API documenation API documentation generated by ApiGen 2.8.0