Skip to content

Commit

Permalink
Added getters and setters for resource and package in FormatterFactor…
Browse files Browse the repository at this point in the history
…y. Added an install which will redirect you to the right location when first installing.
  • Loading branch information
pietercolpaert committed Sep 20, 2011
1 parent 2904ddc commit 026cce4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
4 changes: 3 additions & 1 deletion controllers/RController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ function GET($matches) {

//This will create an instance of a factory depending on which format is set
$this->formatterfactory = FormatterFactory::getInstance($matches["format"]);

$this->formatterfactory->setPackage($package);
$this->formatterfactory->setResource($resourcename);

//This will create an instance of AResource
$model = ResourcesModel::getInstance();
$resource = $model->getResource($package,$resourcename);
Expand Down
15 changes: 15 additions & 0 deletions formatters/FormatterFactory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,20 @@ public function getPrinter($rootname, $objectToPrint){
include_once("formatters/". $this->format . ".class.php");
return new $format($rootname, $objectToPrint);
}

private $package = "", $resource = "";
public function setPackage($package){
$this->package = $package;
}
public function getPackage(){
return $this->package;
}

public function setResource($resource){
$this->resource = $resource;
}
public function getResource(){
return $this->resource;
}
}
?>
9 changes: 9 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
/**
* This file is a redirector and documentation page when first installing The DataTank.
* If it is not yet installed it will redirect you to the installer. If it is installed, it will return information on how to install a GUI
*/

header("Location: installer/");

?>
3 changes: 1 addition & 2 deletions router.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
// explanation of the last part of regex:
// continue the REST parameters as long as no . is encountered. Continue format as long as no ? or end of URI occurs
// /package/resource/rest/para/meters.json?para=meter&filt=er
'/(?P<package>[^/]*)/(?P<resource>[^/]*)/?(?P<RESTparameters>[^.]*)\.(?P<format>[^?]*).*' => 'RController',

'/(?P<package>[^/]*)/(?P<resource>[^/]*)/?(?P<RESTparameters>([^.]*\.)*(?P<format>[^?/]*)).*' => 'RController',
// Calling the Create, Update, Delete- controller
// This is a request on the real-world object
// examples of matches:
Expand Down

0 comments on commit 026cce4

Please sign in to comment.