-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
* Load a given block with or whitout parameters. | ||
*/ | ||
public function renderForm($module, $form, $params = []) { | ||
return $this->getFormBuilder()->getForm('Drupal\\' . $module . '\Form\\' . $form, $params); |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update DocBlock (parameters)
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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']), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add bamboo_load_menu
?
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or image.source
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"