Overview

Namespaces

  • Mapbender
    • Component
      • HTTP
    • CoreBundle
      • Command
      • Component
        • Exception
      • Controller
      • DataFixtures
        • ORM
      • DependencyInjection
      • Element
        • Type
      • Entity
      • EventListener
      • Extension
      • Form
        • DataTransformer
        • EventListener
        • Type
      • Security
      • Template
    • 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
        • 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 ElementGenerator 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:         $classFile = sprintf('%s/Element/%s.php', $bundleDir, $className);
17:         $widgetFile = sprintf('%s/Resources/public/mapbender.element.%s.js', $bundleDir, $classNameLower);
18:         $twigFile = sprintf('%s/Resources/views/Element/%s.html.twig', $bundleDir, $classNameLower);
19: 
20:         if(file_exists($classFile) || file_exists($widgetFile) || file_exists($twigFile)) {
21:             $msg = array();
22:             $msg[] = "One of the the following files already exists and would be overwritten. Aborting.";
23:             $msg[] = $classFile;
24:             $msg[] = $twigFile;
25:             $msg[] = $widgetFile;
26:             $msg = implode("\n", $msg);
27:             throw new \RuntimeException($msg);
28:         }
29: 
30:         $this->renderFile(__DIR__ . '/../Resources/skeleton/element',
31:             $type . '.php.twig', $classFile, array(
32:             'bundleNamespace' => $bundleNamespace,
33:             'className' => $className,
34:             'classNameLower' => $classNameLower,
35:             'bundle' => $bundle));
36:         $files['PHP class'] = $classFile;
37: 
38:         $this->renderFile(__DIR__ . '/../Resources/skeleton/element',
39:             $type . '.js.twig', $widgetFile, array(
40:                 'widgetName' => $className));
41:         $files['jQuery widget'] = $widgetFile;
42: 
43:         if($type === 'general') {
44:             $this->renderFile(__DIR__ . '/../Resources/skeleton/element',
45:                 $type . '.html.twig', $twigFile, array(
46:                     'classNameLower' => $classNameLower));
47:             $files['Twig template'] = $twigFile;
48:         }
49: 
50:         return $files;
51:     }
52: }
53: 
Mapbender3 API documenation API documentation generated by ApiGen 2.8.0