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

Fix widgets: Only setRendered if widget didn't return null #1791

Merged
merged 2 commits into from
Aug 31, 2020
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
32 changes: 16 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
"ext-mbstring": "*",
"ext-pdo": "*",
"api-platform/core": "^2.5",
"babdev/pagerfanta-bundle": "^2.4",
"beberlei/doctrineextensions": "^1.0",
"babdev/pagerfanta-bundle": "^2.5",
"beberlei/doctrineextensions": "^1.2",
"bolt/common": "^2.1.6",
"cocur/slugify": "^4.0",
"composer/composer": "^1.10",
"composer/package-versions-deprecated": "^1.8",
"doctrine/doctrine-bundle": "^2.0",
"composer/package-versions-deprecated": "^1.11",
"doctrine/doctrine-bundle": "^2.1",
"doctrine/doctrine-fixtures-bundle": "^3.3",
"doctrine/orm": "^2.7",
"drupol/composer-packages": "^1.1",
Expand All @@ -26,15 +26,15 @@
"knplabs/knp-menu-bundle": "^3.0",
"league/glide-symfony": "^1.0",
"miljar/php-exif": "^0.6.4",
"nelmio/cors-bundle": "^2.0",
"nesbot/carbon": "^2.28",
"nelmio/cors-bundle": "^2.1",
"nesbot/carbon": "^2.39",
"peterkahl/country-code-to-emoji-flag": "^1.2",
"php-translation/symfony-bundle": "^0.12",
"phpdocumentor/reflection-docblock": "^4.3",
"psr/event-dispatcher": "^1.0",
"psr/simple-cache": "^1.0",
"scienta/doctrine-json-functions": "^4.1",
"sensio/framework-extra-bundle": "^5.5",
"sensio/framework-extra-bundle": "^5.6",
"sensiolabs/security-checker": "^6.0",
"siriusphp/upload": "^3.0.1",
"squirrelphp/twig-php-syntax": "^1.5",
Expand All @@ -44,7 +44,7 @@
"symfony/dependency-injection": "^4.4 | ^5.1",
"symfony/dotenv": "^4.4 | ^5.1",
"symfony/expression-language": "^4.4 | ^5.1",
"symfony/flex": "^1.6",
"symfony/flex": "^1.9",
"symfony/form": "^4.4 | ^5.1",
"symfony/framework-bundle": "^4.4 | ^5.1",
"symfony/http-client": "^4.4 | ^5.1",
Expand All @@ -64,10 +64,10 @@
"symfony/web-server-bundle": "^4.4",
"symfony/webpack-encore-bundle": "^1.7",
"symfony/yaml": "^4.4 | ^5.1",
"tightenco/collect": "^7.4",
"tightenco/collect": "^7.25",
"twig/twig": "^3.0",
"ua-parser/uap-php": "^3.9",
"webimpress/safe-writer": "^2.0",
"webimpress/safe-writer": "^2.1",
"webmozart/path-util": "^2.3",
"webonyx/graphql-php": "^0.13",
"xemlock/htmlpurifier-html5": "^0.1.11"
Expand All @@ -78,23 +78,23 @@
"require-dev": {
"ext-curl": "*",
"ext-pdo_sqlite": "*",
"acmecorp/reference-extension": "^1.0",
"acmecorp/reference-extension": "^1.2",
"behat/mink-goutte-driver": "^1.2",
"behat/mink-selenium2-driver": "^1.4",
"behatch/contexts": "^3.2",
"bobdenotter/configuration-notices": "^1.0",
"behatch/contexts": "^3.3",
"bobdenotter/configuration-notices": "^1.1",
"bobdenotter/weatherwidget": "^1.1",
"bolt/newswidget": "^1.1",
"bolt/newswidget": "^1.2",
"coduo/php-matcher": "^4.0",
"dama/doctrine-test-bundle": "^6.2.0",
"doctrine/doctrine-migrations-bundle": "^2.1",
"doctrine/doctrine-migrations-bundle": "^2.2",
"friends-of-behat/mink": "^1.8",
"friends-of-behat/mink-browserkit-driver": "^1.4",
"friends-of-behat/symfony-extension": "^2.1",
"lakion/mink-debug-extension": "^1.2",
"php-http/httplug-pack": "^1.2",
"php-translation/loco-adapter": "^0.11",
"phpspec/phpspec": "^6.1.1",
"phpspec/phpspec": "^6.2.1",
"phpspec/prophecy": "^1.10",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-doctrine": "^0.12",
Expand Down
3 changes: 2 additions & 1 deletion src/Configuration/Content/FieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ private static function defaults(): Collection
'pattern' => false,
'hidden' => false,
'default_locale' => 'en',
'height' => '10', // 10 rows by default
// 10 rows by default
'height' => '10',
]);
}

