Esempio n. 1
0
 /**
  * Constructor
  *
  * @param	DoliDb	$db		      Database handler
  * @param   string  $cachedir     Cache dir
  */
 function __construct($db, $cachedir = '')
 {
     global $conf;
     if (empty($cachedir)) {
         $cachedir = $conf->api->dir_temp;
     }
     Defaults::$cacheDirectory = $cachedir;
     $this->db = $db;
     $production_mode = empty($conf->global->API_PRODUCTION_MODE) ? false : true;
     $this->r = new Restler($production_mode);
 }
 /**
  * Constructor
  *
  * @param boolean $productionMode
  *                              When set to false, it will run in
  *                              debug mode and parse the class files
  *                              every time to map it to the URL
  *
  * @param bool    $refreshCache will update the cache when set to true
  */
 public function __construct($productionMode = false, $refreshCache = false)
 {
     $this->startTime = time();
     Util::$restler = $this;
     $this->productionMode = $productionMode;
     if (is_null(Defaults::$cacheDirectory)) {
         Defaults::$cacheDirectory = dirname($_SERVER['SCRIPT_FILENAME']) . DIRECTORY_SEPARATOR . 'cache';
     }
     $this->cache = new Defaults::$cacheClass();
     // use this to rebuild cache every time in production mode
     if ($productionMode && $refreshCache) {
         $this->cached = false;
     }
 }
Esempio n. 3
0
$version = floor(file_get_contents(__DIR__ . '/VERSION'));
if ($matches && isset($matches[1]) && $matches[1] == 2) {
    $version = 2;
}
// Do not put .json at the end of the resource
Explorer::$useFormatAsExtension = false;
//Do not hide the API
Explorer::$hideProtected = false;
// Use /api/v1/projects uri
Defaults::$useUrlBasedVersioning = true;
if (ForgeConfig::get('DEBUG_MODE')) {
    $restler = new Restler(false, true);
    $restler->setSupportedFormats('JsonFormat', 'XmlFormat', 'HtmlFormat');
} else {
    $restler_cache = new RestlerCache();
    Defaults::$cacheDirectory = $restler_cache->getAndInitiateCacheDirectory($version);
    $restler = new Restler(true, false);
    $restler->setSupportedFormats('JsonFormat', 'XmlFormat');
}
// Do not let Restler find itself the domain, when behind a reverse proxy, it's
// a mess.
$restler->setBaseUrl($sys_default_domain);
$restler->setAPIVersion($version);
$core_resources_injector = new Tuleap\REST\ResourcesInjector();
$core_resources_injector->populate($restler);
switch ($version) {
    case 2:
        $event = Event::REST_RESOURCES_V2;
        break;
    default:
        $event = Event::REST_RESOURCES;
Esempio n. 4
0
 /**
  * Constructor
  *
  * @param boolean $productionMode When set to false, it will run in
  *                                   debug mode and parse the class files
  *                                   every time to map it to the URL
  *
  * @param bool $refreshCache will update the cache when set to true
  * @param bool $enableRouteCache
  */
 public function __construct($productionMode = false, $refreshCache = false, $enableRouteCache = false)
 {
     parent::__construct();
     $this->startTime = time();
     Util::$restler = $this;
     Scope::set('Restler', $this);
     $this->productionMode = $productionMode;
     $this->enableRouteCache = $enableRouteCache;
     if (is_null(Defaults::$cacheDirectory)) {
         Defaults::$cacheDirectory = dirname($_SERVER['SCRIPT_FILENAME']) . DIRECTORY_SEPARATOR . 'cache';
     }
     if ($enableRouteCache) {
         $this->cache = new Defaults::$cacheClass();
         $this->refreshCache = $refreshCache;
         // use this to rebuild cache every time in production mode
         if ($productionMode && $refreshCache) {
             $this->cached = false;
         }
     }
     $this->headerData = new \Luracast\Restler\Data\Response\Header();
     $this->requestFromObject = null;
 }
        return class_alias($app['config']['app.aliases'][$className], $className);
    }
    return false;
}, true, true);
/*
|--------------------------------------------------------------------------
| Bind Paths
|--------------------------------------------------------------------------
|
| Here we are binding the paths configured in paths.php to the app. You
| should not be changing these here. If you need to change these you
| may do so within the paths.php file and they will be bound here.
|
*/
$app->bindInstallPaths(require __DIR__ . '/paths.php');
/*
|--------------------------------------------------------------------------
| Configure Restler to adapt to Laravel  4.2 structure
|--------------------------------------------------------------------------
*/
use Luracast\Restler\Defaults;
use Luracast\Restler\Format\HtmlFormat;
use Luracast\Restler\UI\Forms;
use Luracast\Restler\UI\FormStyles;
use Luracast\Restler\Scope;
$app['config']['app.aliases'] += Scope::$classAliases + ['Scope' => 'Luracast\\Restler\\Scope'];
HtmlFormat::$viewPath = $app['path'] . '/views';
HtmlFormat::$cacheDirectory = $app['path.storage'] . '/views';
Defaults::$cacheDirectory = $app['path.storage'] . '/cache';
HtmlFormat::$template = 'blade';
Forms::$style = FormStyles::$bootstrap3;