This repository has been archived on 2025-03-31. You can view files and clone it, but cannot push or open issues or pull requests.
php-frs/lib/Frs/FieldDefinition.php

40 lines
994 B
PHP

<?php
namespace Frs;
class FieldDefinition
{
private $fieldData = array();
/**
* @param string $type Type of FieldDefinition (hotel, car, etc.)
* @throws \Exception if no definition file for this $type is found
*/
public function __construct($type)
{
$definitionFile = 'definitions/' . $type . '.json';
if (!file_exists($definitionFile)) {
throw new \Exception('File ' . $definitionFile . ' not found!');
}
$fieldDataJson = file_get_contents($definitionFile);
$this->fieldData = json_decode($fieldDataJson, true);
}
public function getFieldData()
{
return $this->fieldData;
}
public function getGroups()
{
$byGroup = array();
foreach ($this->fieldData['groups'] as $id=>$group) {
$byGroup[$group] = array(
'group_name' => $group,
'fields' => array(),
);
}
return $byGroup;
}
}