<?php

/**
 * When accessing the path:
 *
 *  http://localhost/limesurvey/plugins/direct/?plugin=NewDirectRequestNotWorking&function=someEndpoint
 *
 * this plugin throws the error:
 *
 *  Alias "ext.Menu.MenuWidget" is invalid. Make sure it points to an existing PHP file and the file is readable.
 *  /framework/YiiBase.php(323)
 */
class NewDirectRequestNotWorking extends ls\pluginmanager\PluginBase {

  protected $storage = 'DbStorage';
  static protected $name = 'NewDirectRequestNotWorking';
  static protected $description = 'test';

  protected $settings = array();

  function init() {

    $this->subscribe( 'newDirectRequest' );
  }

  function newDirectRequest() {

    $event = $this->event;

    if ( $event->get( 'target' ) === __CLASS__ ) {
      $functionToCall = $event->get( 'function' );
      if ( method_exists( $this, $functionToCall ) ) {
        $content = $this->$functionToCall();
        $event->setContent( $this, $content );
      }
    }
  }

  function someEndpoint() {

    return '<strong>Some content wrapped inside the Limesurvey admin dashboard HTML wrapper.</strong>';
  }
}

