Exemplo n.º 1
0
 /**
  * Put your class dependencies in here
  */
 public function __construct()
 {
     $this['AppName'] = 'music';
     $this['API'] = $this->share(function ($c) {
         return new API($c['AppName']);
     });
     /**
      * Http
      */
     $this['Request'] = $this->share(function ($c) {
         $params = json_decode(file_get_contents('php://input'), true);
         $params = is_array($params) ? $params : array();
         return new Request(array('get' => $_GET, 'post' => $_POST, 'files' => $_FILES, 'server' => $_SERVER, 'env' => $_ENV, 'session' => $_SESSION, 'cookies' => $_COOKIE, 'method' => isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : null, 'params' => $params, 'urlParams' => $c['urlParams']));
     });
     $this['Protocol'] = $this->share(function () {
         if (isset($_SERVER['SERVER_PROTOCOL'])) {
             return new Http($_SERVER, $_SERVER['SERVER_PROTOCOL']);
         } else {
             return new Http($_SERVER);
         }
     });
     $this['Dispatcher'] = $this->share(function ($c) {
         return new Dispatcher($c['Protocol'], $c['MiddlewareDispatcher']);
     });
     /**
      * Middleware
      */
     $this['SecurityMiddleware'] = $this->share(function ($c) {
         return new SecurityMiddleware($c['API'], $c['Request']);
     });
     $this['HttpMiddleware'] = $this->share(function ($c) {
         return new HttpMiddleware($c['API'], $c['Request']);
     });
     $this['MiddlewareDispatcher'] = $this->share(function ($c) {
         $dispatcher = new MiddlewareDispatcher();
         $dispatcher->registerMiddleware($c['HttpMiddleware']);
         $dispatcher->registerMiddleware($c['SecurityMiddleware']);
         return $dispatcher;
     });
     require_once __DIR__ . '/diconfig.php';
 }
Exemplo n.º 2
0
    return new Scanner($c['API'], $c['ExtractorGetID3'], $c['ArtistBusinessLayer'], $c['AlbumBusinessLayer'], $c['TrackBusinessLayer']);
});
$this['getID3'] = $this->share(function () {
    $getID3 = new \getID3();
    $getID3->encoding = 'UTF-8';
    // On 32-bit systems, getid3 tries to make a 2GB size check,
    // which does not work with fopen. Disable it.
    // Therefore the filesize (determined by getID3) could be wrong
    // (for files over ~2 GB) but this isn't used in any way.
    $getID3->option_max_2gb_check = false;
    return $getID3;
});
$this['ExtractorGetID3'] = $this->share(function ($c) {
    return new ExtractorGetID3($c['API'], $c['getID3']);
});
$this['Scanner'] = $this->share(function ($c) {
    return new Scanner($c['API'], $c['ExtractorGetID3'], $c['ArtistBusinessLayer'], $c['AlbumBusinessLayer'], $c['TrackBusinessLayer']);
});
/**
 * Middleware
 */
$this['AmpacheMiddleware'] = $this->share(function ($c) {
    return new AmpacheMiddleware($c['API'], $c['Request'], $c['AmpacheSessionMapper'], $c['AmpacheUser']);
});
$this['MiddlewareDispatcher'] = $this->share(function ($c) {
    $dispatcher = new MiddlewareDispatcher();
    $dispatcher->registerMiddleware($c['AmpacheMiddleware']);
    $dispatcher->registerMiddleware($c['HttpMiddleware']);
    $dispatcher->registerMiddleware($c['SecurityMiddleware']);
    return $dispatcher;
});