Add custom prefix for definition files to class.

This commit is contained in:
Markus Birth 2016-07-10 16:17:50 +02:00
parent e14010cf60
commit 89af62d083

View File

@ -4,15 +4,18 @@ namespace Frs;
class FieldDefinition
{
private $definitionsPrefix;
private $fieldData = array();
/**
* @param string $type Type of FieldDefinition (hotel, car, etc.)
* @param string $definitionsPrefix Prefix for definition files. If it's a directory, has to end with slash!
* @throws \Exception if no definition file for this $type is found
*/
public function __construct($type)
public function __construct($type, $definitionsPrefix = 'definitions/')
{
$definitionFile = 'definitions/' . $type . '.json';
$this->definitionsPrefix = $definitionsPrefix;
$definitionFile = $this->definitionsPrefix . $type . '.json';
if (!file_exists($definitionFile)) {
throw new \Exception('File ' . $definitionFile . ' not found!');
}