static function define($definition_file)
 {
     if (!(file_exists($definition_file) and is_readable($definition_file))) {
         throw new Exception('Unable to load polyfill definition file');
     }
     
     self::$polyfills = json_decode(file_get_contents($definition_file), true);
     
     foreach (self::$polyfills as $name => $polyfill) {
         $version = $polyfill['since'];
         if (!isset(self::$versions[$version])) {
             self::$versions[$version] = array();
         }
         self::$versions[$version][] = $name;
     }
 }
<?php

#global includes
require_once 'vendor/trails/trails.php';
require_once 'app/controllers/studip_controller.php';
# local includes
require 'app/controllers/plugin_generator_controller.php';
function uol_pg_autoload($name)
{
    include dirname(__FILE__) . '/classes/' . $name . '.php';
}
spl_autoload_register('uol_pg_autoload');
# Defaults
Polyfill::define(dirname(__FILE__) . '/polyfills.json');
 function index_action($step = 'manifest')
 {
     $step = Request::option('step', $step);
     $this->previous = $this->next = $last = false;
     foreach ($this->actions as $action) {
         if ($last == $step) {
             $this->next = $action;
         }
         if ($action == $step) {
             $this->previous = $last;
         }
         $last = $action;
     }
     // if (Request::isPost()) {    # since Stud.IP 2.1
     if ($_SERVER['REQUEST_METHOD'] === 'POST') {
         $this->plugin = array_merge($this->plugin, $this->extract($step, $errors));
         $_SESSION['plugin-generator']['passed'][$step] = empty($errors);
     }
     if (!empty($errors)) {
         PageLayout::postMessage(Messagebox::error(_('Es sind Fehler aufgetreten:'), $errors));
     } elseif (Request::submitted('action')) {
         $action = Request::option('action');
         if (!in_array($action, array('display download install'))) {
             $generator = new Generator($this->dispatcher->plugin->getPluginPath(), '/templates', '/environments');
         }
         $generator->populate($this->plugin);
         $generator->{$action}();
         if ($action === 'install') {
             $this->redirect(URLHelper::getURL('dispatch.php/admin/plugin'));
             return;
         }
         #            PageLayout::postMessage(Messagebox::success('Jipp.'));
     } elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
         if (Request::submitted('back')) {
             $step = Request::option('back', $this->previous);
         } else {
             if (Request::submitted('forward')) {
                 $step = Request::option('forward', $this->next);
             }
         }
         $this->redirect('generator/' . $step);
         return;
     }
     $this->step = $step;
     switch ($step) {
         case 'manifest':
             $this->interfaces = array('HomepagePlugin' => _('Homepage eines Nutzers'), 'PortalPlugin' => _('Startseite (Portalseite)'), 'StandardPlugin' => _('Veranstaltungen und Einrichtungen'), 'StudienmodulManagementPlugin' => _('Studienmodulsuche'), 'SystemPlugin' => _('Systemweite Erweiterungen'));
             $this->versions = words('2.0 2.1 2.2 2.3 2.4');
             break;
         case 'assets':
             $this->environments = array('default' => _('Standard'), 'trails' => _('Trails'));
             break;
         case 'polyfill':
             $this->polyfills = Polyfill::getVersions();
             break;
     }
     $variables = array('step' => $step, 'controller' => $this);
     $factory = new Flexi_TemplateFactory($this->dispatcher->plugin->getPluginPath() . '/app/views/');
     $progress = $factory->render('infobox-route', $variables);
     $this->setInfoboxImage($this->dispatcher->plugin->getPluginURL() . '/assets/images/puzzle.jpg')->addToInfobox(_('Fortschritt'), $progress)->addToInfobox(_('Aktionen'), sprintf('<a href="%s">Reset</a>', $this->url_for('generator/' . $step . '?reset=1')), Assets::image_path('icons/16/black/refresh.png'));
 }