Skip to content

Commit

Permalink
Merge pull request #91 from esmero/ISSUE-90
Browse files Browse the repository at this point in the history
ISSUE-90: Final commits for D9 readiness/spiciness
  • Loading branch information
DiegoPino authored Jul 9, 2020
2 parents 925fb58 + 63d3835 commit d5d4f0c
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 19 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
}
],
"require": {
"drupal/core": "^8.8 || ^9",
"ml/json-ld": "^1.1",
"mtdowling/jmespath.php":"^2.5",
"swaggest/json-schema":"^0.12.25",
Expand Down
2 changes: 1 addition & 1 deletion src/Event/StrawberryfieldCrudEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class StrawberryfieldCrudEvent extends Event {
* @var array
*
*/
private $processedby;
private $processedby = [];

/**
* Construct a new entity event.
Expand Down
3 changes: 1 addition & 2 deletions src/Form/keyNameProviderEntityDeleteForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public function getConfirmText() {
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->entity->delete();

drupal_set_message(
$this->messenger()->addMessage(
$this->t('content @type: deleted @label.',
[
'@type' => $this->entity->bundle(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function process($langcode = NULL)
$jmespath_array = array_map('trim', explode(',', $jmespaths));
$jmespath_result = [];
foreach ($jmespath_array as $jmespath) {
$jmespath_result[] = $item->searchPath($jmespath,FALSE);
$jmespath_result[] = $item->searchPath(trim($jmespath),FALSE);
}
$jmespath_result_to_expose = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static function defaultStorageSettings() {
'target_type' => 'file',
'display_field' => FALSE,
'display_default' => FALSE,
'uri_scheme' => file_default_scheme(),
'uri_scheme' => \Drupal::config('system.file')->get('default_scheme')
] + parent::defaultStorageSettings();
}

Expand Down
5 changes: 3 additions & 2 deletions src/Plugin/StrawberryfieldKeyNameProviderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
namespace Drupal\strawberryfield\Plugin;
use Drupal\Component\Plugin\PluginInspectionInterface;
use Drupal\Core\Plugin\PluginWithFormsInterface;
use Drupal\Component\Plugin\ConfigurablePluginInterface;
use Drupal\Component\Plugin\ConfigurableInterface;
use Drupal\Component\Plugin\DependentPluginInterface;

/**
* Defines and Interface for StrawberryfieldKeyNameProvider Plugins
Expand All @@ -18,7 +19,7 @@
*
* @package Drupal\strawberryfield\Plugin
*/
interface StrawberryfieldKeyNameProviderInterface extends PluginInspectionInterface, PluginWithFormsInterface, ConfigurablePluginInterface{
interface StrawberryfieldKeyNameProviderInterface extends PluginInspectionInterface, PluginWithFormsInterface, ConfigurableInterface, DependentPluginInterface{


/**
Expand Down
10 changes: 5 additions & 5 deletions src/StrawberryfieldFilePersisterService.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ public function getDestinationUri(
$current_uri,
PATHINFO_EXTENSION
);
$file_parts['destination_scheme'] = $this->fileSystem->uriScheme(
$file->getFileUri()
);
$file_parts['destination_scheme'] = $this->streamWrapperManager
->getScheme($current_uri);

list($file_parts['destination_filetype'],) = explode(
'/',
$file->getMimeType()
Expand Down Expand Up @@ -1024,13 +1024,13 @@ public function getBaseFileMetadata(FileInterface $file) {
$output_exif = '';
$output_fido = '';
$result_exif = exec(
$exif_exec_path . ' -json -q -a -gps:all -Common "-gps*" -xmp:all -ImageWidth -ImageHeight -Canon -Nikon-AllDates -pdf:all -ee -MIMEType ' . escapeshellcmd($templocation),
$exif_exec_path . ' -json -q -a -gps:all -Common "-gps*" -xmp:all -ImageWidth -ImageHeight -Canon -Nikon-AllDates -pdf:all -ee -MIMEType ' . escapeshellarg($templocation),
$output_exif,
$status_exif
);

$result_fido = exec(
$fido_exec_path . ' ' . escapeshellcmd($templocation),
$fido_exec_path . ' ' . escapeshellarg($templocation),
$output_fido,
$status_fido
);
Expand Down
3 changes: 1 addition & 2 deletions strawberryfield.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ name: Strawberry Field
description: Creates a field type that stores JSON and makes it available to other Drupal modules.
package: Archipelago
type: module
core: 8.x
core_version_requirement: ^8.8 || ^9
php: 7.1
dependencies:
- 'drupal:system (>= 8.7)'
- 'drupal:user'
- 'drupal:field'
- 'drupal:serialization'
Expand Down
16 changes: 11 additions & 5 deletions strawberryfield.module
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ function strawberryfield_node_presave(ContentEntityInterface $entity) {
// When benchmark is enabled a simple but effective report will be found in the reports/logs
if ($config->get('benchmark')) {
$bench = TRUE;
$start_time = microtime(true);
}
// Introducing our newest development, the processing time stats!
// Starting on PHP 7.3 we should use hrtime for docker and VMS.
// https://www.php.net/manual/en/function.microtime.php
$start_time = microtime(true);

//@TODO make bench simply an Event Method! That way we can measure every
//Event by calling it and for new ones. Etc.

Expand All @@ -49,16 +50,21 @@ function strawberryfield_node_presave(ContentEntityInterface $entity) {
if ($bench) {
$end_time = microtime(TRUE);
// Removed bsuc
$time = round($end_time, $start_time, 4);
$time = round($end_time - $start_time, 4);
$max_memory = memory_get_peak_usage(TRUE);
$events = implode("\n\r",$event->getProcessedBy());
$events = '';
foreach($event->getProcessedBy() as $event_info) {
$success = $event_info['success']? 'Successful' : 'Failure';
$events .= '<li>'.$event_info['class']. ' => '.$success.'</li>';
}
$events_markup = \Drupal\Core\Render\Markup::create($events);
\Drupal::logger('strawberryfield')->notice(
'ADO with UUID @uuid spend @time in seconds on all presave event subscriber processing and max memory usage was @maxmem. Event Subscribers that run where the following <br> @events',
'ADO with UUID @uuid spent @time seconds on all presave event subscriber processing and max memory usage was @maxmem. <br> Event Subscribers that could run were the following: <br><ul>@events</ul>',
[
'@uuid' => $entity->uuid(),
'@time' => $time,
'@maxmem' => \Drupal::service('strawberryfield.utility')->formatBytes($max_memory, 2),
'@events' => $events,
'@events' => $events_markup,
]
);
}
Expand Down

0 comments on commit d5d4f0c

Please sign in to comment.