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

Refactoring Loaders & Renders #3

Merged
merged 13 commits into from
Apr 17, 2017

Conversation

WengerK
Copy link
Member

@WengerK WengerK commented Apr 1, 2017

When merged, should refactore also every other Twig Extension to use the new Drupal\bamboo_twig\TwigExtensionTwigExtensionBase.

Loader
run test with ../../vendor/bin/phpunit --group bamboo_twig_loader --printer="\Drupal\Tests\Listeners\HtmlOutputPrinter"

Render
run test with ../../vendor/bin/phpunit --group bamboo_twig_render --printer="\Drupal\Tests\Listeners\HtmlOutputPrinter"

or more globally with ../../vendor/bin/phpunit --group bamboo_twig --printer="\Drupal\Tests\Listeners\HtmlOutputPrinter"

* Load a given block with or whitout parameters.
*/
public function renderForm($module, $form, $params = []) {
return $this->getFormBuilder()->getForm('Drupal\\' . $module . '\Form\\' . $form, $params);
Copy link
Member

Choose a reason for hiding this comment

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

check if \Form should be \\Form.

}

/**
* Load a given block with or whitout parameters.
Copy link
Member

Choose a reason for hiding this comment

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

Update DocBlock

}

/**
* Load a given block with or whitout parameters.
Copy link
Member

Choose a reason for hiding this comment

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

Update DocBlock (parameters)

Copy link
Member Author

Choose a reason for hiding this comment

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

done

* @return array
* A render array to display the region content.
*/
public function renderRegion($region, $theme = NULL) {
Copy link
Member

Choose a reason for hiding this comment

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

I propose to remove this feature.
I don't see the usecase

* @param mixed $id
* (optional) The ID of the entity to render.
* @param string $formatter
* (optional) The formatter that should be used to render the field.
Copy link
Member

Choose a reason for hiding this comment

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

Add examples values

* @return null|array
* A render array for the field or NULL if the value does not exist.
*/
public function renderField($field_name, $entity_type, $id = NULL, $formatter = NULL, $langcode = NULL) {
Copy link
Member

Choose a reason for hiding this comment

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

switch $formatter and $langcode

}

if (isset($entity->{$field_name})) {
return $entity->{$field_name}->view($display_options);
Copy link
Member

Choose a reason for hiding this comment

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

I prefer $entity->get($field_name)

new \Twig_SimpleFunction('bamboo_load_entity', [$this, 'loadEntity']),
new \Twig_SimpleFunction('bamboo_load_field', [$this, 'loadField']),
new \Twig_SimpleFunction('bamboo_load_currentuser', [$this, 'loadCurrentUser']),
new \Twig_SimpleFunction('bamboo_load_image', [$this, 'loadImage']),
Copy link
Member

Choose a reason for hiding this comment

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

add bamboo_load_menu ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Create a issue for this here : #7
People will chose.

<h2>Loader Image</h2>
<hr>
{% set image = bamboo_load_image('public://antistatique.png') %}
<div class="loader-image-uri">{{ image.getSource }}</div>
Copy link
Member

Choose a reason for hiding this comment

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

replace by image.getSource() if this is a method

Copy link
Member

Choose a reason for hiding this comment

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

or image.source

@tonifisler tonifisler merged commit 802248f into 8.x-2.x-dev Apr 17, 2017
@tonifisler tonifisler deleted the 8.x-2.x-dev--refactoring-loaders branch April 17, 2017 10:20
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.

3 participants