Deprecate is_grouping in favor of isStory

This commit is contained in:
Benoît Burnichon
2015-07-13 18:14:51 +02:00
parent 2107cd28df
commit c97eedd40f
20 changed files with 43 additions and 43 deletions

View File

@@ -31,7 +31,7 @@ class Story implements AttributeInterface
*/
public function __construct(\record_adapter $story)
{
if ( ! $story->is_grouping()) {
if ( ! $story->isStory()) {
throw new \InvalidArgumentException('Unable to fetch a story from string');
}
@@ -87,7 +87,7 @@ class Story implements AttributeInterface
throw new \InvalidArgumentException('Unable to fetch a story from string');
}
if ( ! $story->is_grouping()) {
if ( ! $story->isStory()) {
throw new \InvalidArgumentException('Unable to fetch a story from string');
}

View File

@@ -1034,7 +1034,7 @@ class V1Controller extends Controller
}
if ($record->is_grouping()) {
if ($record->isStory()) {
$ret['results']['stories'][] = $this->listStory($request, $record);
} else {
$ret['results']['records'][] = $this->listRecord($request, $record);
@@ -1190,7 +1190,7 @@ class V1Controller extends Controller
*/
public function listStory(Request $request, \record_adapter $story)
{
if (!$story->is_grouping()) {
if (!$story->isStory()) {
return Result::createError($request, 404, 'Story not found')->createResponse();
}

View File

@@ -127,7 +127,7 @@ class PropertyController extends Controller
}
//update children if current record is a story
if (isset($applyStatusToChildren[$sbasId]) && $record->is_grouping()) {
if (isset($applyStatusToChildren[$sbasId]) && $record->isStory()) {
foreach ($record->get_children() as $child) {
if (null !== $updatedStatus = $this->updateRecordStatus($child, $postStatus)) {
$updated[$record->get_serialize_key()] = $updatedStatus;

View File

@@ -170,7 +170,7 @@ class StoryController extends Controller
{
$story = new \record_adapter($this->app, $sbas_id, $record_id);
if (!$story->is_grouping()) {
if (!$story->isStory()) {
throw new \Exception('This is not a story');
}
@@ -184,7 +184,7 @@ class StoryController extends Controller
try {
$story = new \record_adapter($this->app, $sbas_id, $record_id);
if (!$story->is_grouping()) {
if (!$story->isStory()) {
throw new \Exception('This is not a story');
}

View File

@@ -40,7 +40,7 @@ class ToolsController extends Controller
if (count($records) == 1) {
$record = $records->first();
if (!$record->is_grouping()) {
if (!$record->isStory()) {
try {
$metadata = $this->getExifToolReader()
->files($record->get_subdef('document')->get_pathfile())

View File

@@ -96,7 +96,7 @@ class WorkzoneController extends Controller
$element = explode('_', $element);
$story = new \record_adapter($this->app, $element[0], $element[1]);
if (!$story->is_grouping()) {
if (!$story->isStory()) {
throw new \Exception('You can only attach stories');
}

View File

@@ -42,12 +42,12 @@ class RecordsRequest extends ArrayCollection
parent::__construct($elements);
$this->received = $received;
$this->basket = $basket;
$this->isSingleStory = ($flatten !== self::FLATTEN_YES && 1 === count($this) && $this->first()->is_grouping());
$this->isSingleStory = ($flatten !== self::FLATTEN_YES && 1 === count($this) && $this->first()->isStory());
if (self::FLATTEN_NO !== $flatten) {
$to_remove = [];
foreach ($this as $key => $record) {
if ($record->is_grouping()) {
if ($record->isStory()) {
if (self::FLATTEN_YES === $flatten) {
$to_remove[] = $key;
}
@@ -143,7 +143,7 @@ class RecordsRequest extends ArrayCollection
{
return new ArrayCollection(
array_filter($this->toArray(), function (\record_adapter $record) {
return $record->is_grouping();
return $record->isStory();
})
);
}

View File

@@ -42,7 +42,7 @@ class RecordEditSubscriber implements EventSubscriberInterface
private function updateRecord($record, $field)
{
if (false === $record->is_grouping()) {
if (false === $record->isStory()) {
foreach ($record->get_grouping_parents() as $story) {
$this->updateEditField($story, $field);
}

View File

@@ -54,7 +54,7 @@ class SubdefSubstituer
$subdefFile = $pathhd . $filehd;
$meta_writable = true;
} else {
$type = $record->is_grouping() ? 'image' : $record->get_type();
$type = $record->isStory() ? 'image' : $record->get_type();
$subdef_def = $record->get_databox()->get_subdef_structure()->get_subdef($type, $name);
if ($record->has_subdef($name) && $record->get_subdef($name)->is_physically_present()) {

View File

@@ -69,7 +69,7 @@ class ESRecordSerializer extends AbstractSerializer
'sha256' => $record->get_sha256(),
'technical_informations' => $technicalInformation,
'phrasea_type' => $record->get_type(),
'type' => $record->is_grouping() ? 'story' : 'record',
'type' => $record->isStory() ? 'story' : 'record',
'uuid' => $record->getUuid(),
'caption' => $caption,
'status' => $status,

View File

@@ -106,7 +106,7 @@ class RecordMoverJob extends AbstractJob
break;
case 'DELETE':
if ($row['deletechildren'] && $rec->is_grouping()) {
if ($row['deletechildren'] && $rec->isStory()) {
/** @var record_adapter $child */
foreach ($rec->get_children() as $child) {
$child->delete();
@@ -175,7 +175,7 @@ class RecordMoverJob extends AbstractJob
break;
case 'DELETE':
$tmp['deletechildren'] = false;
if ($sxtask['deletechildren'] && $rec->is_grouping()) {
if ($sxtask['deletechildren'] && $rec->isStory()) {
$tmp['deletechildren'] = true;
}
$ret[] = $tmp;

View File

@@ -274,7 +274,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
*/
protected function find_substitute_file()
{
if ($this->record->is_grouping()) {
if ($this->record->isStory()) {
$this->mime = 'image/png';
$this->width = 256;
$this->height = 256;

View File

@@ -60,7 +60,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
private $subdefs;
private $type;
private $sha256;
private $grouping;
private $isStory;
private $duration;
/** @var databox */
private $databox;
@@ -232,10 +232,16 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
* Return true if the record is a grouping
*
* @return bool
* @deprecated use {@link self::isStory} instead
*/
public function is_grouping()
{
return $this->grouping;
return $this->isStory();
}
public function isStory()
{
return $this->isStory;
}
/**
@@ -506,7 +512,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
$searchDevices = array_merge((array) $devices, (array) databox_subdef::DEVICE_ALL);
$type = $this->is_grouping() ? 'image' : $this->get_type();
$type = $this->isStory() ? 'image' : $this->get_type();
foreach ($this->databox->get_subdef_structure() as $group => $databoxSubdefs) {
@@ -828,7 +834,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
$meta_writable = true;
} else {
$type = $this->is_grouping() ? 'image' : $this->get_type();
$type = $this->isStory() ? 'image' : $this->get_type();
$subdef_def = $this->get_databox()->get_subdef_structure()->get_subdef($type, $name);
@@ -1605,7 +1611,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
*/
public function get_children()
{
if (!$this->is_grouping()) {
if (!$this->isStory()) {
throw new Exception('This record is not a grouping');
}
@@ -1697,7 +1703,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
public function appendChild(\record_adapter $record)
{
if (!$this->is_grouping()) {
if (!$this->isStory()) {
throw new \Exception('Only stories can append children');
}
@@ -1746,7 +1752,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
public function removeChild(\record_adapter $record)
{
if (!$this->is_grouping()) {
if (!$this->isStory()) {
throw new \Exception('Only stories can append children');
}
@@ -1792,12 +1798,6 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
return $this->get_databox()->get_sbas_id();
}
/** {@inheritdoc} */
public function isStory()
{
return $this->is_grouping();
}
/** {@inheritdoc} */
public function getMimeType()
{
@@ -1886,7 +1886,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
$this->sha256 = $data['sha256'];
$this->original_name = $data['original_name'];
$this->type = $data['type'];
$this->grouping = $data['grouping'];
$this->isStory = $data['grouping'];
$this->uuid = $data['uuid'];
$this->updated = $data['modification_date'];
$this->created = $data['creation_date'];
@@ -1903,7 +1903,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
'sha256' => $this->sha256,
'original_name' => $this->original_name,
'type' => $this->type,
'grouping' => $this->grouping,
'grouping' => $this->isStory,
'uuid' => $this->uuid,
'modification_date' => $this->updated,
'creation_date' => $this->created,
@@ -1925,7 +1925,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
$this->updated = new DateTime($row['moddate']);
$this->uuid = $row['uuid'];
$this->grouping = ($row['parent_record_id'] == '1');
$this->isStory = ($row['parent_record_id'] == '1');
$this->type = $row['type'];
$this->original_name = $row['originalname'];
$this->sha256 = $row['sha256'];

View File

@@ -119,7 +119,7 @@ abstract class set_abstract implements IteratorAggregate
{
$n = 0;
foreach ($this->elements as $record) {
if ($record->is_grouping())
if ($record->isStory())
$n ++;
}

View File

@@ -100,7 +100,7 @@ class set_export extends set_abstract
continue;
}
if ($record->is_grouping()) {
if ($record->isStory()) {
foreach ($record->get_children() as $child_basrec) {
$base_id = $child_basrec->get_base_id();
$record_id = $child_basrec->get_record_id();

View File

@@ -128,7 +128,7 @@ class set_selection extends set_abstract
} catch (\Exception $e) {
continue;
}
if ($record->is_grouping() && $flatten_groupings === true) {
if ($record->isStory() && $flatten_groupings === true) {
foreach ($record->get_children() as $rec) {
$this->add_element($rec);
}

View File

@@ -158,7 +158,7 @@
{% endif %}
{% endif %}
{% if record.is_grouping %}
{% if record.isStory %}
{% set on_click_html = "openPreview('REG',0, '" ~ record.get_serialize_key() ~ "');" %}
{% else %}
{% set on_click_html = "openPreview('RESULT','" ~ record.getNumber() ~ "');" %}

View File

@@ -32,7 +32,7 @@
<p>
<select name="types[{{record.get_serialize_key()}}]" class="input-block-level">
{% for option in typesEnum %}
<option value="{{ option }}" {{ record.is_grouping() ? "disabled='disabled'": "" }} {{ option == record.get_type() ? "selected='selected'" : '' }}>{{ option }}</option>
<option value="{{ option }}" {{ record.isStory() ? "disabled='disabled'": "" }} {{ option == record.get_type() ? "selected='selected'" : '' }}>{{ option }}</option>
{% endfor %}
</select>
<input class="input-block-level" type="text" name="mimes[{{record.get_serialize_key()}}]" value="{{ record.get_mime }}" style="width:100%">

View File

@@ -338,7 +338,7 @@ class UploadTest extends \PhraseanetAuthenticatedWebTestCase
$id = explode('_', $datas['id']);
$record = new \record_adapter(self::$DI['app'], $id[0], $id[1]);
$this->assertFalse($record->is_grouping());
$this->assertFalse($record->isStory());
$this->assertEquals([], $datas['reasons']);
}
@@ -375,7 +375,7 @@ class UploadTest extends \PhraseanetAuthenticatedWebTestCase
$id = explode('_', $datas['id']);
$record = new \record_adapter(self::$DI['app'], $id[0], $id[1]);
$this->assertFalse($record->is_grouping());
$this->assertFalse($record->isStory());
$this->assertEquals(1, substr(strrev($record->get_status()), 4, 1));
$this->assertEquals([], $datas['reasons']);
}

View File

@@ -152,8 +152,8 @@ class record_adapterTest extends \PhraseanetAuthenticatedTestCase
public function testIs_grouping()
{
$this->assertFalse($this->getRecord1()->is_grouping());
$this->assertTrue($this->getRecordStory1()->is_grouping());
$this->assertFalse($this->getRecord1()->isStory());
$this->assertTrue($this->getRecordStory1()->isStory());
}
public function testGet_base_id()