Expand Down
6 changes: 1 addition & 5 deletions src/Event/Listener/ContentFillListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,14 @@ class ContentFillListener
/** @var UserRepository */
private $users;

/** @var string */
private $defaultLocale;

/** @var FieldRepository */
private $fieldRepository;

public function __construct(Config $config, ContentExtension $contentExtension, UserRepository $users, string $defaultLocale, FieldRepository $fieldRepository)
public function __construct(Config $config, ContentExtension $contentExtension, UserRepository $users, FieldRepository $fieldRepository)
{
$this->config = $config;
$this->contentExtension = $contentExtension;
$this->users = $users;
$this->defaultLocale = $defaultLocale;
$this->fieldRepository = $fieldRepository;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Storage/Handler/SelectQueryHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function __invoke(ContentQueryParser $contentQuery)
return $this->createPaginator($request, $query, $amountPerPage, $page);
}

private function createPaginator(?Request $request, Query $query, int $amountPerPage, int $page = null): Pagerfanta
private function createPaginator(?Request $request, Query $query, int $amountPerPage, ?int $page = null): Pagerfanta
{
$paginator = new Pagerfanta(new DoctrineORMAdapter($query, true, true));
$paginator->setMaxPerPage($amountPerPage);
Expand Down
2 changes: 1 addition & 1 deletion src/Storage/SelectQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ public function doTaxonomyJoins(): void
*/
public function doFieldJoins(): void
{
foreach ($this->fieldJoins as $key => $filter) {
foreach (array_keys($this->fieldJoins) as $key) {
$contentAlias = 'content';
$fieldsAlias = 'fields_' . $key;
$translationsAlias = 'translations_' . $key;
Expand Down
2 changes: 1 addition & 1 deletion src/Twig/ContentExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ public function getListTemplates(TemplateselectField $field): LaravelCollection
return new LaravelCollection($options);
}

public function pager(Environment $twig, Pagerfanta $records = null, string $template = '@bolt/helpers/_pager_basic.html.twig', string $class = 'pagination', int $surround = 3)
public function pager(Environment $twig, ?Pagerfanta $records = null, string $template = '@bolt/helpers/_pager_basic.html.twig', string $class = 'pagination', int $surround = 3)
{
$params = array_merge(
$this->request->get('_route_params'),
Expand Down
3 changes: 2 additions & 1 deletion src/Twig/FieldExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ public function getSelected(Field\SelectField $field, $returnsingle = false, $re
}

$ids = $field->getValue();
$records = $this->contentRepository->findBy(['id' => $ids]); // Find records by their respective ids
// Find records by their respective ids
$records = $this->contentRepository->findBy(['id' => $ids]);

if ($returnsingle || (! $returnarray && $definition->get('multiple') === false)) {
return current($records);
Expand Down
7 changes: 6 additions & 1 deletion src/Widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,18 @@ private function invokeWidget(WidgetInterface $widget, array $params = []): ?str
}

// Call the magic `__invoke` method on the $widget object
// It can return a string (even an empty one) or `null`
$output = $widget($params);

if ($widget instanceof StopwatchAwareInterface) {
$widget->stopStopwatch();
}

$this->setRendered($widget, $output);
// Set the output as rendered for this Request, unless invoking it
// returned `null`
if ($output !== null) {
$this->setRendered($widget, $output);
}

return $output;
}
Expand Down
9 changes: 9 additions & 0 deletions symfony.lock
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@
"config/packages/test/dama_doctrine_test_bundle.yaml"
]
},
"dealerdirect/phpcodesniffer-composer-installer": {
"version": "v0.7.0"
},
"doctrine/annotations": {
"version": "1.0",
"recipe": {
Expand Down Expand Up @@ -509,6 +512,9 @@
"phpspec/prophecy": {
"version": "v1.10.2"
},
"phpstan/phpdoc-parser": {
"version": "0.4.9"
},
"phpstan/phpstan": {
"version": "0.12.11"
},
Expand Down Expand Up @@ -661,6 +667,9 @@
"siriusphp/validation": {
"version": "2.3.0"
},
"slevomat/coding-standard": {
"version": "6.4.0"
},
"squirrelphp/twig-php-syntax": {
"version": "v1.5"
},
Expand Down