Extract whether subdef metadata updates are required

This commit is contained in:
Benoît Burnichon
2016-01-22 17:15:51 +01:00
parent 401ed4f431
commit f501cba16b
8 changed files with 63 additions and 52 deletions

View File

@@ -32,7 +32,11 @@ class databox_subdef
protected $path;
protected $subdef_group;
protected $labels = [];
protected $write_meta;
/**
* @var bool
*/
private $requiresMetadataUpdate;
protected $downloadable;
protected $translator;
protected static $mediaTypeToSubdefTypes = [
@@ -74,7 +78,7 @@ class databox_subdef
$this->downloadable = p4field::isyes($sd->attributes()->downloadable);
$this->path = trim($sd->path) !== '' ? p4string::addEndSlash(trim($sd->path)) : '';
$this->write_meta = p4field::isyes((string) $sd->meta);
$this->requiresMetadataUpdate = p4field::isyes((string) $sd->meta);
foreach ($sd->label as $label) {
$lang = trim((string) $label->attributes()->lang);
@@ -242,13 +246,13 @@ class databox_subdef
}
/**
* Tells us if we have to write meta datas in the subdef
* Tells us if we have to write meta data in the subdef
*
* @return boolean
* @return bool
*/
public function meta_writeable()
public function isMetadataUpdateRequired()
{
return $this->write_meta;
return $this->requiresMetadataUpdate;
}
/**

View File

@@ -14,8 +14,7 @@ use Symfony\Component\Translation\TranslatorInterface;
class databox_subdefsStructure implements IteratorAggregate, Countable
{
/**
*
* @var Array
* @var array|databox_subdef[][]
*/
protected $AvSubdefs = [];
@@ -24,6 +23,11 @@ class databox_subdefsStructure implements IteratorAggregate, Countable
*/
private $translator;
/**
* @var databox
*/
private $databox;
/**
*
* @return ArrayIterator
@@ -133,10 +137,10 @@ class databox_subdefsStructure implements IteratorAggregate, Countable
}
/**
* @param $subdef_type
* @param $subdef_name
* @param string $subdef_type
* @param string $subdef_name
*
* @return mixed
* @return databox_subdef
* @throws Exception_Databox_SubdefNotFound
*/
public function get_subdef($subdef_type, $subdef_name)
@@ -220,13 +224,14 @@ class databox_subdefsStructure implements IteratorAggregate, Countable
}
/**
*
* @param string $group
* @param string $name
* @param string $class
* @param boolean $downloadable
* @param Array $options
* @param string $group
* @param string $name
* @param string $class
* @param boolean $downloadable
* @param array $options
* @param array $labels
* @return databox_subdefsStructure
* @throws Exception
*/
public function set_subdef($group, $name, $class, $downloadable, $options, $labels)
{