Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISSUE-177: Initialize embargo cache arrays sooner #178

Merged
merged 1 commit into from
Mar 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Controller/MetadataExposeDisplayController.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ public function castViaTwig(
);
}
$context = [];
$embargo_context = [];
$embargo_tags = [];
if ($sbf_fields = $this->strawberryfieldUtility->bearsStrawberryfield(
$node
)) {
Expand Down Expand Up @@ -210,11 +212,9 @@ public function castViaTwig(
}

$embargo_info = $this->embargoResolver->embargoInfo($node->uuid(), $jsondata);
$embargo_context = [];
// This one is for the Twig template
// We do not need the IP here. No use of showing the IP at all?
$context_embargo = ['data_embargo' => ['embargoed' => false, 'until' => NULL]];
$embargo_tags = [];
if (is_array($embargo_info)) {
$embargoed = $embargo_info[0];
$context_embargo['data_embargo']['embargoed'] = $embargoed;
Expand Down
4 changes: 2 additions & 2 deletions src/Plugin/Field/FieldFormatter/Strawberry3DFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
$upload_keys = explode(',', $upload_keys_string);
$upload_keys = array_filter($upload_keys);
$upload_keys = array_map('trim', $upload_keys);
$embargo_context = [];
$embargo_tags = [];

$embargo_upload_keys_string = strlen(trim($this->getSetting('embargo_json_key_source'))) > 0 ? trim($this->getSetting('embargo_json_key_source')) : NULL;
$embargo_upload_keys_string = explode(',', $embargo_upload_keys_string);
Expand Down Expand Up @@ -170,8 +172,6 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
}*/
$embargo_info = $this->embargoResolver->embargoInfo($items->getEntity()->uuid(), $jsondata);
// Check embargo
$embargo_context = [];
$embargo_tags = [];
if (is_array($embargo_info)) {
$embargoed = $embargo_info[0];
$embargo_tags[] = 'format_strawberryfield:all_embargo';
Expand Down
4 changes: 2 additions & 2 deletions src/Plugin/Field/FieldFormatter/StrawberryAudioFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
$upload_keys_string = strlen(trim($this->getSetting('upload_json_key_source'))) > 0 ? trim($this->getSetting('upload_json_key_source')) : NULL;
$upload_keys = explode(',', $upload_keys_string);
$upload_keys = array_filter($upload_keys);
$embargo_context = [];
$embargo_tags = [];

$embargo_upload_keys_string = strlen(trim($this->getSetting('embargo_json_key_source'))) > 0 ? trim($this->getSetting('embargo_json_key_source')) : NULL;
$embargo_upload_keys_string = explode(',', $embargo_upload_keys_string);
Expand Down Expand Up @@ -187,8 +189,6 @@ public function viewElements(FieldItemListInterface $items, $langcode) {

$embargo_info = $this->embargoResolver->embargoInfo($items->getEntity()->uuid(), $jsondata);
// Check embargo
$embargo_context = [];
$embargo_tags = [];
if (is_array($embargo_info)) {
$embargoed = $embargo_info[0];
$embargo_tags[] = 'format_strawberryfield:all_embargo';
Expand Down
4 changes: 2 additions & 2 deletions src/Plugin/Field/FieldFormatter/StrawberryMediaFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
$upload_keys = explode(',', $upload_keys_string);
$upload_keys = array_filter($upload_keys);
$upload_keys = array_map('trim', $upload_keys);
$embargo_context = [];
$embargo_tags = [];

$embargo_upload_keys_string = strlen(trim($this->getSetting('embargo_json_key_source'))) > 0 ? trim($this->getSetting('embargo_json_key_source')) : NULL;
$embargo_upload_keys_string = explode(',', $embargo_upload_keys_string);
Expand Down Expand Up @@ -204,8 +206,6 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
$embargo_info = $this->embargoResolver->embargoInfo($items->getEntity()
->uuid(), $jsondata);
// Check embargo
$embargo_context = [];
$embargo_tags = [];
if (is_array($embargo_info)) {
$embargoed = $embargo_info[0];
$embargo_tags[] = 'format_strawberryfield:all_embargo';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
$usemetadatalabel = $this->getSetting('metadatadisplayentity_uselabel');
$metadatadisplayentity_uuid = $this->getSetting('metadatadisplayentity_uuid');
$nodeid = $items->getEntity()->id();
$embargo_context = [];
$embargo_tags = [];

foreach ($items as $delta => $item) {
$main_property = $item->getFieldDefinition()->getFieldStorageDefinition()->getMainPropertyName();
Expand Down Expand Up @@ -229,11 +231,10 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
return $elements[$delta] = ['#markup' => $message];
}
$embargo_info = $this->embargoResolver->embargoInfo($items->getEntity()->uuid(), $jsondata);
$embargo_context = [];
// This one is for the Twig template
// We do not need the IP here. No use of showing the IP at all?
$context_embargo = ['data_embargo' => ['embargoed' => false, 'until' => NULL]];
$embargo_tags = [];

if (is_array($embargo_info)) {
$embargoed = $embargo_info[0];
$context_embargo['data_embargo']['embargoed'] = $embargoed;
Expand Down
5 changes: 3 additions & 2 deletions src/Plugin/Field/FieldFormatter/StrawberryPagedFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,8 @@ public function processElementforMetadatadisplays($delta, array $jsondata, Field
$max_width = $this->getSetting('max_width');
$max_width_css = empty($max_width) || $max_width == 0 ? '100%' : $max_width .'px';
$max_height = $this->getSetting('max_height');
$embargo_context = [];
$embargo_tags = [];

if ($this->getSetting('metadatadisplayentity_uuid')) {
/* @var $metadatadisplayentity \Drupal\format_strawberryfield\Entity\MetadataDisplayEntity */
Expand All @@ -395,11 +397,10 @@ public function processElementforMetadatadisplays($delta, array $jsondata, Field
StrawberryfieldJsonHelper::orderSequence($jsondata, $mainkey, $ordersubkey);

$embargo_info = $this->embargoResolver->embargoInfo($item->getEntity()->uuid(), $jsondata);
$embargo_context = [];
// This one is for the Twig template
// We do not need the IP here. No use of showing the IP at all?
$context_embargo = ['data_embargo' => ['embargoed' => false, 'until' => NULL]];
$embargo_tags = [];

if (is_array($embargo_info)) {
$embargoed = $embargo_info[0];
$context_embargo['data_embargo']['embargoed'] = $embargoed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
$upload_keys = explode(',', $upload_keys_string);
$upload_keys = array_filter($upload_keys);
$upload_keys = array_map('trim', $upload_keys);
$embargo_context = [];
$embargo_tags = [];

$embargo_upload_keys_string = strlen(trim($this->getSetting('embargo_json_key_source'))) > 0 ? trim($this->getSetting('embargo_json_key_source')) : NULL;
$embargo_upload_keys_string = explode(',', $embargo_upload_keys_string);
Expand Down Expand Up @@ -297,11 +299,10 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
}

$embargo_info = $this->embargoResolver->embargoInfo($item->getEntity()->uuid(), $jsondata);
$embargo_context = [];
// This one is for the Twig template
// We do not need the IP here. No use of showing the IP at all?
$context_embargo = ['data_embargo' => ['embargoed' => false, 'until' => NULL]];
$embargo_tags = [];

if (is_array($embargo_info)) {
$embargoed = $embargo_info[0];
$context_embargo['data_embargo']['embargoed'] = $embargoed;
Expand Down
4 changes: 2 additions & 2 deletions src/Plugin/Field/FieldFormatter/StrawberryPdfFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
$upload_keys_string = strlen(trim($this->getSetting('upload_json_key_source'))) > 0 ? trim($this->getSetting('upload_json_key_source')) : NULL;
$upload_keys = explode(',', $upload_keys_string);
$upload_keys = array_filter($upload_keys);
$embargo_context = [];
$embargo_tags = [];

$embargo_upload_keys_string = strlen(trim($this->getSetting('embargo_json_key_source'))) > 0 ? trim($this->getSetting('embargo_json_key_source')) : NULL;
$embargo_upload_keys_string = explode(',', $embargo_upload_keys_string);
Expand Down Expand Up @@ -209,11 +211,9 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
},
}*/
$embargo_info = $this->embargoResolver->embargoInfo($items->getEntity()->uuid(), $jsondata);
$embargo_context = [];
// This one is for the Twig template
// We do not need the IP here. No use of showing the IP at all?
$context_embargo = ['data_embargo' => ['embargoed' => false, 'until' => NULL]];
$embargo_tags = [];
if (is_array($embargo_info)) {
$embargoed = $embargo_info[0];
$context_embargo['data_embargo']['embargoed'] = $embargoed;
Expand Down
4 changes: 2 additions & 2 deletions src/Plugin/Field/FieldFormatter/StrawberryVideoFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
$upload_keys_string = strlen(trim($this->getSetting('upload_json_key_source'))) > 0 ? trim($this->getSetting('upload_json_key_source')) : NULL;
$upload_keys = explode(',', $upload_keys_string);
$upload_keys = array_filter($upload_keys);
$embargo_context = [];
$embargo_tags = [];

$embargo_upload_keys_string = strlen(trim($this->getSetting('embargo_json_key_source'))) > 0 ? trim($this->getSetting('embargo_json_key_source')) : NULL;
$embargo_upload_keys_string = explode(',', $embargo_upload_keys_string);
Expand Down Expand Up @@ -221,8 +223,6 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
$embargo_info = $this->embargoResolver->embargoInfo($items->getEntity()
->uuid(), $jsondata);
// Check embargo
$embargo_context = [];
$embargo_tags = [];
if (is_array($embargo_info)) {
$embargoed = $embargo_info[0];
$embargo_tags[] = 'format_strawberryfield:all_embargo';
Expand Down
4 changes: 2 additions & 2 deletions src/Plugin/Field/FieldFormatter/StrawberryWarcFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
$nodeid = $items->getEntity()->id();
$number_media = $this->getSetting('number_media') ?? 1;
$key = $this->getSetting('json_key_source');
$embargo_context = [];
$embargo_tags = [];

$nodeuuid = $items->getEntity()->uuid();
$nodeid = $items->getEntity()->id();
Expand Down Expand Up @@ -195,8 +197,6 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
$embargo_info = $this->embargoResolver->embargoInfo($items->getEntity()
->uuid(), $jsondata);
// Check embargo
$embargo_context = [];
$embargo_tags = [];
if (is_array($embargo_info)) {
$embargoed = $embargo_info[0];
$embargo_tags[] = 'format_strawberryfield:all_embargo';
Expand Down