Add databox_field::toArray method

This commit is contained in:
Romain Neutron
2013-04-17 15:02:17 +02:00
parent d7cd289dc8
commit a137bc7cf7
2 changed files with 68 additions and 0 deletions

View File

@@ -15,6 +15,7 @@ use Alchemy\Phrasea\Vocabulary\ControlProvider\ControlProviderInterface;
use Alchemy\Phrasea\Metadata\Tag\Nosource;
use PHPExiftool\Driver\TagInterface;
use PHPExiftool\Driver\TagFactory;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
*
@@ -178,6 +179,10 @@ class databox_field implements cache_cacheableInterface
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if (!$row) {
throw new NotFoundHttpException(sprintf('Unable to find field in %s', $id));
}
$this->id = (int) $id;
$this->tag = self::loadClassFromTagName($row['src']);
@@ -796,6 +801,39 @@ class databox_field implements cache_cacheableInterface
return $this->on_error;
}
public function toArray()
{
return array(
'id' => $this->id,
'name' => $this->name,
'tag' => $this->tag->getTagname(),
'business' => $this->Business,
'type' => $this->type,
'thumbtitle' => $this->thumbtitle,
'tbranch' => $this->tbranch,
'separator' => $this->separator,
'required' => $this->required,
'report' => $this->report,
'readonly' => $this->readonly,
'multi' => $this->multi,
'indexable' => $this->indexable,
'dces-element' => $this->dces_element,
'vocabulary-name' => $this->Vocabulary ? $this->Vocabulary->getName() : null,
'vocabulary-restricted' => $this->VocabularyRestriction,
);
}
/**
*
* @param \Alchemy\Phrasea\Application $app
* @param databox $databox
* @param type $name
* @param type $multi
*
* @return databox_field
*
* @throws \Exception_InvalidArgument
*/
public static function create(Application $app, databox $databox, $name, $multi)
{
$sorter = 0;