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

wsdata fields & wsdata block #2

Merged
merged 35 commits into from
Dec 4, 2017

Conversation

morinluc0
Copy link
Collaborator

@morinluc0 morinluc0 commented Oct 31, 2017

wsdata field implementation
wsdata block implementation

Better header control for the simple http connector.
Implemented the wscall call function

Luc Morin added 25 commits October 26, 2017 15:34
Modifying the storage controller to be a custom value.
…wsfieldconfig entity type, added the action, the form.
…ace the computed field values with the values returned from the service.
…routes dynamically the file was not needed.
@morinluc0 morinluc0 changed the title WIP: wsdata fields wsdata fields & wsdata block Nov 13, 2017
* {@inheritdoc}
*/
public function build() {
// Fetch the wscall.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use the wsdata service. Also, use dependency injection.

public function blockForm($form, FormStateInterface $form_state) {

// Load the wscall entities.
$wscalls = entity_load_multiple('wscall');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should write a method for the wscall's to generate their own forms instead of having multiple implementations of essentially the same form.

$options[$wscall->id()] = $wscall->label();
}

$form['wscall'] = [
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's that wscall and replacements form again.

$cid_array = array_merge($options, $this->getOptions(), $replacements, $tokens, array('data' => $data, 'key' => $key));
$cid = md5(serialize($cid_array));
if ($cache = \Drupal::cache('wsdata')->get($cid)) {
$cache_data = $cache->data;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of wrapping the entire contents of this function in an "else", just return early if you have the data in the cache.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the return early.

}

if ($cache_data) {
$this->addData($cache_data);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are you getting/setting expires times? Are the results permanently cached?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have fixed the caching system ready to be reviewed.

@@ -88,6 +88,7 @@ public function call(array $form, FormStateInterface $form_state) {
foreach ($this->entity->getReplacements() as $replacement) {
$replacements[$replacement] = $form_state->getValue($replacement);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Third place that has the WSCall form.

}

// Fetch the cache tags for this call and the server instance call.
$cache_tags = array_merge($this->wsserverInst->getCacheTags(), $this->getCacheTags());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are the encoder and decoders getting applied to the data?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Encoders I can't see anywhere where they were implemented? I figure they should be part of the WSCall entity in the Call function that way they can be applied globally ?

Decoders are applied on the WSCall addData & getData function.

}
}

$form['body'] = [
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Body shouldn't be here. Body is the payload. WSdata->call has a special argument just for it. Also, how would the encoder/decoder get applied?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I am going to move this into the custom form that way the payload can be modified for each block/field.

MorinLuc0 added 9 commits November 22, 2017 14:25
- Fixing the caching layer for simple http connector
- Removed the body from the connector
- Fix the encoder and decoder
- Added the encoders on the wscall
- Use the services in the block
…potzero/wsdata into wsdata-fields-implementation-8-version

Conflicts:
	modules/wsdata_field/src/Plugin/views/field/WSDataFieldsViews.php
@spotzero spotzero merged commit fa44e33 into 8.x-1.x Dec 4, 2017
@spotzero spotzero deleted the wsdata-fields-implementation-8-version branch December 4, 2017 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants