author
int64 658
755k
| date
stringlengths 19
19
| timezone
int64 -46,800
43.2k
| hash
stringlengths 40
40
| message
stringlengths 5
490
| mods
list | language
stringclasses 20
values | license
stringclasses 3
values | repo
stringlengths 5
68
| original_message
stringlengths 12
491
|
---|---|---|---|---|---|---|---|---|---|
95,144 |
10.03.2019 12:22:13
| -3,600 |
f64e8c2417ec0a7b72ab261494c296ce89e06919
|
Properly escaping fields that go into Vue
|
[
{
"change_type": "MODIFY",
"old_path": "templates/_partials/_content_listing.html.twig",
"new_path": "templates/_partials/_content_listing.html.twig",
"diff": "<listing-records\ntype=\"{{ type }}\"\n{# tricky part: https://github.com/whiteoctober/WhiteOctoberPagerfantaBundle/issues/165#issuecomment-462777227 #}\n- :data=\"{{ records|merge([])|json_encode }}\"\n+ :data=\"{{ records|merge([])|json_encode|e }}\"\n>\n</listing-records>\n<!-- end listing records -->\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/_partials/fields/email.html.twig",
"new_path": "templates/_partials/fields/email.html.twig",
"diff": "<field-email\n:id=\"'{{ id }}'\"\n:name=\"'{{ name }}'\"\n- :value=\"{{ value|json_encode() }}\"\n+ :value=\"{{ value|json_encode()|e }}\"\n></field-email>\n{% endblock %}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/_partials/fields/html.html.twig",
"new_path": "templates/_partials/fields/html.html.twig",
"diff": "{% block field %}\n<editor-html\n- :value=\"'{{ value|json_encode() }}'\"\n+ :value=\"{{ value|json_encode()|e }}\"\n:name=\"'{{ name }}'\"\n></editor-html>\n{% endblock %}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/_partials/fields/markdown.html.twig",
"new_path": "templates/_partials/fields/markdown.html.twig",
"diff": "{% block field %}\n<editor-markdown\n- :value=\"'{{value|json_encode()}}'\"\n+ :value='{{ value|json_encode()|e }}'\n:name=\"'{{ name }}'\"\n></editor-markdown>\n{% endblock %}\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/_partials/fields/password.html.twig",
"new_path": "templates/_partials/fields/password.html.twig",
"diff": "<field-password\n:id=\"'{{ id }}'\"\n:name=\"'{{ name }}'\"\n- :value=\"{{ value|json_encode() }}\"\n+ :value=\"{{ value|json_encode()|e }}\"\n></field-password>\n{% endblock %}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/_partials/fields/select.html.twig",
"new_path": "templates/_partials/fields/select.html.twig",
"diff": "{% block field %}\n{#<pre><code>{{ value|json_encode() }}</code></pre>#}\n<editor-select\n- :value=\"{{ value|json_encode() }}\"\n+ :value=\"{{ value|json_encode()|e }}\"\n:name=\"'{{ name }}'\"\n:id=\"'{{ id }}'\"\n- :options=\"{{ options|json_encode() }}\"\n+ :options=\"{{ options|json_encode()|e }}\"\n:form=\"'{{ form }}'\"\n:multiple=\"{{ multiple }}\"\n:allowempty=\"{{ allowempty }}\"\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/_partials/fields/text.html.twig",
"new_path": "templates/_partials/fields/text.html.twig",
"diff": "{% block field %}\n<editor-text\n:id=\"'{{ id }}'\"\n- :value=\"{{ value|json_encode() }}\"\n+ :value=\"{{ value|json_encode()|e }}\"\n:name=\"'{{ name }}'\"\n:type=\"'{{ class }}'\"\n:disabled=\"'{{ disabled }}'\"\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/_partials/fields/textarea.html.twig",
"new_path": "templates/_partials/fields/textarea.html.twig",
"diff": "{% block field %}\n<editor-textarea\n- :value='{{ value|json_encode() }}'\n+ :value='{{ value|json_encode()|e }}'\n:label=\"'{{ label }}'\"\n:name=\"'{{ name }}'\"\n></editor-textarea>\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Properly escaping fields that go into Vue
|
95,144 |
10.03.2019 13:01:51
| -3,600 |
afdec8c4c3683b6aa3cec2ed19ffec289a8a3c34
|
Escape language select
|
[
{
"change_type": "MODIFY",
"old_path": "templates/content/_localeswitcher.html.twig",
"new_path": "templates/content/_localeswitcher.html.twig",
"diff": "<general-language\nlabel=\"{{ 'field.switch_to_locale'|trans }}\"\ncurrent=\"{{ currentlocale }}\"\n- :locales=\"{{ contentlocales(locales) }}\"\n+ :locales=\"{{ contentlocales(locales)|e }}\"\n></general-language>\n<a href=\"{{ path('bolt_content_edit_locales', {'id': record.id}) }}\" class=\"btn btn-light btn-small\">\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Escape language select
|
95,144 |
10.03.2019 13:22:59
| -3,600 |
e93f954b759becb1988566372c728791e2691772
|
Second attempt, less hackish
|
[
{
"change_type": "MODIFY",
"old_path": "config/packages/twig.yaml",
"new_path": "config/packages/twig.yaml",
"diff": "twig:\ndebug: '%kernel.debug%'\nstrict_variables: true\n- autoescape: false\nform_themes:\n- 'form/layout.twig'\n- 'form/fields.twig'\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Entity/Content.php",
"new_path": "src/Entity/Content.php",
"diff": "@@ -450,12 +450,18 @@ class Content implements \\JsonSerializable\n* - {{ record.image }} => field named image\n* - {{ record|image }} => value of guessed image field\n*/\n- public function __call(string $name, array $arguments = []): Field\n+ public function __call(string $name, array $arguments = [])\n{\ntry {\n- return $this->getField($name);\n+ $field = $this->getField($name);\n} catch (\\InvalidArgumentException $e) {\nthrow new \\RuntimeException(sprintf('Invalid field name or method call on %s: %s', $this->__toString(), $name));\n}\n+\n+ if ($field->getDefinition()->get('allow_markup')) {\n+ $field = new \\Twig_Markup($field, 'UTF-8');\n+ }\n+\n+ return $field;\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Entity/Field.php",
"new_path": "src/Entity/Field.php",
"diff": "@@ -105,10 +105,6 @@ class Field implements Translatable\n{\n$stringValue = implode(', ', $this->getValue());\n- if (! $this->getDefinition()->get('allow_markup')) {\n- $stringValue = htmlentities($stringValue);\n- }\n-\nreturn $stringValue;\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Second attempt, less hackish
|
95,144 |
10.03.2019 13:46:43
| -3,600 |
d18e50e660e3b62c7c21d57e8360231009eae343
|
Well, that took the better part of my weekend.
|
[
{
"change_type": "MODIFY",
"old_path": "templates/_partials/fields/markdown.html.twig",
"new_path": "templates/_partials/fields/markdown.html.twig",
"diff": "{% block field %}\n<editor-markdown\n- :value='{{ value|json_encode()|e }}'\n+ :value='{{ value|json_encode() }}'\n:name=\"'{{ name }}'\"\n></editor-markdown>\n{% endblock %}\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/_partials/fields/password.html.twig",
"new_path": "templates/_partials/fields/password.html.twig",
"diff": "<field-password\n:id=\"'{{ id }}'\"\n:name=\"'{{ name }}'\"\n- :value=\"{{ value|json_encode()|e }}\"\n+ :value=\"{{ value|json_encode() }}\"\n></field-password>\n{% endblock %}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/_partials/fields/text.html.twig",
"new_path": "templates/_partials/fields/text.html.twig",
"diff": "{% block field %}\n<editor-text\n:id=\"'{{ id }}'\"\n- :value=\"{{ value|json_encode()|e }}\"\n+ :value=\"{{ value|json_encode() }}\"\n:name=\"'{{ name }}'\"\n:type=\"'{{ class }}'\"\n:disabled=\"'{{ disabled }}'\"\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Well, that took the better part of my weekend.
|
95,144 |
11.03.2019 13:16:44
| -3,600 |
c2c398102999699ddc48db90f8417b158c51342f
|
Rename `allow_markup` to `allow_html`
|
[
{
"change_type": "MODIFY",
"old_path": "config/bolt/contenttypes.yaml",
"new_path": "config/bolt/contenttypes.yaml",
"diff": "@@ -336,10 +336,10 @@ tests:\nuses: title\ntext_markup:\ntype: text\n- allow_markup: true\n+ allow_html: true\ntext_plain:\ntype: text\n- allow_markup: false\n+ allow_html: false\nhtml_field:\ntype: html\nmarkdown_field:\n"
},
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/test.twig",
"new_path": "public/theme/skeleton/test.twig",
"diff": "<hr>\n- <h2>Testing output with `allow_markup`</h2>\n+ <h2>Testing output with `allow_html`</h2>\n<p>\n- Default output with <code>allow_markup: {{ record.field('text_markup').definition.allow_markup ? 'true' : 'false' }}</code>:<br>\n+ Default output with <code>allow_html: {{ record.field('text_markup').definition.allow_html ? 'true' : 'false' }}</code>:<br>\n<div class=\"box text_markup_a\">{{ record.text_markup }}</div><br>\nExplicit raw: <br>\n<hr>\n<p>\n- Default output with <code>allow_markup: {{ record.field('text_plain').definition.allow_markup ? 'true' : 'false' }}</code>:<br>\n+ Default output with <code>allow_html: {{ record.field('text_plain').definition.allow_html ? 'true' : 'false' }}</code>:<br>\n<div class=\"box text_plain_a\">{{ record.text_plain }}</div><br>\nExplicit raw: <br>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Configuration/Parser/ContentTypesParser.php",
"new_path": "src/Configuration/Parser/ContentTypesParser.php",
"diff": "@@ -209,8 +209,8 @@ class ContentTypesParser extends BaseParser\n$hasGroups = true;\n}\n- if (isset($field['allow_markup']) === false) {\n- $field['allow_markup'] = in_array($field['type'], ['html', 'markdown'], true);\n+ if (isset($field['allow_html']) === false) {\n+ $field['allow_html'] = in_array($field['type'], ['html', 'markdown'], true);\n}\n// Make sure we have these keys and every field has a group set.\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Entity/Content.php",
"new_path": "src/Entity/Content.php",
"diff": "@@ -458,7 +458,7 @@ class Content implements \\JsonSerializable\nthrow new \\RuntimeException(sprintf('Invalid field name or method call on %s: %s', $this->__toString(), $name));\n}\n- if ($field->getDefinition()->get('allow_markup')) {\n+ if ($field->getDefinition()->get('allow_html')) {\n$field = new \\Twig_Markup($field, 'UTF-8');\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/e2e/features/display_record_test.feature",
"new_path": "tests/e2e/features/display_record_test.feature",
"diff": "Feature: Test field output\n- @wip\n+\nScenario: As a user I want to see how fields are escaped\nWhen I visit the \"single_test\" page with parameters:\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Rename `allow_markup` to `allow_html`
|
95,144 |
11.03.2019 14:45:50
| -3,600 |
f2011aee745c7837648f99a2c761376c8084df76
|
Cast to array in `setValue()` instead
|
[
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/test.twig",
"new_path": "public/theme/skeleton/test.twig",
"diff": "Escaped: <br>\n<div class=\"box text_markup_c\">{{ record.text_markup|e }}</div><br>\n-\n</p>\n<hr>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/ContentEditController.php",
"new_path": "src/Controller/Backend/ContentEditController.php",
"diff": "@@ -235,7 +235,7 @@ class ContentEditController extends TwigAwareController\n$value = Json::findArray($value);\n}\n- $field->setValue((array) $value);\n+ $field->setValue($value);\n}\nprivate function updateTaxonomy(Content $content, string $key, $taxonomy): void\n"
},
{
"change_type": "MODIFY",
"old_path": "src/DataFixtures/ContentFixtures.php",
"new_path": "src/DataFixtures/ContentFixtures.php",
"diff": "@@ -84,7 +84,7 @@ class ContentFixtures extends Fixture implements DependentFixtureInterface\n$field->setName($name);\nif (isset($preset[$name])) {\n- $field->setValue((array) $preset[$name]);\n+ $field->setValue($preset[$name]);\n} else {\n$field->setValue($this->getValuesforFieldType($name, $fieldType));\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Entity/Field.php",
"new_path": "src/Entity/Field.php",
"diff": "@@ -198,9 +198,9 @@ class Field implements Translatable\nreturn $value;\n}\n- public function setValue(array $value): self\n+ public function setValue($value): self\n{\n- $this->value = $value;\n+ $this->value = (array) $value;\nreturn $this;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Entity/Field/MarkdownField.php",
"new_path": "src/Entity/Field/MarkdownField.php",
"diff": "@@ -16,7 +16,8 @@ class MarkdownField extends Field implements Excerptable\npublic function __toString(): string\n{\n$markdown = new Markdown();\n+ $value = $this->getValue();\n- return $markdown->toHtml(implode(', ', $this->getValue()));\n+ return $markdown->toHtml(reset($value));\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Entity/Field/SlugField.php",
"new_path": "src/Entity/Field/SlugField.php",
"diff": "@@ -14,9 +14,12 @@ use Tightenco\\Collect\\Support\\Collection;\n*/\nclass SlugField extends Field\n{\n- public function setValue(array $value): parent\n+ public function setValue($value): parent\n{\n- $value = Str::slug(reset($value));\n+ if (is_array($value)) {\n+ $value = reset($value);\n+ }\n+ $value = Str::slug($value);\n$this->value = [$value];\nreturn $this;\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Cast to array in `setValue()` instead
|
95,144 |
11.03.2019 15:16:56
| -3,600 |
8fc0fed4702d75f05c24bd5bb3134c11255a7d5c
|
Implement `getTwigValue`
|
[
{
"change_type": "MODIFY",
"old_path": "src/Entity/Content.php",
"new_path": "src/Entity/Content.php",
"diff": "@@ -458,10 +458,6 @@ class Content implements \\JsonSerializable\nthrow new \\RuntimeException(sprintf('Invalid field name or method call on %s: %s', $this->__toString(), $name));\n}\n- if ($field->getDefinition()->get('allow_html')) {\n- $field = new \\Twig_Markup($field, 'UTF-8');\n- }\n-\n- return $field;\n+ return $field->getTwigValue();\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Entity/ContentExtrasTrait.php",
"new_path": "src/Entity/ContentExtrasTrait.php",
"diff": "@@ -71,11 +71,4 @@ trait ContentExtrasTrait\n'depublishedAt' => $content->getDepublishedAt(),\n];\n}\n-\n- public function var_export(): string\n- {\n- $array = $this->getFieldValues();\n-\n- return var_export($array, true);\n- }\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Entity/Field.php",
"new_path": "src/Entity/Field.php",
"diff": "@@ -198,6 +198,17 @@ class Field implements Translatable\nreturn $value;\n}\n+ public function getTwigValue()\n+ {\n+ $value = $this->__toString();\n+\n+ if ($this->getDefinition()->get('allow_html')) {\n+ $value = new \\Twig_Markup($value, 'UTF-8');\n+ }\n+\n+ return $value;\n+ }\n+\npublic function setValue($value): self\n{\n$this->value = (array) $value;\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Implement `getTwigValue`
|
95,144 |
02.03.2019 16:54:35
| -3,600 |
42e6368049103d68db0d527cc5228d2421257647
|
Be more lenient when calling non-existant object properties from within Twig
|
[
{
"change_type": "MODIFY",
"old_path": "src/Entity/Content.php",
"new_path": "src/Entity/Content.php",
"diff": "@@ -445,6 +445,14 @@ class Content implements \\JsonSerializable\n/**\n* Generic getter for a record fields. Will return the field with $name.\n*\n+ * If $name is not found, throw an exception if it's invoked from code, and\n+ * return null if invoked from within a template. In templates we need to be\n+ * more lenient, in order to do things like `{% if record.foo %}..{% endif %}\n+ *\n+ * Note: We can not rely on `{% if record.foo is defined %}`, because it\n+ * always returns `true` for object properties.\n+ * See: https://craftcms.stackexchange.com/questions/2116/twig-is-defined-always-returning-true\n+ *\n* - {{ record.title }} => field named title\n* - {{ record|title }} => value of guessed title field\n* - {{ record.image }} => field named image\n@@ -455,6 +463,14 @@ class Content implements \\JsonSerializable\ntry {\n$field = $this->getField($name);\n} catch (\\InvalidArgumentException $e) {\n+ $backtrace = new LaravelCollection(debug_backtrace());\n+\n+ if ($backtrace->contains('class', \\Twig_Template::class)) {\n+ // Invoked from within a Template render, so be lenient.\n+ return null;\n+ }\n+\n+ // Invoked from code, throw Exception\nthrow new \\RuntimeException(sprintf('Invalid field name or method call on %s: %s', $this->__toString(), $name));\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Be more lenient when calling non-existant object properties from within Twig
|
95,144 |
04.03.2019 17:02:40
| -3,600 |
0ed5536ba56db0308ed00acddfe73f48ab97c899
|
Update record.twig: distinguish between title and heading
|
[
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/record.twig",
"new_path": "public/theme/skeleton/record.twig",
"diff": "{% block main %}\n- {% if record.hasField('title') %}\n+ {% if record.title %}\n<h1 class=\"title\">{{ record.title }}</h1>\n{% else %}\n<h1 class=\"heading\">{{ record|title }}</h1>\n<a href=\"{{ record.image }}\">\n<img src=\"{{ thumbnail(record.image, 400, 260) }}\">\n</a>\n+\n<hr>\n{% endif %}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Update record.twig: distinguish between title and heading
|
95,144 |
04.03.2019 19:34:41
| -3,600 |
9529417ce167563837ea61546fd9d061b28918fa
|
Use $e->getTrace()
|
[
{
"change_type": "MODIFY",
"old_path": "src/Entity/Content.php",
"new_path": "src/Entity/Content.php",
"diff": "@@ -463,7 +463,7 @@ class Content implements \\JsonSerializable\ntry {\n$field = $this->getField($name);\n} catch (\\InvalidArgumentException $e) {\n- $backtrace = new LaravelCollection(debug_backtrace());\n+ $backtrace = new LaravelCollection($e->getTrace());\nif ($backtrace->contains('class', \\Twig_Template::class)) {\n// Invoked from within a Template render, so be lenient.\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Use $e->getTrace()
|
95,144 |
13.03.2019 07:51:28
| -3,600 |
7c2bfe402074b9d28319b8ea48f7b3be02c89d6d
|
Fix `Twig\Template` -> `Twig\TemplateWrapper`, because of Twig 2.7
|
[
{
"change_type": "MODIFY",
"old_path": "src/Twig/SourceCodeExtension.php",
"new_path": "src/Twig/SourceCodeExtension.php",
"diff": "@@ -6,7 +6,7 @@ namespace Bolt\\Twig;\nuse Twig\\Environment;\nuse Twig\\Extension\\AbstractExtension;\n-use Twig\\Template;\n+use Twig\\TemplateWrapper;\nuse Twig\\TwigFunction;\n/**\n@@ -88,7 +88,7 @@ class SourceCodeExtension extends AbstractExtension\nreturn new \\ReflectionFunction($callable);\n}\n- private function getTemplateSource(Template $template): array\n+ private function getTemplateSource(TemplateWrapper $template): array\n{\n$templateSource = $template->getSourceContext();\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Fix `Twig\Template` -> `Twig\TemplateWrapper`, because of Twig 2.7
|
95,144 |
13.03.2019 17:08:39
| -3,600 |
375d3f522af9e7089bf86d943b83d49af8b4e0b2
|
Use `\Twig\Template`
|
[
{
"change_type": "MODIFY",
"old_path": "src/Entity/Content.php",
"new_path": "src/Entity/Content.php",
"diff": "@@ -465,7 +465,7 @@ class Content implements \\JsonSerializable\n} catch (\\InvalidArgumentException $e) {\n$backtrace = new LaravelCollection($e->getTrace());\n- if ($backtrace->contains('class', \\Twig_Template::class)) {\n+ if ($backtrace->contains('class', \\Twig\\Template::class)) {\n// Invoked from within a Template render, so be lenient.\nreturn null;\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Use `\Twig\Template`
|
95,144 |
13.03.2019 07:53:10
| -3,600 |
27072359591e439eacf69699b0d5a2de06d2b21c
|
Clean up `|merge[]`, unneeded since PagerFanta 2.1
|
[
{
"change_type": "MODIFY",
"old_path": "templates/_partials/_content_listing.html.twig",
"new_path": "templates/_partials/_content_listing.html.twig",
"diff": "<!-- listing records -->\n<listing-records\ntype=\"{{ type }}\"\n- {# tricky part: https://github.com/whiteoctober/WhiteOctoberPagerfantaBundle/issues/165#issuecomment-462777227 #}\n- :data=\"{{ records|merge([])|json_encode }}\"\n+ :data=\"{{ records|json_encode }}\"\n>\n</listing-records>\n<!-- end listing records -->\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Clean up `|merge[]`, unneeded since PagerFanta 2.1
|
95,144 |
19.03.2019 17:29:56
| -3,600 |
76f2f28e38473c6e1e6ed09014d090d4b34c4dea
|
Workaround for multiple URL parameters, use stable Kakunin
|
[
{
"change_type": "MODIFY",
"old_path": "tests/e2e/features/edit_record_1.feature",
"new_path": "tests/e2e/features/edit_record_1.feature",
"diff": "@@ -34,29 +34,25 @@ Feature: Edit record\nWhen I fill the \"title_field\" field with \"Changed title NL\"\nAnd I click the \"save_button\" element\n+ # Note, see https://github.com/TheSoftwareHouse/Kakunin/pull/157\n+ # @todo update, when the mentioned PR lands in stable Kakunin\nWhen I visit the \"edit_record\" page with parameters:\n- | id | 1 |\n- | edit_locale | nl |\n+ | id | 1?edit_locale=nl |\nThen I wait for \"title_field\" element to appear\nThen there is element \"title_field\" with text \"Changed title NL\"\nWhen I visit the \"edit_record\" page with parameters:\n- | id | 1 |\n- | edit_locale | nl |\n- | _locale | nl |\n+ | id | 1?edit_locale=nl&_locale=nl |\nThen I wait for \"title_field\" element to appear\nThen there is element \"title_field\" with text \"Changed title NL\"\nWhen I visit the \"edit_record\" page with parameters:\n- | id | 1 |\n- | edit_locale | en |\n- | _locale | nl |\n+ | id | 1?edit_locale=en&_locale=nl |\nThen I wait for \"title_field\" element to appear\nThen there is element \"title_field\" with text \"Changed title EN\"\nWhen I visit the \"single_record\" page with parameters:\n- | id | 1 |\n- | _locale | nl |\n+ | id | 1?_locale=nl |\nThen there is element \"title\" with text \"Changed title NL\"\nWhen I visit the \"single_record\" page with parameters:\n@@ -64,8 +60,7 @@ Feature: Edit record\nThen there is element \"title\" with text \"Changed title NL\"\nWhen I visit the \"single_record\" page with parameters:\n- | id | 1 |\n- | _locale | en |\n+ | id | 1?_locale=en |\nThen there is element \"title\" with text \"Changed title EN\"\nWhen I visit the \"single_record\" page with parameters:\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/e2e/package.json",
"new_path": "tests/e2e/package.json",
"diff": "},\n\"dependencies\": {\n\"cross-env\": \"^5.2.0\",\n- \"kakunin\": \"https://github.com/JarJak/Kakunin/tarball/master-with-additional-url-params\",\n+ \"kakunin\": \"^2.5\",\n\"protractor\": \"^5.4.2\",\n\"webdriver-manager\": \"^12.1.1\"\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Workaround for multiple URL parameters, use stable Kakunin
|
95,144 |
10.03.2019 15:05:30
| -3,600 |
e04606c516c8412733002623ff53595d6cd443c7
|
Make sure we get the correct contenttype for listings.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Controller/Frontend/ListingController.php",
"new_path": "src/Controller/Frontend/ListingController.php",
"diff": "@@ -40,11 +40,11 @@ class ListingController extends TwigAwareController\n{\n$page = (int) $request->query->get('page', 1);\n- /** @var Content[] $records */\n- $records = $contentRepository->findForPage($page);\n-\n$contentType = ContentType::factory($contentTypeSlug, $this->config->get('contenttypes'));\n+ /** @var Content[] $records */\n+ $records = $contentRepository->findForPage($page, $contentType);\n+\n$templates = $this->templateChooser->forListing($contentType);\nreturn $this->renderTemplate($templates, ['records' => $records]);\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Make sure we get the correct contenttype for listings.
|
95,144 |
10.03.2019 15:51:20
| -3,600 |
39d0a494b19987e0f6b20dc2f52f96b039358c46
|
Only fetch published items, unless instructed otherwise
|
[
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/ContentOverviewController.php",
"new_path": "src/Controller/Backend/ContentOverviewController.php",
"diff": "@@ -26,7 +26,7 @@ class ContentOverviewController extends TwigAwareController\n$page = (int) $request->query->get('page', 1);\n- $records = $contentRepository->findForPage($page, $contentType);\n+ $records = $contentRepository->findForListing($page, $contentType, false);\nreturn $this->renderTemplate('@bolt/content/listing.html.twig', [\n'records' => $records,\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Frontend/ListingController.php",
"new_path": "src/Controller/Frontend/ListingController.php",
"diff": "@@ -43,7 +43,7 @@ class ListingController extends TwigAwareController\n$contentType = ContentType::factory($contentTypeSlug, $this->config->get('contenttypes'));\n/** @var Content[] $records */\n- $records = $contentRepository->findForPage($page, $contentType);\n+ $records = $contentRepository->findForListing($page, $contentType);\n$templates = $this->templateChooser->forListing($contentType);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Frontend/SearchController.php",
"new_path": "src/Controller/Frontend/SearchController.php",
"diff": "@@ -39,7 +39,7 @@ class SearchController extends TwigAwareController\n$page = (int) $request->query->get('page', 1);\n// @todo implement actual Search Engine\n- $records = $contentRepository->findForPage($page);\n+ $records = $contentRepository->findForListing($page);\n$templates = $this->templateChooser->forSearch();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Frontend/TaxonomyController.php",
"new_path": "src/Controller/Frontend/TaxonomyController.php",
"diff": "@@ -42,7 +42,7 @@ class TaxonomyController extends TwigAwareController\n$page = (int) $request->query->get('page', 1);\n/** @var Content[] $records */\n- $records = $contentRepository->findForPage($page);\n+ $records = $contentRepository->findForListing($page);\n$contentType = ContentType::factory('page', $this->config->get('contenttypes'));\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Repository/ContentRepository.php",
"new_path": "src/Repository/ContentRepository.php",
"diff": "@@ -32,7 +32,7 @@ class ContentRepository extends ServiceEntityRepository\nreturn $this->createQueryBuilder('content');\n}\n- public function findForPage(int $page = 1, ?ContentType $contentType = null): Pagerfanta\n+ public function findForListing(int $page = 1, ?ContentType $contentType = null, bool $published = true): Pagerfanta\n{\n$qb = $this->getQueryBuilder()\n->addSelect('a')\n@@ -43,6 +43,10 @@ class ContentRepository extends ServiceEntityRepository\n->setParameter('ct', $contentType['slug']);\n}\n+ if ($published) {\n+ $qb->andWhere('content.status = :status')\n+ ->setParameter('status', 'published');\n+ }\nreturn $this->createPaginator($qb->getQuery(), $page);\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Only fetch published items, unless instructed otherwise
|
95,144 |
10.03.2019 15:51:53
| -3,600 |
c795439f76d3b7349c3ee1674375cfe273003c9d
|
Don't break if we have no `record`
|
[
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/partials/_master.twig",
"new_path": "public/theme/skeleton/partials/_master.twig",
"diff": "{# make sure we always display a proper title: The record's title if there is one, appended with the\nsitename. If there is no title, we append the sitename with the payoff, if there is one. #}\n<title>\n- {%- if record.hasField('title') %}{{ record.title|striptags }} | {% endif -%}\n+ {%- if record.hasField('title')|default() %}{{ record.title|striptags }} | {% endif -%}\n{{ config.get('general/sitename') -}}\n- {% if not record.hasField('title') and config.has('general/payoff') %} | {{ config.get('general/payoff') }}{% endif -%}\n+ {% if not record.hasField('title')|default() and config.has('general/payoff') %} | {{ config.get('general/payoff') }}{% endif -%}\n</title>\n{#<link rel=\"stylesheet\" href=\"{{ asset('css/normalize.css', 'theme') }}\">#}\n{#<link rel=\"stylesheet\" href=\"{{ asset('css/sakura.css', 'theme') }}\">#}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Don't break if we have no `record`
|
95,144 |
10.03.2019 16:12:29
| -3,600 |
fd6483bd55f771e064079ae4f810407e3512dd3d
|
Prefill fixtures, depending on listing_record
|
[
{
"change_type": "MODIFY",
"old_path": "config/bolt/contenttypes.yaml",
"new_path": "config/bolt/contenttypes.yaml",
"diff": "@@ -139,7 +139,7 @@ entries:\ntaxonomy: [ categories, tags, groups ]\nrecord_template: entry.twig\nlisting_template: listing.twig\n- listing_records: 10\n+ listing_records: 20\ndefault_status: published\nsort: -publishedAt\nrecordsperpage: 20\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Configuration/Parser/ContentTypesParser.php",
"new_path": "src/Configuration/Parser/ContentTypesParser.php",
"diff": "@@ -124,6 +124,12 @@ class ContentTypesParser extends BaseParser\n$contentType['singleton'] = false;\n}\n+ if ($contentType['singleton']) {\n+ $contentType['listing_records'] = 1;\n+ } else if (! isset($contentType['listing_records'])) {\n+ $contentType['listing_records'] = 6;\n+ }\n+\nif (! isset($contentType['locales'])) {\n$contentType['locales'] = [];\n} elseif (is_string($contentType['locales'])) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/DataFixtures/ContentFixtures.php",
"new_path": "src/DataFixtures/ContentFixtures.php",
"diff": "@@ -60,7 +60,8 @@ class ContentFixtures extends Fixture implements DependentFixtureInterface\n$translationRepository = $manager->getRepository(Translation::class);\nforeach ($this->config as $contentType) {\n- $amount = $contentType['singleton'] ? 1 : 15;\n+\n+ $amount = $contentType['singleton'] ? 1 : (int) ($contentType['listing_records'] * 2.5);\nforeach (range(1, $amount) as $i) {\n$ref = $i === 1 ? 'admin' : ['admin', 'henkie', 'jane_admin', 'tom_admin'][random_int(0, 3)];\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Prefill fixtures, depending on listing_record
|
95,144 |
13.03.2019 07:21:21
| -3,600 |
2d638956c38ac970db49568934df14a9b4bdcf44
|
Adding some tests, yo!
|
[
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/partials/_sub_pager.twig",
"new_path": "public/theme/skeleton/partials/_sub_pager.twig",
"diff": "{% if records.haveToPaginate|default() %}\n- <div class=\"pagination\">\n+ <div class=\"{{ class|default('pagination') }}\">\n{{ pagerfanta(records) }}\n</div>\n{% else %}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "tests/e2e/features/display_listing.feature",
"diff": "+Feature: Display a listing of records\n+ @wip\n+ Scenario: As a user I want to display a listing of records\n+ When I visit the \"listing_records\" page\n+ Then I wait for \"heading\" element to appear\n+\n+ Then I scroll to the \"pagination\" element\n+ And I click the \"next\" element\n+\n+ Then I wait for \"heading\" element to appear\n+ Then there is element \"current\" with text \"2\"\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "tests/e2e/pages/listing_records.js",
"diff": "+const { BasePage } = require('kakunin');\n+\n+class ListingRecordsPage extends BasePage {\n+ constructor() {\n+ super();\n+\n+ this.url = '/entries';\n+\n+ this.heading = $('article h2');\n+ this.pagination = $('.pagination');\n+ this.next = $('.pagination a[rel=\"next\"]');\n+ this.current = $('.pagination span.current');\n+ }\n+}\n+\n+module.exports = ListingRecordsPage;\n\\ No newline at end of file\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Adding some tests, yo!
|
95,144 |
13.03.2019 14:14:07
| -3,600 |
80a64e2052cc4c11d2611b50578889ce880e2437
|
Fall back to "global" `listing_records`
|
[
{
"change_type": "MODIFY",
"old_path": "src/Configuration/Config.php",
"new_path": "src/Configuration/Config.php",
"diff": "@@ -100,7 +100,7 @@ class Config\n$taxonomy = new TaxonomyParser();\n$config['taxonomies'] = $taxonomy->parse();\n- $contentTypes = new ContentTypesParser($config->get('general')['accept_file_types']);\n+ $contentTypes = new ContentTypesParser($config->get('general'));\n$config['contenttypes'] = $contentTypes->parse();\n// @todo Add these config files if needed, or refactor them out otherwise\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Configuration/Parser/ContentTypesParser.php",
"new_path": "src/Configuration/Parser/ContentTypesParser.php",
"diff": "@@ -13,13 +13,13 @@ use Tightenco\\Collect\\Support\\Collection;\nclass ContentTypesParser extends BaseParser\n{\n/**\n- * @var string[]\n+ * @var Collection\n*/\n- private $acceptFileTypes = [];\n+ private $generalConfig;\n- public function __construct(array $acceptFileTypes)\n+ public function __construct(Collection $generalConfig)\n{\n- $this->acceptFileTypes = $acceptFileTypes;\n+ $this->generalConfig = $generalConfig;\nparent::__construct();\n}\n@@ -127,9 +127,10 @@ class ContentTypesParser extends BaseParser\nif ($contentType['singleton']) {\n$contentType['listing_records'] = 1;\n} elseif (isset($contentType['listing_records']) === false) {\n- $contentType['listing_records'] = 6;\n+ $contentType['listing_records'] = $this->generalConfig->get('listing_records');\n}\n+\nif (! isset($contentType['locales'])) {\n$contentType['locales'] = [];\n} elseif (is_string($contentType['locales'])) {\n@@ -176,6 +177,7 @@ class ContentTypesParser extends BaseParser\n$currentGroup = 'ungrouped';\n$groups = [];\n$hasGroups = false;\n+ $acceptFileTypes = $this->generalConfig->get('accept_file_types');\nforeach ($fields as $key => $field) {\nunset($fields[$key]);\n@@ -189,7 +191,7 @@ class ContentTypesParser extends BaseParser\n// If field is a \"file\" type, make sure the 'extensions' are set, and it's an array.\nif ($field['type'] === 'file' || $field['type'] === 'filelist') {\nif (empty($field['extensions'])) {\n- $field['extensions'] = $this->acceptFileTypes;\n+ $field['extensions'] = $acceptFileTypes;\n}\n$field['extensions'] = (array) $field['extensions'];\n@@ -199,7 +201,7 @@ class ContentTypesParser extends BaseParser\nif ($field['type'] === 'image' || $field['type'] === 'imagelist') {\nif (empty($field['extensions'])) {\n$extensions = new Collection(['gif', 'jpg', 'jpeg', 'png', 'svg']);\n- $field['extensions'] = $extensions->intersect($this->acceptFileTypes)->toArray();\n+ $field['extensions'] = $extensions->intersect($acceptFileTypes)->toArray();\n}\n$field['extensions'] = (array) $field['extensions'];\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Kernel.php",
"new_path": "src/Kernel.php",
"diff": "@@ -16,6 +16,7 @@ use Symfony\\Component\\DependencyInjection\\ContainerBuilder;\nuse Symfony\\Component\\HttpKernel\\Kernel as BaseKernel;\nuse Symfony\\Component\\Routing\\RouteCollectionBuilder;\nuse Symfony\\Component\\Yaml\\Yaml;\n+use Tightenco\\Collect\\Support\\Collection;\nclass Kernel extends BaseKernel\n{\n@@ -123,7 +124,7 @@ class Kernel extends BaseKernel\n*/\nprivate function setContentTypeRequirements(ContainerBuilder $container): void\n{\n- $ContentTypesParser = new ContentTypesParser([]);\n+ $ContentTypesParser = new ContentTypesParser(new Collection());\n$contentTypes = $ContentTypesParser->parse();\n$pluralslugs = $contentTypes->pluck('slug')->implode('|');\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Fall back to "global" `listing_records`
|
95,144 |
13.03.2019 14:14:41
| -3,600 |
5b8f90ab28af0f97c3de62bb05676b135f68af5a
|
Use `.title` instead of `hasField('title')`
|
[
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/partials/_master.twig",
"new_path": "public/theme/skeleton/partials/_master.twig",
"diff": "{# make sure we always display a proper title: The record's title if there is one, appended with the\nsitename. If there is no title, we append the sitename with the payoff, if there is one. #}\n<title>\n- {%- if record.hasField('title')|default() %}{{ record.title|striptags }} | {% endif -%}\n+ {%- if record.title|default %}{{ record.title|striptags }} | {% endif -%}\n{{ config.get('general/sitename') -}}\n- {% if not record.hasField('title')|default() and config.has('general/payoff') %} | {{ config.get('general/payoff') }}{% endif -%}\n+ {% if not record.title|default and config.has('general/payoff') %} | {{ config.get('general/payoff') }}{% endif -%}\n</title>\n{#<link rel=\"stylesheet\" href=\"{{ asset('css/normalize.css', 'theme') }}\">#}\n{#<link rel=\"stylesheet\" href=\"{{ asset('css/sakura.css', 'theme') }}\">#}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Use `.title` instead of `hasField('title')`
|
95,144 |
13.03.2019 14:49:48
| -3,600 |
1710723dbbc8f0112c7c8dc6690187a4c612a7c2
|
add `theme` and `surround`
|
[
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/partials/_sub_pager.twig",
"new_path": "public/theme/skeleton/partials/_sub_pager.twig",
"diff": "{% if records.haveToPaginate|default() %}\n+\n+ {% set theme = theme|default('default') %}\n+ {% set options = {\n+ 'proximity': surround|default(3)\n+ } %}\n+\n<div class=\"{{ class|default('pagination') }}\">\n- {{ pagerfanta(records) }}\n+ {{ pagerfanta(records, theme, options) }}\n</div>\n{% else %}\n<strong class='bolt_template_warning'>Warning: Not possible to paginate given object.</strong>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Repository/ContentRepository.php",
"new_path": "src/Repository/ContentRepository.php",
"diff": "@@ -32,7 +32,7 @@ class ContentRepository extends ServiceEntityRepository\nreturn $this->createQueryBuilder('content');\n}\n- public function findForListing(int $page = 1, ?ContentType $contentType = null, bool $published = true): Pagerfanta\n+ public function findForListing(int $page = 1, ?ContentType $contentType = null, bool $onlyPublished = true): Pagerfanta\n{\n$qb = $this->getQueryBuilder()\n->addSelect('a')\n@@ -43,11 +43,12 @@ class ContentRepository extends ServiceEntityRepository\n->setParameter('ct', $contentType['slug']);\n}\n- if ($published) {\n+ if ($onlyPublished) {\n$qb->andWhere('content.status = :status')\n- ->setParameter('status', 'published');\n+ ->setParameter('status', Statuses::PUBLISHED);\n}\n- return $this->createPaginator($qb->getQuery(), $page);\n+\n+ return $this->createPaginator($qb->getQuery(), $page, $contentType['recordsperpage']);\n}\npublic function findLatest(?ContentType $contentType = null, int $amount = 6): ?array\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
add `theme` and `surround`
|
95,144 |
13.03.2019 14:51:33
| -3,600 |
db62b67c1c217f73e718e906abdfdfcc2b1dd723
|
Get rid of `const NUM_ITEMS`
|
[
{
"change_type": "MODIFY",
"old_path": "config/bolt/contenttypes.yaml",
"new_path": "config/bolt/contenttypes.yaml",
"diff": "@@ -142,7 +142,7 @@ entries:\nlisting_records: 20\ndefault_status: published\nsort: -publishedAt\n- recordsperpage: 20\n+ recordsperpage: 6\nicon_many: \"fa:file-alt\"\nicon_one: \"fa:file-alt\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Entity/Content.php",
"new_path": "src/Entity/Content.php",
"diff": "@@ -35,8 +35,6 @@ class Content implements \\JsonSerializable\nuse ContentLocalizeTrait;\nuse ContentExtrasTrait;\n- public const NUM_ITEMS = 8; // @todo This can't be a const\n-\n/**\n* @var int\n*\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Repository/ContentRepository.php",
"new_path": "src/Repository/ContentRepository.php",
"diff": "@@ -81,10 +81,10 @@ class ContentRepository extends ServiceEntityRepository\n// ->setParameter('values',['red','yellow']);\n}\n- private function createPaginator(Query $query, int $page): Pagerfanta\n+ private function createPaginator(Query $query, int $page, int $max): Pagerfanta\n{\n$paginator = new Pagerfanta(new DoctrineORMAdapter($query));\n- $paginator->setMaxPerPage(Content::NUM_ITEMS);\n+ $paginator->setMaxPerPage($max);\n$paginator->setCurrentPage($page);\nreturn $paginator;\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Get rid of `const NUM_ITEMS`
|
95,144 |
13.03.2019 15:06:30
| -3,600 |
924ef555072790e4eb31c7d520f7aca6ebfa75bf
|
requested change: `record|default`
|
[
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/partials/_master.twig",
"new_path": "public/theme/skeleton/partials/_master.twig",
"diff": "{# make sure we always display a proper title: The record's title if there is one, appended with the\nsitename. If there is no title, we append the sitename with the payoff, if there is one. #}\n<title>\n- {%- if record.title|default %}{{ record.title|striptags }} | {% endif -%}\n+ {%- if record|default and record.title %}{{ record.title|striptags }} | {% endif -%}\n{{ config.get('general/sitename') -}}\n- {% if not record.title|default and config.has('general/payoff') %} | {{ config.get('general/payoff') }}{% endif -%}\n+ {% if not record|default and config.has('general/payoff') %} | {{ config.get('general/payoff') }}{% endif -%}\n</title>\n{#<link rel=\"stylesheet\" href=\"{{ asset('css/normalize.css', 'theme') }}\">#}\n{#<link rel=\"stylesheet\" href=\"{{ asset('css/sakura.css', 'theme') }}\">#}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
requested change: `record|default`
|
95,144 |
13.03.2019 15:09:30
| -3,600 |
29ab1437e7c240a9a4ea57234d1b676e71f391ee
|
Update _master.twig
|
[
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/partials/_master.twig",
"new_path": "public/theme/skeleton/partials/_master.twig",
"diff": "{# make sure we always display a proper title: The record's title if there is one, appended with the\nsitename. If there is no title, we append the sitename with the payoff, if there is one. #}\n<title>\n- {%- if record|default and record.title %}{{ record.title|striptags }} | {% endif -%}\n+ {%- if record is defined and record.title %}{{ record.title|striptags }} | {% endif -%}\n{{ config.get('general/sitename') -}}\n- {% if not record|default and config.has('general/payoff') %} | {{ config.get('general/payoff') }}{% endif -%}\n+ {% if record is not defined and config.has('general/payoff') %} | {{ config.get('general/payoff') }}{% endif -%}\n</title>\n{#<link rel=\"stylesheet\" href=\"{{ asset('css/normalize.css', 'theme') }}\">#}\n{#<link rel=\"stylesheet\" href=\"{{ asset('css/sakura.css', 'theme') }}\">#}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Update _master.twig
|
95,144 |
15.03.2019 09:45:41
| -3,600 |
de901945d81d1f1757a11a644dd76e32d16ca28e
|
Bunch of requested changes
|
[
{
"change_type": "MODIFY",
"old_path": "config/bolt/contenttypes.yaml",
"new_path": "config/bolt/contenttypes.yaml",
"diff": "@@ -139,10 +139,10 @@ entries:\ntaxonomy: [ categories, tags, groups ]\nrecord_template: entry.twig\nlisting_template: listing.twig\n- listing_records: 20\n+ listing_records: 6\ndefault_status: published\nsort: -publishedAt\n- recordsperpage: 6\n+ records_per_page: 3\nicon_many: \"fa:file-alt\"\nicon_one: \"fa:file-alt\"\n"
},
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/partials/_master.twig",
"new_path": "public/theme/skeleton/partials/_master.twig",
"diff": "{# make sure we always display a proper title: The record's title if there is one, appended with the\nsitename. If there is no title, we append the sitename with the payoff, if there is one. #}\n<title>\n- {%- if record is defined and record.title %}{{ record.title|striptags }} | {% endif -%}\n+ {%- if record is defined and record.title %}{{ record.title }} | {% endif -%}\n{{ config.get('general/sitename') -}}\n{% if record is not defined and config.has('general/payoff') %} | {{ config.get('general/payoff') }}{% endif -%}\n</title>\n"
},
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/partials/_sub_pager.twig",
"new_path": "public/theme/skeleton/partials/_sub_pager.twig",
"diff": "{% if records.haveToPaginate|default() %}\n- {% set theme = theme|default('default') %}\n+ {% set theme = theme %}\n{% set options = {\n- 'proximity': surround|default(3)\n+ 'proximity': surround\n} %}\n- <div class=\"{{ class|default('pagination') }}\">\n+ <div class=\"{{ class }}\">\n{{ pagerfanta(records, theme, options) }}\n</div>\n-{% else %}\n- <strong class='bolt_template_warning'>Warning: Not possible to paginate given object.</strong>\n{% endif %}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Configuration/Parser/ContentTypesParser.php",
"new_path": "src/Configuration/Parser/ContentTypesParser.php",
"diff": "@@ -130,6 +130,12 @@ class ContentTypesParser extends BaseParser\n$contentType['listing_records'] = $this->generalConfig->get('listing_records');\n}\n+ if ($contentType['singleton']) {\n+ $contentType['records_per_page'] = 1;\n+ } elseif (isset($contentType['records_per_page']) === false) {\n+ $contentType['records_per_page'] = $this->generalConfig->get('records_per_page');\n+ }\n+\nif (! isset($contentType['locales'])) {\n$contentType['locales'] = [];\n} elseif (is_string($contentType['locales'])) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Configuration/Parser/GeneralParser.php",
"new_path": "src/Configuration/Parser/GeneralParser.php",
"diff": "@@ -59,8 +59,8 @@ class GeneralParser extends BaseParser\n],\n'sitename' => 'Default Bolt site',\n'locale' => null,\n- 'recordsperpage' => 10,\n- 'recordsperdashboardwidget' => 5,\n+ 'records_per_page' => 10,\n+ 'records_per_dashboardwidget' => 5,\n'systemlog' => [\n'enabled' => true,\n],\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Repository/ContentRepository.php",
"new_path": "src/Repository/ContentRepository.php",
"diff": "@@ -48,7 +48,7 @@ class ContentRepository extends ServiceEntityRepository\n->setParameter('status', Statuses::PUBLISHED);\n}\n- return $this->createPaginator($qb->getQuery(), $page, $contentType['recordsperpage']);\n+ return $this->createPaginator($qb->getQuery(), $page, $contentType['listing_records']);\n}\npublic function findLatest(?ContentType $contentType = null, int $amount = 6): ?array\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Twig/RecordExtension.php",
"new_path": "src/Twig/RecordExtension.php",
"diff": "@@ -10,6 +10,7 @@ use Bolt\\Menu\\MenuBuilder;\nuse Bolt\\Repository\\TaxonomyRepository;\nuse Bolt\\Utils\\Excerpt;\nuse Doctrine\\Common\\Collections\\Collection;\n+use Pagerfanta\\Pagerfanta;\nuse Symfony\\Contracts\\Translation\\TranslatorInterface;\nuse Tightenco\\Collect\\Support\\Collection as LaravelCollection;\nuse Twig\\Environment;\n@@ -74,12 +75,8 @@ class RecordExtension extends AbstractExtension\nreturn $input;\n}\n- public function pager(Environment $env, $records = null, string $template = '_sub_pager.twig', ?string $class = null, ?string $theme = null, ?int $surround = null)\n+ public function pager(Environment $env, Pagerfanta $records, string $template = '_sub_pager.twig', string $class = 'pagination', string $theme = 'default', int $surround = 3)\n{\n- if (! is_iterable($records)) {\n- return \"<strong class='bolt_template_warning'>Warning: Not possible to paginate given object.</strong>\";\n- }\n-\n$context = [\n'records' => $records,\n'surround' => $surround,\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Bunch of requested changes
|
95,144 |
15.03.2019 09:49:29
| -3,600 |
3c7f61ada64f01dee61c0535e0d402a0f410831e
|
Add description for pager
|
[
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/partials/_sub_pager.twig",
"new_path": "public/theme/skeleton/partials/_sub_pager.twig",
"diff": "{% if records.haveToPaginate|default() %}\n- {% set theme = theme %}\n- {% set options = {\n- 'proximity': surround\n- } %}\n+ {# The Pagerfanta function allows you to configure what is paginated,\n+ the theme (template) to use for it, as well as a number of other options.\n+ See: https://github.com/whiteoctober/WhiteOctoberPagerfantaBundle #}\n<div class=\"{{ class }}\">\n- {{ pagerfanta(records, theme, options) }}\n+ {{ pagerfanta(records, theme, {\n+ 'proximity': surround\n+ }) }}\n</div>\n{% endif %}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Add description for pager
|
95,144 |
20.03.2019 06:41:46
| -3,600 |
dbef97d5181f565ba73fe542a8d1a3b4cf87cbe7
|
Change `records_per_dashboardwidget` to `records_on_dashboard`
|
[
{
"change_type": "MODIFY",
"old_path": "src/Configuration/Parser/GeneralParser.php",
"new_path": "src/Configuration/Parser/GeneralParser.php",
"diff": "@@ -60,7 +60,7 @@ class GeneralParser extends BaseParser\n'sitename' => 'Default Bolt site',\n'locale' => null,\n'records_per_page' => 10,\n- 'records_per_dashboardwidget' => 5,\n+ 'records_on_dashboard' => 5,\n'systemlog' => [\n'enabled' => true,\n],\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Change `records_per_dashboardwidget` to `records_on_dashboard`
|
95,144 |
13.03.2019 15:52:20
| -3,600 |
a74760e7c85e6d921d235073eaef8bee9e53092e
|
Return correct value for images (array with meta)
|
[
{
"change_type": "MODIFY",
"old_path": "config/bolt/contenttypes.yaml",
"new_path": "config/bolt/contenttypes.yaml",
"diff": "@@ -342,6 +342,12 @@ tests:\nallow_html: false\nhtml_field:\ntype: html\n+ image:\n+ type: image\n+ postfix: An image, actually _named_ image.\n+ picture:\n+ type: image\n+ postfix: An image, named differently.\nmarkdown_field:\ntype: markdown\ntextarea_field:\n"
},
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/test.twig",
"new_path": "public/theme/skeleton/test.twig",
"diff": "<div class=\"box text_textarea\">{{ record.textarea_field }}</div><br>\n</p>\n- {% if record.hasField('image') %}\n- <a href=\"{{ record.image }}\">\n+ <h2>Testing output for images</h2>\n+\n+ {% if record.image %}\n+ We have a field named `image`: {{ dump(record.getField('image').getValue()) }}\n+ {{ dump(record.image) }}\n<img src=\"{{ thumbnail(record.image, 400, 260) }}\">\n- </a>\n<hr>\n{% endif %}\n+ {% if record.image %}\n+ We have a field named `picture`: {{ dump(record.picture) }}\n+ <img src=\"{{ thumbnail(record.picture, 400, 260) }}\">\n+ <hr>\n+ {% endif %}\n+\n+ {% if record|image %}\n+ We have an 'extras' image: {{ dump(record|image) }}\n+ <img src=\"{{ thumbnail(record|image, 400, 260) }}\">\n+ <hr>\n+ {% endif %}\n+\n+\n{# Output all fields, in the order as defined in the content type.\nTo change the generated html and configure the options, see:\nhttps://docs.bolt.cm/templating #}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Entity/Field/ImageField.php",
"new_path": "src/Entity/Field/ImageField.php",
"diff": "@@ -33,6 +33,11 @@ class ImageField extends Field\nreturn $value;\n}\n+ public function getTwigValue()\n+ {\n+ return $this->getValue();\n+ }\n+\npublic function getPath(): string\n{\n$urlBuilder = UrlBuilderFactory::create('/thumbs/');\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Return correct value for images (array with meta)
|
95,144 |
13.03.2019 19:35:12
| -3,600 |
80806ebc446b77c742ae24f195e1f48cfbbdb11d
|
Fixing 'picture'
|
[
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/test.twig",
"new_path": "public/theme/skeleton/test.twig",
"diff": "<hr>\n{% endif %}\n- {% if record.image %}\n+ {% if record.picture %}\nWe have a field named `picture`: {{ dump(record.picture) }}\n<img src=\"{{ thumbnail(record.picture, 400, 260) }}\">\n<hr>\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Fixing 'picture'
|
95,144 |
20.03.2019 07:41:21
| -3,600 |
609534d49df5e142a3d03a3523b169828d9097c3
|
Fix markdown field
|
[
{
"change_type": "MODIFY",
"old_path": "src/Entity/Field/MarkdownField.php",
"new_path": "src/Entity/Field/MarkdownField.php",
"diff": "@@ -7,6 +7,7 @@ namespace Bolt\\Entity\\Field;\nuse Bolt\\Entity\\Field;\nuse Bolt\\Utils\\Markdown;\nuse Doctrine\\ORM\\Mapping as ORM;\n+use Twig\\Markup;\n/**\n* @ORM\\Entity\n@@ -20,4 +21,18 @@ class MarkdownField extends Field implements Excerptable\nreturn $markdown->toHtml(reset($value));\n}\n+\n+ /**\n+ * @return string|array|Markup\n+ */\n+ public function getTwigValue()\n+ {\n+ $value = (string) $this;\n+\n+ if (is_string($value) && $this->getDefinition()->get('allow_html')) {\n+ $value = new Markup($value, 'UTF-8');\n+ }\n+\n+ return $value;\n+ }\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Fix markdown field
|
95,144 |
20.03.2019 12:09:21
| -3,600 |
592e6a5d488d755d41defe08769366b21dc745b4
|
Change `getFlattenedValue` to `getParsedValue`
|
[
{
"change_type": "MODIFY",
"old_path": "src/Entity/Content.php",
"new_path": "src/Entity/Content.php",
"diff": "@@ -299,7 +299,7 @@ class Content implements \\JsonSerializable\n{\n$fieldValues = [];\nforeach ($this->getFields() as $field) {\n- $fieldValues[$field->getName()] = $field->getFlattenedValue();\n+ $fieldValues[$field->getName()] = $field->getParsedValue();\n}\nreturn $fieldValues;\n@@ -330,7 +330,7 @@ class Content implements \\JsonSerializable\nreturn null;\n}\n- return $this->getField($fieldName)->getFlattenedValue();\n+ return $this->getField($fieldName)->getParsedValue();\n}\npublic function getField(string $fieldName): Field\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Entity/Field.php",
"new_path": "src/Entity/Field.php",
"diff": "@@ -184,7 +184,7 @@ class Field implements Translatable\n*\n* @return array|mixed|null\n*/\n- public function getFlattenedValue()\n+ public function getParsedValue()\n{\n$value = $this->getValue();\nif (is_iterable($value)) {\n@@ -204,7 +204,7 @@ class Field implements Translatable\n*/\npublic function getTwigValue()\n{\n- $value = $this->getFlattenedValue();\n+ $value = $this->getParsedValue();\nif (is_string($value) && $this->getDefinition()->get('allow_html')) {\n$value = new Markup($value, 'UTF-8');\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Entity/Field/MarkdownField.php",
"new_path": "src/Entity/Field/MarkdownField.php",
"diff": "@@ -7,7 +7,6 @@ namespace Bolt\\Entity\\Field;\nuse Bolt\\Entity\\Field;\nuse Bolt\\Utils\\Markdown;\nuse Doctrine\\ORM\\Mapping as ORM;\n-use Twig\\Markup;\n/**\n* @ORM\\Entity\n@@ -22,17 +21,8 @@ class MarkdownField extends Field implements Excerptable\nreturn $markdown->toHtml(reset($value));\n}\n- /**\n- * @return string|array|Markup\n- */\n- public function getTwigValue()\n+ public function getParsedValue(): string\n{\n- $value = (string) $this;\n-\n- if (is_string($value) && $this->getDefinition()->get('allow_html')) {\n- $value = new Markup($value, 'UTF-8');\n- }\n-\n- return $value;\n+ return (string) $this;\n}\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Change `getFlattenedValue` to `getParsedValue`
|
95,144 |
22.03.2019 16:38:30
| -3,600 |
0a454f293abdfa8673260e197978377053e1b247
|
Fix test that broke after Twig 2.7.2 -> 2.7.3
|
[
{
"change_type": "MODIFY",
"old_path": "tests/php/Twig/SetcontentTokenParserTest.php",
"new_path": "tests/php/Twig/SetcontentTokenParserTest.php",
"diff": "@@ -74,7 +74,7 @@ class SetcontentTokenParserTest extends TokenParserTestCase\nnew Token(Token::BLOCK_END_TYPE, '', 98),\nnew Token(Token::EOF_TYPE, '', 99),\n];\n- $twigTokenStream = new TokenStream($streamTokens, new Source(null, 'clippy'));\n+ $twigTokenStream = new TokenStream($streamTokens, new Source('', 'clippy'));\n$parser = $this->getParser($twigTokenStream, new SetcontentTokenParser());\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Fix test that broke after Twig 2.7.2 -> 2.7.3
|
95,144 |
24.03.2019 12:23:44
| -3,600 |
be686a0b78f21f022ff85b51a1daf13086a0448d
|
Solidify e2e tests, make sure required entry is published
|
[
{
"change_type": "MODIFY",
"old_path": "src/DataFixtures/ContentFixtures.php",
"new_path": "src/DataFixtures/ContentFixtures.php",
"diff": "@@ -60,7 +60,7 @@ class ContentFixtures extends Fixture implements DependentFixtureInterface\n$translationRepository = $manager->getRepository(Translation::class);\nforeach ($this->config as $contentType) {\n- $amount = $contentType['singleton'] ? 1 : (int) ($contentType['listing_records'] * 2.5);\n+ $amount = $contentType['singleton'] ? 1 : (int) ($contentType['listing_records'] * 3);\nforeach (range(1, $amount) as $i) {\n$ref = $i === 1 ? 'admin' : ['admin', 'henkie', 'jane_admin', 'tom_admin'][random_int(0, 3)];\n@@ -70,7 +70,6 @@ class ContentFixtures extends Fixture implements DependentFixtureInterface\n$content = new Content();\n$content->setContentType($contentType['slug']);\n$content->setAuthor($author);\n- $content->setStatus($i === 1 ? Statuses::PUBLISHED : $this->getRandomStatus());\n$content->setCreatedAt($this->faker->dateTimeBetween('-1 year'));\n$content->setModifiedAt($this->faker->dateTimeBetween('-1 year'));\n$content->setPublishedAt($this->faker->dateTimeBetween('-1 year'));\n@@ -78,6 +77,12 @@ class ContentFixtures extends Fixture implements DependentFixtureInterface\n$preset = $this->getPreset($contentType['slug']);\n+ if ($i === 1 || ! empty($preset)) {\n+ $content->setStatus(Statuses::PUBLISHED);\n+ } else {\n+ $content->setStatus($this->getRandomStatus());\n+ }\n+\n$sortorder = 1;\nforeach ($contentType['fields'] as $name => $fieldType) {\n$field = Field::factory($fieldType, $name);\n@@ -144,6 +149,10 @@ class ContentFixtures extends Fixture implements DependentFixtureInterface\nprivate function getPresetRecords(): array\n{\n+ $records['entries'][] = [\n+ 'title' => 'This is a record in the \"Entries\" ContentType',\n+ 'slug' => 'This is a record in the \"Entries\" ContentType',\n+ ];\n$records['blocks'][] = [\n'title' => 'About',\n];\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/e2e/features/display_listing.feature",
"new_path": "tests/e2e/features/display_listing.feature",
"diff": "Feature: Display a listing of records\n- @wip\nScenario: As a user I want to display a listing of records\nWhen I visit the \"listing_records\" page\nThen I wait for \"heading\" element to appear\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/e2e/features/edit_record_1.feature",
"new_path": "tests/e2e/features/edit_record_1.feature",
"diff": "@@ -71,7 +71,7 @@ Feature: Edit record\nGiven I am logged in as \"admin\"\nWhen I visit the \"edit_record\" page with parameters:\n- | id | 32 |\n+ | id | 44 |\nThen I wait for \"title_field\" element to appear\nThen I click the \"tab_media\" element\nWhen I fill the \"embed_field\" field with \"https://www.youtube.com/watch?v=x4IDM3ltTYo\"\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Solidify e2e tests, make sure required entry is published
|
95,144 |
23.03.2019 07:22:37
| -3,600 |
7d6378263c2817f4c03f9a2701ab405459b1a19f
|
Updating NPM packages and Font Awesome
|
[
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"url\": \"git://github.com/bolt/four.git\"\n},\n\"dependencies\": {\n- \"@babel/polyfill\": \"^7.2.5\",\n- \"@vue/cli-service\": \"^3.4.1\",\n+ \"@babel/polyfill\": \"^7.4.0\",\n+ \"@vue/cli-service\": \"^3.5.1\",\n\"axios\": \"^0.18.0\",\n\"baguettebox.js\": \"^1.11.0\",\n\"bootstrap\": \"^4.3.1\",\n- \"codemirror\": \"^5.44.0\",\n+ \"codemirror\": \"^5.45.0\",\n\"flagpack\": \"^1.0.3\",\n\"jquery\": \"^3.3.1\",\n\"moment\": \"^2.24.0\",\n\"no-scroll\": \"^2.1.1\",\n+ \"npm-check-updates\": \"^3.1.1\",\n\"popper.js\": \"^1.14.7\",\n\"register-service-worker\": \"^1.6.2\",\n\"simplemde\": \"^1.11.2\",\n\"stylelint-config-recommended-scss\": \"^3.2.0\",\n\"stylelint-scss\": \"^3.5.4\",\n- \"terser\": \"^3.16.1\",\n+ \"terser\": \"^3.17.0\",\n\"tinycolor2\": \"^1.4.1\",\n- \"vue\": \"^2.6.7\",\n- \"vue-flatpickr-component\": \"^8.1.1\",\n- \"vue-multiselect\": \"^2.1.3\",\n+ \"vue\": \"^2.6.10\",\n+ \"vue-flatpickr-component\": \"^8.1.2\",\n+ \"vue-multiselect\": \"^2.1.4\",\n\"vue-notification\": \"^1.3.16\",\n\"vue-simplemde\": \"^0.5.1\",\n- \"vue-trumbowyg\": \"^3.4.1\",\n- \"vuedraggable\": \"^2.18.1\",\n+ \"vue-trumbowyg\": \"^3.4.2\",\n+ \"vuedraggable\": \"^2.19.3\",\n\"vuex\": \"^3.1.0\"\n},\n\"devDependencies\": {\n- \"@babel/core\": \"^7.3.4\",\n- \"@babel/plugin-transform-regenerator\": \"^7.3.4\",\n- \"@babel/plugin-transform-runtime\": \"^7.3.4\",\n- \"@babel/polyfill\": \"^7.2.5\",\n- \"@babel/preset-env\": \"^7.3.4\",\n- \"@symfony/webpack-encore\": \"^0.23.0\",\n+ \"@babel/core\": \"^7.4.0\",\n+ \"@babel/plugin-transform-regenerator\": \"^7.4.0\",\n+ \"@babel/plugin-transform-runtime\": \"^7.4.0\",\n+ \"@babel/polyfill\": \"^7.4.0\",\n+ \"@babel/preset-env\": \"^7.4.2\",\n+ \"@symfony/webpack-encore\": \"^0.24.0\",\n\"@vue/test-utils\": \"^1.0.0-beta.29\",\n\"ajv-keywords\": \"^3.4.0\",\n- \"autoprefixer\": \"^9.4.9\",\n+ \"autoprefixer\": \"^9.5.0\",\n\"babel-core\": \"^7.0.0-bridge.0\",\n\"babel-eslint\": \"^10.0.1\",\n- \"babel-jest\": \"^24.1.0\",\n- \"eslint\": \"^5.14.1\",\n+ \"babel-jest\": \"^24.5.0\",\n+ \"eslint\": \"^5.15.3\",\n\"eslint-config-prettier\": \"^4.1.0\",\n\"eslint-plugin-prettier\": \"^3.0.1\",\n\"eslint-plugin-standard\": \"^4.0.0\",\n\"eslint-plugin-vue\": \"^5.2.2\",\n- \"jest\": \"^24.1.0\",\n+ \"jest\": \"^24.5.0\",\n\"jest-serializer-vue\": \"^2.0.2\",\n\"node-sass\": \"^4.11.0\",\n\"postcss-loader\": \"^3.0.0\",\n- \"postcss-preset-env\": \"^6.5.0\",\n+ \"postcss-preset-env\": \"^6.6.0\",\n\"prettier\": \"^1.16.4\",\n- \"regenerator-runtime\": \"^0.13.1\",\n+ \"regenerator-runtime\": \"^0.13.2\",\n\"sass-loader\": \"^7.1.0\",\n\"stylelint\": \"^9.10.1\",\n\"stylelint-config-standard\": \"^18.2.0\",\n- \"vue-jest\": \"^3.0.3\",\n- \"vue-loader\": \"^15.6.4\",\n+ \"vue-jest\": \"^3.0.4\",\n+ \"vue-loader\": \"^15.7.0\",\n\"vue-router\": \"^3.0.2\",\n- \"vue-template-compiler\": \"^2.6.7\",\n+ \"vue-template-compiler\": \"^2.6.10\",\n\"webpackbar\": \"^3.1.5\",\n- \"workbox-webpack-plugin\": \"^3.6.3\"\n+ \"workbox-webpack-plugin\": \"^4.1.1\"\n},\n\"scripts\": {\n\"start\": \"encore dev-server --port=8234 --progress --disable-host-check --verbose\",\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/_base/layout.html.twig",
"new_path": "templates/_base/layout.html.twig",
"diff": "<title>{{ block('title')|striptags }}</title>\n{% block stylesheets %}\n<link href=\"https://fonts.googleapis.com/css?family=Open+Sans:400,600|Source+Sans+Pro:300,400,600&subset=latin-ext\" rel=\"stylesheet\">\n- <link rel=\"stylesheet\" href=\"https://use.fontawesome.com/releases/v5.7.1/css/all.css\" integrity=\"sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr\" crossorigin=\"anonymous\">\n+ <link rel=\"stylesheet\" href=\"https://use.fontawesome.com/releases/v5.8.1/css/all.css\" integrity=\"sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf\" crossorigin=\"anonymous\">\n{% set theme = 'theme-' ~ user.backendTheme|default('default') %}\n{{ encore_entry_link_tags('bolt') }}\n{{ encore_entry_link_tags(theme) }}\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/e2e/package.json",
"new_path": "tests/e2e/package.json",
"diff": "\"cross-env\": \"^5.2.0\",\n\"kakunin\": \"^2.5\",\n\"protractor\": \"^5.4.2\",\n- \"webdriver-manager\": \"^12.1.1\"\n+ \"webdriver-manager\": \"^13.0.0\"\n}\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Updating NPM packages and Font Awesome
|
95,144 |
20.03.2019 21:05:46
| -3,600 |
8ca7e353114332df4ca73bfff8c87c6ba713a21d
|
Working on taxonmies in frontend
|
[
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/partials/_sub_taxonomylinks.twig",
"new_path": "public/theme/skeleton/partials/_sub_taxonomylinks.twig",
"diff": "-{# @todo See Github Issue https://github.com/bolt/four/issues/255 #}\n-{#\n-{% for type, values in record|taxonomy %}\n+{% for type, taxonomies in record|taxonomies %}\n<em>\n- {% if values|length < 2 %}\n- {{ config.get('taxonomy')[type].singular_name }}:\n+ {% if taxonomies|length < 2 %}\n+ {{ config.get('taxonomies')[type].singular_name }}:\n{% else %}\n- {{ config.get('taxonomy')[type].name }}:\n+ {{ config.get('taxonomies')[type].name }}:\n{% endif %}\n</em>\n- {% for link, value in values %}\n- <a href=\"{{ link }}\">{{ value }}</a>{% if not loop.last %}, {% endif %}\n+ {% for taxonomy in taxonomies %}\n+ <a href=\"{{ taxonomy.link }}\">{{ taxonomy.name }}</a>{% if not loop.last %}, {% endif %}\n{% else %}\n{{ __('general.phrase.none') }}\n{% endfor %}\n{% if not loop.last %} - {% endif %}\n{% endfor %}\n-#}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Frontend/TaxonomyController.php",
"new_path": "src/Controller/Frontend/TaxonomyController.php",
"diff": "@@ -30,8 +30,8 @@ class TaxonomyController extends TwigAwareController\n}\n/**\n- * @Route(\"\n- * /{taxonomyslug}/{slug}\",\n+ * @Route(\n+ * \"/{taxonomyslug}/{slug}\",\n* name=\"taxonomy\",\n* requirements={\"taxonomyslug\"=\"%bolt.requirement.taxonomies%\"},\n* methods={\"GET\"}\n@@ -41,13 +41,16 @@ class TaxonomyController extends TwigAwareController\n{\n$page = (int) $request->query->get('page', 1);\n- /** @var Content[] $records */\n- $records = $contentRepository->findForListing($page);\n-\n$contentType = ContentType::factory('page', $this->config->get('contenttypes'));\n+ /** @var Content[] $records */\n+ $records = $contentRepository->findForTaxonomy($page, $taxonomyslug, $slug);\n+\n$templates = $this->templateChooser->forListing($contentType);\nreturn $this->renderTemplate($templates, ['records' => $records]);\n+\n+\n+\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Repository/ContentRepository.php",
"new_path": "src/Repository/ContentRepository.php",
"diff": "@@ -51,6 +51,27 @@ class ContentRepository extends ServiceEntityRepository\nreturn $this->createPaginator($qb->getQuery(), $page, $contentType['listing_records']);\n}\n+ public function findForTaxonomy(int $page = 1, string $taxonomyslug, string $slug, bool $onlyPublished = true): Pagerfanta\n+ {\n+ $qb = $this->getQueryBuilder()\n+ ->addSelect('a')\n+ ->innerJoin('content.author', 'a');\n+\n+ $qb->addSelect('t')\n+ ->innerJoin('content.taxonomies', 't')\n+ ->andWhere('t.type = :taxonomyslug')\n+ ->setParameter('taxonomyslug', $taxonomyslug)\n+ ->andWhere('t.slug = :slug')\n+ ->setParameter('slug', $slug);\n+\n+ if ($onlyPublished) {\n+ $qb->andWhere('content.status = :status')\n+ ->setParameter('status', Statuses::PUBLISHED);\n+ }\n+\n+ return $this->createPaginator($qb->getQuery(), $page, 6);\n+ }\n+\npublic function findLatest(?ContentType $contentType = null, int $amount = 6): ?array\n{\n$qb = $this->getQueryBuilder()\n@@ -81,10 +102,10 @@ class ContentRepository extends ServiceEntityRepository\n// ->setParameter('values',['red','yellow']);\n}\n- private function createPaginator(Query $query, int $page, int $max): Pagerfanta\n+ private function createPaginator(Query $query, int $page, ?int $max): Pagerfanta\n{\n$paginator = new Pagerfanta(new DoctrineORMAdapter($query));\n- $paginator->setMaxPerPage($max);\n+ $paginator->setMaxPerPage($max ?: 6);\n$paginator->setCurrentPage($page);\nreturn $paginator;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Twig/ContentExtension.php",
"new_path": "src/Twig/ContentExtension.php",
"diff": "@@ -49,6 +49,7 @@ class ContentExtension extends AbstractExtension\nnew TwigFilter('next', [$this, 'getNextContent']),\nnew TwigFilter('link', [$this, 'getLink'], $safe),\nnew TwigFilter('edit_link', [$this, 'getEditLink'], $safe),\n+ new TwigFilter('taxonomies', [$this, 'getTaxonomies']),\n];\n}\n@@ -215,4 +216,29 @@ class ContentExtension extends AbstractExtension\n$absolute ? UrlGeneratorInterface::ABSOLUTE_URL : UrlGeneratorInterface::ABSOLUTE_PATH\n);\n}\n+\n+ public function getTaxonomies(Content $content): Collection\n+ {\n+ $taxonomies = [];\n+ foreach ($content->getTaxonomies() as $t) {\n+ $link = $this->urlGenerator->generate('taxonomy', [\n+ 'taxonomyslug' => $t->getType(),\n+ 'slug' => $t->getSlug(),\n+ ]);\n+\n+ $taxonomy = [\n+ 'slug' => $t->getSlug(),\n+ 'name' => $t->getName(),\n+ 'link' => $link,\n+ ];\n+\n+ if ($t->getSortorder()) {\n+ $taxonomy['sortorder'] = $t->getSortorder();\n+ }\n+\n+ $taxonomies[$t->getType()][$t->getSlug()] = $taxonomy;\n+ }\n+\n+ return new Collection($taxonomies);\n+ }\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Working on taxonmies in frontend
|
95,144 |
21.03.2019 07:41:10
| -3,600 |
ddf3434bb2bd173706a0f6ee7ecad72917e52efc
|
Working on Fixtures: Random taxo's!
|
[
{
"change_type": "MODIFY",
"old_path": "src/Controller/Frontend/TaxonomyController.php",
"new_path": "src/Controller/Frontend/TaxonomyController.php",
"diff": "@@ -5,7 +5,6 @@ declare(strict_types=1);\nnamespace Bolt\\Controller\\Frontend;\nuse Bolt\\Configuration\\Config;\n-use Bolt\\Content\\ContentType;\nuse Bolt\\Controller\\TwigAwareController;\nuse Bolt\\Entity\\Content;\nuse Bolt\\Repository\\ContentRepository;\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/DataFixtures/BaseFixture.php",
"diff": "+<?php\n+\n+declare(strict_types=1);\n+\n+namespace Bolt\\DataFixtures;\n+\n+use Doctrine\\Bundle\\FixturesBundle\\Fixture;\n+\n+abstract class BaseFixture extends Fixture\n+{\n+ private $referencesIndex = [];\n+ private $taxonomyIndex = [];\n+\n+ protected function getRandomReference(string $className)\n+ {\n+ if (! isset($this->referencesIndex[$className])) {\n+ $this->referencesIndex[$className] = [];\n+\n+ foreach (array_keys($this->referenceRepository->getReferences()) as $key) {\n+ if (mb_strpos($key, $className.'_') === 0) {\n+ $this->referencesIndex[$className][] = $key;\n+ }\n+ }\n+ }\n+ if (empty($this->referencesIndex[$className])) {\n+ throw new \\Exception(sprintf('Cannot find any references for class \"%s\"', $className));\n+ }\n+ $randomReferenceKey = array_rand($this->referencesIndex[$className], 1);\n+\n+ return $this->getReference($this->referencesIndex[$className][$randomReferenceKey]);\n+ }\n+\n+ protected function getRandomTaxonomy(string $type)\n+ {\n+ if (empty($this->taxonomyIndex)) {\n+ foreach (array_keys($this->referenceRepository->getReferences()) as $key) {\n+ if (mb_strpos($key, 'taxonomy_') === 0) {\n+ $tuples = explode('_', $key);\n+ $this->taxonomyIndex[$tuples[1]][] = $key;\n+ }\n+ }\n+ }\n+\n+ if (empty($this->taxonomyIndex[$type])) {\n+ return null;\n+ }\n+\n+ $randomReferenceKey = array_rand($this->taxonomyIndex[$type], 1);\n+\n+ return $this->getReference($this->taxonomyIndex[$type][$randomReferenceKey]);\n+ }\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/DataFixtures/ContentFixtures.php",
"new_path": "src/DataFixtures/ContentFixtures.php",
"diff": "@@ -8,9 +8,7 @@ use Bolt\\Collection\\DeepCollection;\nuse Bolt\\Configuration\\Config;\nuse Bolt\\Entity\\Content;\nuse Bolt\\Entity\\Field;\n-use Bolt\\Entity\\User;\nuse Bolt\\Enum\\Statuses;\n-use Doctrine\\Bundle\\FixturesBundle\\Fixture;\nuse Doctrine\\Common\\DataFixtures\\DependentFixtureInterface;\nuse Doctrine\\Common\\Persistence\\ObjectManager;\nuse Faker\\Factory;\n@@ -19,7 +17,7 @@ use Gedmo\\Translatable\\Entity\\Repository\\TranslationRepository;\nuse Gedmo\\Translatable\\Entity\\Translation;\nuse Tightenco\\Collect\\Support\\Collection;\n-class ContentFixtures extends Fixture implements DependentFixtureInterface\n+class ContentFixtures extends BaseFixture implements DependentFixtureInterface\n{\n/** @var Generator */\nprivate $faker;\n@@ -63,9 +61,11 @@ class ContentFixtures extends Fixture implements DependentFixtureInterface\n$amount = $contentType['singleton'] ? 1 : (int) ($contentType['listing_records'] * 3);\nforeach (range(1, $amount) as $i) {\n- $ref = $i === 1 ? 'admin' : ['admin', 'henkie', 'jane_admin', 'tom_admin'][random_int(0, 3)];\n- /** @var User $author */\n- $author = $this->getReference($ref);\n+ if ($i === 1) {\n+ $author = $this->getReference('user_admin');\n+ } else {\n+ $author = $this->getRandomReference('user');\n+ }\n$content = new Content();\n$content->setContentType($contentType['slug']);\n@@ -104,6 +104,24 @@ class ContentFixtures extends Fixture implements DependentFixtureInterface\n}\n}\n+ foreach ($contentType['taxonomy'] as $taxonomySlug) {\n+ if ($taxonomySlug === 'categories') {\n+ $amount = 2;\n+ } elseif ($taxonomySlug === 'tags') {\n+ $amount = 4;\n+ } else {\n+ $amount = 1;\n+ }\n+\n+ for ($i = 1; $i <= $amount; $i++) {\n+ $taxonomy = $this->getRandomTaxonomy($taxonomySlug);\n+\n+ if ($taxonomy) {\n+ $content->addTaxonomy($taxonomy);\n+ }\n+ }\n+ }\n+\n$manager->persist($content);\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/DataFixtures/TaxonomyFixtures.php",
"new_path": "src/DataFixtures/TaxonomyFixtures.php",
"diff": "@@ -8,11 +8,9 @@ use Bolt\\Collection\\DeepCollection;\nuse Bolt\\Configuration\\Config;\nuse Bolt\\Entity\\Taxonomy;\nuse Bolt\\Utils\\Str;\n-use Doctrine\\Bundle\\FixturesBundle\\Fixture;\n-use Doctrine\\Common\\DataFixtures\\DependentFixtureInterface;\nuse Doctrine\\Common\\Persistence\\ObjectManager;\n-class TaxonomyFixtures extends Fixture implements DependentFixtureInterface\n+class TaxonomyFixtures extends BaseFixture\n{\n/**\n* @var DeepCollection\n@@ -24,13 +22,6 @@ class TaxonomyFixtures extends Fixture implements DependentFixtureInterface\n$this->config = $config->get('taxonomies');\n}\n- public function getDependencies()\n- {\n- return [\n- UserFixtures::class,\n- ];\n- }\n-\npublic function load(ObjectManager $manager): void\n{\n$this->loadTaxonomies($manager);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/DataFixtures/UserFixtures.php",
"new_path": "src/DataFixtures/UserFixtures.php",
"diff": "@@ -5,11 +5,10 @@ declare(strict_types=1);\nnamespace Bolt\\DataFixtures;\nuse Bolt\\Entity\\User;\n-use Doctrine\\Bundle\\FixturesBundle\\Fixture;\nuse Doctrine\\Common\\Persistence\\ObjectManager;\nuse Symfony\\Component\\Security\\Core\\Encoder\\UserPasswordEncoderInterface;\n-class UserFixtures extends Fixture\n+class UserFixtures extends BaseFixture\n{\n/** @var UserPasswordEncoderInterface */\nprivate $passwordEncoder;\n@@ -39,7 +38,7 @@ class UserFixtures extends Fixture\n$user->setBackendTheme('default');\n$manager->persist($user);\n- $this->addReference($userData['username'], $user);\n+ $this->addReference('user_' . $userData['username'], $user);\n}\n$manager->flush();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Repository/ContentRepository.php",
"new_path": "src/Repository/ContentRepository.php",
"diff": "@@ -51,7 +51,7 @@ class ContentRepository extends ServiceEntityRepository\nreturn $this->createPaginator($qb->getQuery(), $page, $contentType['listing_records']);\n}\n- public function findForTaxonomy(int $page = 1, string $taxonomyslug, string $slug, ?int $amountPerPage = null, bool $onlyPublished = true): Pagerfanta\n+ public function findForTaxonomy(int $page, string $taxonomyslug, string $slug, ?int $amountPerPage = null, bool $onlyPublished = true): Pagerfanta\n{\n$qb = $this->getQueryBuilder()\n->addSelect('a')\n@@ -102,10 +102,10 @@ class ContentRepository extends ServiceEntityRepository\n// ->setParameter('values',['red','yellow']);\n}\n- private function createPaginator(Query $query, int $page, ?int $max): Pagerfanta\n+ private function createPaginator(Query $query, int $page, ?int $amountPerPage): Pagerfanta\n{\n$paginator = new Pagerfanta(new DoctrineORMAdapter($query));\n- $paginator->setMaxPerPage($max ?: 6);\n+ $paginator->setMaxPerPage($amountPerPage ?: 6);\n$paginator->setCurrentPage($page);\nreturn $paginator;\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Working on Fixtures: Random taxo's!
|
95,144 |
24.03.2019 14:34:29
| -3,600 |
1302f9b7089f17c38670353a0f3a19ab82de2f8d
|
Update test with fixed Record
|
[
{
"change_type": "MODIFY",
"old_path": "tests/e2e/features/display_taxonomies.feature",
"new_path": "tests/e2e/features/display_taxonomies.feature",
"diff": "@@ -3,7 +3,7 @@ Feature: Display taxonomies\n@wip\nScenario: As a user I want to see taxonomies on a single record\nWhen I visit the \"single_record\" page with parameters:\n- | id | 19 |\n+ | id | this-is-a-record-in-the-entries-contenttype |\nThen I wait for \"title\" element to appear\nAnd there are \"equal 2\" \"taxonomy_categories\" elements\nAnd there are \"equal 4\" \"taxonomy_tags\" elements\n@@ -12,7 +12,7 @@ Feature: Display taxonomies\nScenario: As an admin I want to a listing of a taxonomy\nWhen I visit the \"single_record\" page with parameters:\n- | id | 19 |\n+ | id | this-is-a-record-in-the-entries-contenttype |\nThen I wait for \"title\" element to appear\nAnd I scroll to the \"first_category\" element\nAnd I click the \"first_category\" element\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Update test with fixed Record
|
95,144 |
24.03.2019 16:37:31
| -3,600 |
b008cae4ac06cfd50c78615ca8b82d78dd0f833b
|
Some SCSS tweaks
|
[
{
"change_type": "MODIFY",
"old_path": "assets/scss/init/_variables.scss",
"new_path": "assets/scss/init/_variables.scss",
"diff": "$card-box-shadow: 0 7.5px 15px -5px rgba(0, 0, 0, 0.07);\n-$letter-spacing: 1px;\n+$letter-spacing: 0px;\n+\n+$bolt-blue: #255687; // Nice and bright, pretty light\n+$bolt-bluegray: #2F3E4D; // Nice dark and desaturated\n+$bolt-saturated: #003E7C; // Very saturated. Use with care\n+\n+\n"
},
{
"change_type": "MODIFY",
"old_path": "assets/scss/layout/_admin.scss",
"new_path": "assets/scss/layout/_admin.scss",
"diff": "//** Layout | Admin\n-$admin-toolbar-height: 30px;\n+$admin-toolbar-height: 36px;\n$admin-sidebar-width: 200px;\n$admin-aside-width: 320px;\n$admin-header-height: 70px;\n"
},
{
"change_type": "MODIFY",
"old_path": "assets/scss/modules/admin/_header.scss",
"new_path": "assets/scss/modules/admin/_header.scss",
"diff": "font-size: $h2-font-size;\ni {\n- color: var(--primary);\n+ color: var(--boltblue);\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "assets/scss/modules/admin/_sidebar.scss",
"new_path": "assets/scss/modules/admin/_sidebar.scss",
"diff": ".link--menu {\nbackground: var(--admin-sidebar-menu);\nborder-radius: 0 $border-radius $border-radius 0;\n+ box-shadow: 5px 5px 30px rgba(0, 0, 0, 0.2);\n+ border: 1px solid rgba(0, 0, 0, 0.1);\nposition: absolute;\nleft: 100%;\ntop: 0;\n&--footer {\n-webkit-backface-visibility: hidden;\n- @include darken(--admin-sidebar, 0.02);\n+ background: transparent;\ncolor: var(--admin-sidebar-text);\nposition: fixed;\n"
},
{
"change_type": "MODIFY",
"old_path": "assets/scss/modules/admin/_toolbar.scss",
"new_path": "assets/scss/modules/admin/_toolbar.scss",
"diff": "width: 100%;\ndisplay: flex;\nfont-size: 90%;\n+ padding: 0 1rem 0 0;\n&.is-dark {\ncolor: var(--admin-toolbar-text-light);\ndisplay: flex;\nalign-items: center;\njustify-content: center;\n- padding: 0 $spacer / 2;\n+ padding: 0 $spacer;\nopacity: 0.75;\ni {\n"
},
{
"change_type": "MODIFY",
"old_path": "assets/scss/themes/default.scss",
"new_path": "assets/scss/themes/default.scss",
"diff": "//** Theme | Default\n+@import '../init/variables';\n@import '../init/mixins';\n@import '_shared';\n+$bolt-blue: #003E7C; // Very saturated. Use with care\n+$bolt-bluegray: #2F3E4D; // Nice dark and desaturated\n+\n:root {\n--background: #f3f5f7;\n--foreground: #fff;\n--status-draft: #1078da;\n--status-held: #dd2443;\n--status-timed: #741ce6;\n- --admin-sidebar: #0c223b;\n- --admin-sidebar-text: #fff;\n- --admin-sidebar-icon: #fff;\n- --admin-sidebar-menu: #0a1d32;\n- --admin-sidebar-menu-text: #fff;\n- --admin-toolbar: #053b7a;\n+ --admin-sidebar: #2F3E4D;\n+ --admin-sidebar-text: #EEE;\n+ --admin-sidebar-icon: #FFF;\n+ --admin-sidebar-menu: #f0f3f5;\n+ --admin-sidebar-menu-text: #666;\n+ --admin-toolbar: #4C6E91;\n--admin-toolbar-text-light: #fff;\n--admin-toolbar-text-dark: #0c223b;\n- @include generate-color(primary, 212, 70%, 35%);\n- @include generate-color(secondary, 212, 90%, 25%);\n+ @include generate-color(primary, 210, 76%, 39%);\n+ @include generate-color(secondary, 188, 32%, 52%);\n@include generate-color(body, 212, 66%, 14%);\n@include generate-color(shade, 208, 13%, 43%);\n@include generate-color(grey, 251, 20%, 92%);\n- @include generate-color(success, 152, 92%, 38%);\n- @include generate-color(danger, 350, 73%, 50%);\n+ @include generate-color(success, 90, 68%, 38%);\n+ @include generate-color(danger, 359, 72%, 50%);\n+ @include generate-color(boltblue, 210, 88%, 32%);\n+\n}\n$bootstrap-colors: (\n@@ -37,3 +43,8 @@ $bootstrap-colors: (\n);\n@import '_bootstrap';\n+\n+.admin__sidebar {\n+ background: rgb(42,57,70);\n+ background: linear-gradient(-70deg, rgba(47,62,77,1) 50%, rgba(42,57,70,1) 50.5%);\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"vue-notification\": \"^1.3.16\",\n\"vue-simplemde\": \"^0.5.1\",\n\"vue-trumbowyg\": \"^3.4.2\",\n- \"vuedraggable\": \"^2.19.3\",\n+ \"vuedraggable\": \"^2.20.0\",\n\"vuex\": \"^3.1.0\"\n},\n\"devDependencies\": {\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/content/_buttons.html.twig",
"new_path": "templates/content/_buttons.html.twig",
"diff": "{% if record.id %}\n \n- <button type=\"submit\" class=\"btn btn-secondary mb-3\" form=\"editcontent\"\n+ <button type=\"submit\" class=\"btn btn-primary mb-3\" form=\"editcontent\"\nformaction=\"{{ path('bolt_content_edit_preview', {'id': record.id }) }}\" formtarget=\"_blank\">\n<i class=\"fas fa-external-link-square-alt mr-2\"></i>\n{{ 'action.preview'|trans }}\n</button>\n{% if record.status == \"published\" %}\n- <button type=\"button\" class=\"btn btn-secondary dropdown-toggle dropdown-toggle-split mb-3\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\">\n+ <button type=\"button\" class=\"btn btn-primary dropdown-toggle dropdown-toggle-split mb-3\" data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\">\n<span class=\"sr-only\">Toggle Dropdown</span>\n</button>\n<button type=\"submit\" class=\"btn btn-light dropdown-menu dropdown-menu-right\" form=\"editcontent\"\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Some SCSS tweaks
|
95,144 |
26.03.2019 15:40:49
| -3,600 |
ed445a0f64bd52da516bbd4416825cded0e7e18f
|
Getting rid of magic number
|
[
{
"change_type": "MODIFY",
"old_path": "src/Controller/Frontend/TaxonomyController.php",
"new_path": "src/Controller/Frontend/TaxonomyController.php",
"diff": "@@ -39,9 +39,10 @@ class TaxonomyController extends TwigAwareController\npublic function listing(ContentRepository $contentRepository, Request $request, string $taxonomyslug, string $slug): Response\n{\n$page = (int) $request->query->get('page', 1);\n+ $amountPerPage = $this->config->get('general/listing_records');\n/** @var Content[] $records */\n- $records = $contentRepository->findForTaxonomy($page, $taxonomyslug, $slug, $this->config->get('listing_records'));\n+ $records = $contentRepository->findForTaxonomy($page, $taxonomyslug, $slug, $amountPerPage);\n$templates = $this->templateChooser->forTaxonomy($taxonomyslug);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/DataFixtures/BaseFixture.php",
"new_path": "src/DataFixtures/BaseFixture.php",
"diff": "@@ -11,23 +11,23 @@ abstract class BaseFixture extends Fixture\nprivate $referencesIndex = [];\nprivate $taxonomyIndex = [];\n- protected function getRandomReference(string $className)\n+ protected function getRandomReference(string $entityName)\n{\n- if (! isset($this->referencesIndex[$className])) {\n- $this->referencesIndex[$className] = [];\n+ if (! isset($this->referencesIndex[$entityName])) {\n+ $this->referencesIndex[$entityName] = [];\nforeach (array_keys($this->referenceRepository->getReferences()) as $key) {\n- if (mb_strpos($key, $className.'_') === 0) {\n- $this->referencesIndex[$className][] = $key;\n+ if (mb_strpos($key, $entityName.'_') === 0) {\n+ $this->referencesIndex[$entityName][] = $key;\n}\n}\n}\n- if (empty($this->referencesIndex[$className])) {\n- throw new \\Exception(sprintf('Cannot find any references for class \"%s\"', $className));\n+ if (empty($this->referencesIndex[$entityName])) {\n+ throw new \\Exception(sprintf('Cannot find any references for Entity \"%s\"', $entityName));\n}\n- $randomReferenceKey = array_rand($this->referencesIndex[$className], 1);\n+ $randomReferenceKey = array_rand($this->referencesIndex[$entityName], 1);\n- return $this->getReference($this->referencesIndex[$className][$randomReferenceKey]);\n+ return $this->getReference($this->referencesIndex[$entityName][$randomReferenceKey]);\n}\nprotected function getRandomTaxonomy(string $type)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Repository/ContentRepository.php",
"new_path": "src/Repository/ContentRepository.php",
"diff": "@@ -48,10 +48,12 @@ class ContentRepository extends ServiceEntityRepository\n->setParameter('status', Statuses::PUBLISHED);\n}\n- return $this->createPaginator($qb->getQuery(), $page, $contentType['listing_records']);\n+ $amountPerPage = $contentType['listing_records'];\n+\n+ return $this->createPaginator($qb->getQuery(), $page, $amountPerPage);\n}\n- public function findForTaxonomy(int $page, string $taxonomyslug, string $slug, ?int $amountPerPage = null, bool $onlyPublished = true): Pagerfanta\n+ public function findForTaxonomy(int $page, string $taxonomyslug, string $slug, int $amountPerPage, bool $onlyPublished = true): Pagerfanta\n{\n$qb = $this->getQueryBuilder()\n->addSelect('a')\n@@ -105,7 +107,7 @@ class ContentRepository extends ServiceEntityRepository\nprivate function createPaginator(Query $query, int $page, ?int $amountPerPage): Pagerfanta\n{\n$paginator = new Pagerfanta(new DoctrineORMAdapter($query));\n- $paginator->setMaxPerPage($amountPerPage ?: 6);\n+ $paginator->setMaxPerPage($amountPerPage);\n$paginator->setCurrentPage($page);\nreturn $paginator;\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Getting rid of magic number
|
95,144 |
26.03.2019 16:09:16
| -3,600 |
34bd2bcf62ae796cce4312ff4a3a56df863a1b7a
|
Splitting e2e test for Taxonomy
|
[
{
"change_type": "MODIFY",
"old_path": "tests/e2e/features/display_taxonomies.feature",
"new_path": "tests/e2e/features/display_taxonomies.feature",
"diff": "Feature: Display taxonomies\n- @wip\nScenario: As a user I want to see taxonomies on a single record\nWhen I visit the \"single_record\" page with parameters:\n| id | this-is-a-record-in-the-entries-contenttype |\n@@ -8,12 +7,12 @@ Feature: Display taxonomies\nAnd there are \"equal 2\" \"taxonomy_categories\" elements\nAnd there are \"equal 4\" \"taxonomy_tags\" elements\n- @wip\n-\n- Scenario: As an admin I want to a listing of a taxonomy\n+ Scenario: As an admin I want to see a listing of a taxonomy\nWhen I visit the \"single_record\" page with parameters:\n| id | this-is-a-record-in-the-entries-contenttype |\nThen I wait for \"title\" element to appear\nAnd I scroll to the \"first_category\" element\nAnd I click the \"first_category\" element\n+\n+ Then the \"listing_taxonomies\" page is displayed\nAnd there are \"at least 3\" \"article\" elements\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "tests/e2e/pages/listing_taxonomies.js",
"diff": "+const { BasePage } = require('kakunin');\n+\n+class ListingTaxonomiesPage extends BasePage {\n+ constructor() {\n+ super();\n+\n+ this.url = '/:type/:slug';\n+\n+ this.article = $$('article');\n+ }\n+}\n+\n+module.exports = ListingTaxonomiesPage;\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/e2e/pages/single_record.js",
"new_path": "tests/e2e/pages/single_record.js",
"diff": "@@ -13,7 +13,6 @@ class SingleRecordPage extends BasePage {\nthis.taxonomy_tags = $$('.taxonomy-tags');\nthis.taxonomy_categories = $$('.taxonomy-categories');\nthis.first_category = $('.taxonomy-categories');\n- this.article = $$('article');\n}\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Splitting e2e test for Taxonomy
|
95,144 |
27.03.2019 17:36:00
| -3,600 |
69838e9b4827800565007af2b64581ff227c23a4
|
Get rid of hardcoded/magical amountPerPage
|
[
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/ContentOverviewController.php",
"new_path": "src/Controller/Backend/ContentOverviewController.php",
"diff": "@@ -25,8 +25,9 @@ class ContentOverviewController extends TwigAwareController\n$contentType = ContentType::factory($contentType, $this->config->get('contenttypes'));\n$page = (int) $request->query->get('page', 1);\n+ $amountPerPage = $contentType->get('listing_records');\n- $records = $contentRepository->findForListing($page, $contentType, false);\n+ $records = $contentRepository->findForListing($page, $amountPerPage, $contentType, false);\nreturn $this->renderTemplate('@bolt/content/listing.html.twig', [\n'records' => $records,\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Frontend/ListingController.php",
"new_path": "src/Controller/Frontend/ListingController.php",
"diff": "@@ -38,12 +38,13 @@ class ListingController extends TwigAwareController\n*/\npublic function listing(ContentRepository $contentRepository, Request $request, string $contentTypeSlug): Response\n{\n- $page = (int) $request->query->get('page', 1);\n-\n$contentType = ContentType::factory($contentTypeSlug, $this->config->get('contenttypes'));\n+ $page = (int) $request->query->get('page', 1);\n+ $amountPerPage = $contentType->get('listing_records');\n+\n/** @var Content[] $records */\n- $records = $contentRepository->findForListing($page, $contentType);\n+ $records = $contentRepository->findForListing($page, $amountPerPage, $contentType);\n$templates = $this->templateChooser->forListing($contentType);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Frontend/SearchController.php",
"new_path": "src/Controller/Frontend/SearchController.php",
"diff": "@@ -37,9 +37,10 @@ class SearchController extends TwigAwareController\npublic function search(ContentRepository $contentRepository, Request $request): Response\n{\n$page = (int) $request->query->get('page', 1);\n+ $amountPerPage = $this->config->get('general/listing_records');\n// @todo implement actual Search Engine\n- $records = $contentRepository->findForListing($page);\n+ $records = $contentRepository->findForListing($page, $amountPerPage);\n$templates = $this->templateChooser->forSearch();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Repository/ContentRepository.php",
"new_path": "src/Repository/ContentRepository.php",
"diff": "@@ -32,7 +32,7 @@ class ContentRepository extends ServiceEntityRepository\nreturn $this->createQueryBuilder('content');\n}\n- public function findForListing(int $page = 1, ?ContentType $contentType = null, bool $onlyPublished = true): Pagerfanta\n+ public function findForListing(int $page, int $amountPerPage, ?ContentType $contentType = null, bool $onlyPublished = true): Pagerfanta\n{\n$qb = $this->getQueryBuilder()\n->addSelect('a')\n@@ -48,8 +48,6 @@ class ContentRepository extends ServiceEntityRepository\n->setParameter('status', Statuses::PUBLISHED);\n}\n- $amountPerPage = $contentType['listing_records'];\n-\nreturn $this->createPaginator($qb->getQuery(), $page, $amountPerPage);\n}\n@@ -104,7 +102,7 @@ class ContentRepository extends ServiceEntityRepository\n// ->setParameter('values',['red','yellow']);\n}\n- private function createPaginator(Query $query, int $page, ?int $amountPerPage): Pagerfanta\n+ private function createPaginator(Query $query, int $page, int $amountPerPage): Pagerfanta\n{\n$paginator = new Pagerfanta(new DoctrineORMAdapter($query));\n$paginator->setMaxPerPage($amountPerPage);\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Get rid of hardcoded/magical amountPerPage
|
95,144 |
27.03.2019 17:55:43
| -3,600 |
6450591cdfe93acbde9760c215a5e35a133afbcc
|
Don't construct new unneeded arrays.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Entity/Taxonomy.php",
"new_path": "src/Entity/Taxonomy.php",
"diff": "@@ -52,6 +52,11 @@ class Taxonomy\n*/\nprivate $sortorder = 0;\n+ /**\n+ * @var string\n+ */\n+ private $link;\n+\npublic function __construct()\n{\n$this->content = new ArrayCollection();\n@@ -150,4 +155,16 @@ class Taxonomy\nreturn $this;\n}\n+\n+ public function getLink(): ?string\n+ {\n+ return $this->link;\n+ }\n+\n+ public function setLink(string $link): self\n+ {\n+ $this->link = $link;\n+\n+ return $this;\n+ }\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Twig/ContentExtension.php",
"new_path": "src/Twig/ContentExtension.php",
"diff": "@@ -220,23 +220,13 @@ class ContentExtension extends AbstractExtension\npublic function getTaxonomies(Content $content): Collection\n{\n$taxonomies = [];\n- foreach ($content->getTaxonomies() as $t) {\n+ foreach ($content->getTaxonomies() as $taxonomy) {\n$link = $this->urlGenerator->generate('taxonomy', [\n- 'taxonomyslug' => $t->getType(),\n- 'slug' => $t->getSlug(),\n+ 'taxonomyslug' => $taxonomy->getType(),\n+ 'slug' => $taxonomy->getSlug(),\n]);\n-\n- $taxonomy = [\n- 'slug' => $t->getSlug(),\n- 'name' => $t->getName(),\n- 'link' => $link,\n- ];\n-\n- if ($t->getSortorder()) {\n- $taxonomy['sortorder'] = $t->getSortorder();\n- }\n-\n- $taxonomies[$t->getType()][$t->getSlug()] = $taxonomy;\n+ $taxonomy->setLink($link);\n+ $taxonomies[$taxonomy->getType()][$taxonomy->getSlug()] = $taxonomy;\n}\nreturn new Collection($taxonomies);\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Don't construct new unneeded arrays.
|
95,144 |
28.03.2019 06:50:16
| -3,600 |
0e16d4a61f16428b4127cf805063d286d2776a85
|
Cleanup of config files
|
[
{
"change_type": "MODIFY",
"old_path": "config/bolt/contenttypes.yaml",
"new_path": "config/bolt/contenttypes.yaml",
"diff": "# The Homepage content type is a singleton: There can be only one record of this\n# content type.\n-\nhomepage:\nname: Homepage\nsingular_name: Homepage\n@@ -146,8 +145,6 @@ entries:\nicon_many: \"fa:file-alt\"\nicon_one: \"fa:file-alt\"\n- # class: Bundle\\Site\\BobEntity\n-\n# The 'Showcases' is not particularly useful in most cases, but it does a good\n# job of showcasing most of the available fieldtypes. Feel free to delete it, or\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Cleanup of config files
|
95,144 |
24.03.2019 08:16:32
| -3,600 |
eec9744dbff769a775b530080b0964d60ac7aeeb
|
Adding tests, tweaks and fixes
|
[
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/search.twig",
"new_path": "public/theme/skeleton/search.twig",
"diff": "we display an appropriate title. The 'records' array contains all of the\nrecords matching the current query. If there are no results, the\ncode in the 'else' part of the for-loop is used. #}\n- <h1>\n+ <h1 class=\"search-results\">\n{% if search is not empty %}\n- {{ __('general.phrase.search-results-for-variable', { '%search%': search }) }}\n+ {{ __('general.phrase.search-results-for', { '%search%': search }) }}\n{% else %}\n{{ __('general.phrase.search') }}\n{% endif %}\n{% endif %}\n{% else %}\n- <article>\n<p>\n- {{ __('general.phrase.no-result-for-search-term', { '%SEARCHTERM%': search|escape }) }}\n+ {{ __('general.phrase.no-search-results-for', { '%search%': search|escape }) }}\n</p>\n- </article>\n{% endfor %}\n{# If there are more records than will fit on one page, the pager is shown. #}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Frontend/SearchController.php",
"new_path": "src/Controller/Frontend/SearchController.php",
"diff": "@@ -39,7 +39,7 @@ class SearchController extends TwigAwareController\n$page = (int) $request->query->get('page', 1);\n$amountPerPage = $this->config->get('general/listing_records');\n- $search = $request->get('search');\n+ $search = $request->get('search', '');\n// @todo implement actual Search Engine\n$records = $contentRepository->findNaiveSearch($page, $search);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Repository/ContentRepository.php",
"new_path": "src/Repository/ContentRepository.php",
"diff": "@@ -72,6 +72,10 @@ class ContentRepository extends ServiceEntityRepository\npublic function findNaiveSearch(int $page = 1, string $search = '', int $amountPerPage = 6, bool $onlyPublished = true)\n{\n+ if (empty($search)) {\n+ return null;\n+ }\n+\n// First, create a querybuilder to get the fields that match the Query\n$qb = $this->getQueryBuilder()\n->select('partial content.{id}');\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Twig/RecordExtension.php",
"new_path": "src/Twig/RecordExtension.php",
"diff": "@@ -75,8 +75,12 @@ class RecordExtension extends AbstractExtension\nreturn $input;\n}\n- public function pager(Environment $env, Pagerfanta $records, string $template = '_sub_pager.twig', string $class = 'pagination', string $theme = 'default', int $surround = 3)\n+ public function pager(Environment $env, ?Pagerfanta $records, string $template = '_sub_pager.twig', string $class = 'pagination', string $theme = 'default', int $surround = 3)\n{\n+ if (!$records) {\n+ return;\n+ }\n+\n$context = [\n'records' => $records,\n'surround' => $surround,\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "tests/e2e/features/display_search.feature",
"diff": "+Feature: Display search functionality\n+ @wip\n+ Scenario: As a user I want to display search results\n+ When I visit the \"homepage\" page\n+\n+ Then I scroll to the \"search_input\" element\n+ When I fill the \"search_input\" field with \"consequatur\"\n+ And I click the \"search_button\" element\n+\n+ Then there is element \"search_results_title\" with text \"Search results for 'consequatur'.\"\n+ And there are \"at least 3\" \"article\" elements\n+ And there is element \"search_input\" with text \"consequatur\"\n+\n+ Then I fill the \"search_input\" field with \"ymnrubeyrvwearsytevsf\"\n+ And I click the \"search_button\" element\n+\n+ Then there is element \"search_results_title\" with text \"Search results for 'ymnrubeyrvwearsytevsf'.\"\n+ And there are \"eq 0\" \"article\" elements\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/e2e/kakunin.conf.js",
"new_path": "tests/e2e/kakunin.conf.js",
"diff": "@@ -50,7 +50,7 @@ module.exports = {\n\"clearCookiesAfterScenario\": true,\n\"clearLocalStorageAfterScenario\": true,\n\"email\": null,\n- \"headless\": true,\n+ \"headless\": false,\n\"noGpu\": false,\n\"type\": \"otherWeb\",\n\"baseUrl\": \"http://127.0.0.1:8088\",\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/e2e/pages/homepage.js",
"new_path": "tests/e2e/pages/homepage.js",
"diff": "@@ -8,6 +8,13 @@ class HomepagePage extends BasePage {\nthis.title = $('header a');\nthis.recent_pages_list = $('aside ul');\n+\n+ // For testing \"search\"\n+ this.search_input = $('#searchform-inline input[name=\"search\"');\n+ this.search_button = $('#searchform-inline button');\n+\n+ this.search_results_title = $('h1.search-results');\n+ this.article = $$('article');\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "translations/messages.en.xlf",
"new_path": "translations/messages.en.xlf",
"diff": "<target>The Kitchensink</target>\n</segment>\n</unit>\n+ <unit id=\"eq5YMQf\" name=\"9fb3e6e\">\n+ <segment>\n+ <source>This website is <a href='%url%' target='_blank' title='Sophisticated, lightweight & simple CMS'>Built with Bolt</a>.</source>\n+ <target><![CDATA[This website is <a href='%url%' target='_blank' title='Sophisticated, lightweight & simple CMS'>Built with Bolt</a>.]]></target>\n+ </segment>\n+ </unit>\n+ <unit id=\"2CfJ3WY\" name=\"general.phrase.search-results-for\">\n+ <segment>\n+ <source>general.phrase.search-results-for</source>\n+ <target>Search results for '%search%'.</target>\n+ </segment>\n+ </unit>\n+ <unit id=\"V0VhH5g\" name=\"general.phrase.no-search-results-for\">\n+ <segment>\n+ <source>general.phrase.no-search-results-for</source>\n+ <target>No search results found for '%search%'.</target>\n+ </segment>\n+ </unit>\n</file>\n</xliff>\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Adding tests, tweaks and fixes
|
95,144 |
27.03.2019 16:32:39
| -3,600 |
bc4223a56c21cd09ccea6bed61f31278ca84b569
|
Expanding the test case for search
|
[
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/search.twig",
"new_path": "public/theme/skeleton/search.twig",
"diff": "{% else %}\n- <p>\n+ {% if search is not empty %}\n+ <p class=\"search-results-description\">\n{{ __('general.phrase.no-search-results-for', { '%search%': search|escape }) }}\n</p>\n+ {% else %}\n+ <p class=\"search-results-description\">\n+ {{ __('general.phrase.no-search-term-provided') }}\n+ </p>\n+ {% endif %}\n{% endfor %}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Twig/RecordExtension.php",
"new_path": "src/Twig/RecordExtension.php",
"diff": "@@ -75,9 +75,9 @@ class RecordExtension extends AbstractExtension\nreturn $input;\n}\n- public function pager(Environment $env, Pagerfanta $records, string $template = '_sub_pager.twig', string $class = 'pagination', string $theme = 'default', int $surround = 3)\n+ public function pager(Environment $env, ?Pagerfanta $records, string $template = '_sub_pager.twig', string $class = 'pagination', string $theme = 'default', int $surround = 3)\n{\n- if (count($records) === 0) {\n+ if (!is_iterable($records)) {\nreturn;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "symfony.lock",
"new_path": "symfony.lock",
"diff": "\"guzzlehttp/psr7\": {\n\"version\": \"1.4.2\"\n},\n+ \"illuminate/contracts\": {\n+ \"version\": \"v5.8.8\"\n+ },\n+ \"illuminate/support\": {\n+ \"version\": \"v5.8.8\"\n+ },\n\"intervention/image\": {\n\"version\": \"2.4.2\"\n},\n\"symplify/package-builder\": {\n\"version\": \"v5.2.3\"\n},\n- \"symplify/token-runner\": {\n- \"version\": \"v5.2.3\"\n- },\n\"theseer/tokenizer\": {\n\"version\": \"1.1.0\"\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/e2e/features/display_search.feature",
"new_path": "tests/e2e/features/display_search.feature",
"diff": "@@ -16,4 +16,12 @@ Feature: Display search functionality\nAnd I click the \"search_button\" element\nThen there is element \"search_results_title\" with text \"Search results for 'ymnrubeyrvwearsytevsf'.\"\n+ And there is element \"search_results_description\" with text \"No search results found for 'ymnrubeyrvwearsytevsf'.\"\n+\n+ And there are \"eq 0\" \"article\" elements\n+\n+ Then I fill the \"search_input\" field with \"\"\n+ And I click the \"search_button\" element\n+\n+ Then there is element \"search_results_description\" with text \"Please provide a search term, in order to display relevant results.\"\nAnd there are \"eq 0\" \"article\" elements\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/e2e/pages/search.js",
"new_path": "tests/e2e/pages/search.js",
"diff": "@@ -10,6 +10,7 @@ class SearchPage extends BasePage {\nthis.search_button = $('#searchform-inline button');\nthis.search_results_title = $('h1.search-results');\n+ this.search_results_description = $('p.search-results-description');\nthis.article = $$('article');\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "translations/messages.en.xlf",
"new_path": "translations/messages.en.xlf",
"diff": "<target>No search results found for '%search%'.</target>\n</segment>\n</unit>\n+ <unit id=\"_KyvT9o\" name=\"general.phrase.no-search-term-provided\">\n+ <segment>\n+ <source>general.phrase.no-search-term-provided</source>\n+ <target>Please provide a search term, in order to display relevant results.</target>\n+ </segment>\n+ </unit>\n</file>\n</xliff>\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Expanding the test case for search
|
95,144 |
29.03.2019 06:53:41
| -3,600 |
1141deb4718ccf9b4ebd694dc12b0f14f6e89059
|
Rename 'search' to 'searchTerm'
|
[
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/partials/_footer.twig",
"new_path": "public/theme/skeleton/partials/_footer.twig",
"diff": "<h4>{{ __('Search') }}</h4>\n<form method=\"get\" action=\"{{ path('search') }}\" id=\"searchform-inline\" enctype=\"text/plain\">\n- <input type=\"search\" value=\"{{ search|default() }}\" placeholder=\"{{ __('general.phrase.search-ellipsis') }}\" name=\"search\" >\n+ <input type=\"search\" value=\"{{ searchTerm|default() }}\" placeholder=\"{{ __('general.phrase.search-ellipsis') }}\" name=\"searchTerm\" >\n<button type=\"submit\">{{ __('general.phrase.search') }}</button>\n</form>\n"
},
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/search.twig",
"new_path": "public/theme/skeleton/search.twig",
"diff": "records matching the current query. If there are no results, the\ncode in the 'else' part of the for-loop is used. #}\n<h1 class=\"search-results\">\n- {% if search is not empty %}\n- {{ __('general.phrase.search-results-for', { '%search%': search }) }}\n+ {% if searchTerm is not empty %}\n+ {{ __('general.phrase.search-results-for', { '%search%': searchTerm }) }}\n{% else %}\n{{ __('general.phrase.search') }}\n{% endif %}\n{% endif %}\n<form method=\"get\" action=\"{{ path('search') }}\" id=\"searchform-inline\" enctype=\"text/plain\">\n- <input type=\"search\" value=\"{{ search|default() }}\" placeholder=\"{{ __('general.phrase.search-ellipsis') }}\" name=\"search\" >\n+ <input type=\"search\" value=\"{{ searchTerm|default() }}\" placeholder=\"{{ __('general.phrase.search-ellipsis') }}\" name=\"searchTerm\" >\n<button type=\"submit\">{{ __('general.phrase.search') }}</button>\n</form>\n{% if search is not empty %}\n<p class=\"search-results-description\">\n- {{ __('general.phrase.no-search-results-for', { '%search%': search|escape }) }}\n+ {{ __('general.phrase.no-search-results-for', { '%search%': searchTerm|escape }) }}\n</p>\n{% else %}\n<p class=\"search-results-description\">\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Frontend/SearchController.php",
"new_path": "src/Controller/Frontend/SearchController.php",
"diff": "@@ -39,18 +39,19 @@ class SearchController extends TwigAwareController\npublic function search(ContentRepository $contentRepository, Request $request): Response\n{\n$page = (int) $request->query->get('page', 1);\n- $search = $request->get('search', '');\n+ $searchTerm = $request->get('searchTerm', $request->get('search', $request->get('q', '')));\n$amountPerPage = $this->config->get('general/listing_records');\n// @todo implement actual Search Engine\n- if (! empty($search)) {\n- $records = $contentRepository->searchNaive($search, $page, $amountPerPage);\n+ if (! empty($searchTerm)) {\n+ $records = $contentRepository->searchNaive($searchTerm, $page, $amountPerPage);\n} else {\n$records = new Pagerfanta(new ArrayAdapter([]));\n}\n$context = [\n- 'search' => $search,\n+ 'searchTerm' => $searchTerm,\n+ 'search' => $searchTerm, // Keep 'search' for Backwards Compatibility\n'records' => $records,\n];\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Repository/ContentRepository.php",
"new_path": "src/Repository/ContentRepository.php",
"diff": "@@ -48,9 +48,28 @@ class ContentRepository extends ServiceEntityRepository\n->setParameter('status', Statuses::PUBLISHED);\n}\n- $max = $contentType['listing_records'] ?: 6;\n+ return $this->createPaginator($qb->getQuery(), $page, $amountPerPage);\n+ }\n+\n+ public function findForTaxonomy(int $page, string $taxonomyslug, string $slug, int $amountPerPage, bool $onlyPublished = true): Pagerfanta\n+ {\n+ $qb = $this->getQueryBuilder()\n+ ->addSelect('a')\n+ ->innerJoin('content.author', 'a');\n- return $this->createPaginator($qb->getQuery(), $page, $max);\n+ $qb->addSelect('t')\n+ ->innerJoin('content.taxonomies', 't')\n+ ->andWhere('t.type = :taxonomyslug')\n+ ->setParameter('taxonomyslug', $taxonomyslug)\n+ ->andWhere('t.slug = :slug')\n+ ->setParameter('slug', $slug);\n+\n+ if ($onlyPublished) {\n+ $qb->andWhere('content.status = :status')\n+ ->setParameter('status', Statuses::PUBLISHED);\n+ }\n+\n+ return $this->createPaginator($qb->getQuery(), $page, $amountPerPage);\n}\npublic function findLatest(?ContentType $contentType = null, int $amount = 6): ?array\n@@ -69,7 +88,7 @@ class ContentRepository extends ServiceEntityRepository\nreturn $qb->getQuery()->getResult();\n}\n- public function searchNaive(string $search, int $page, int $amountPerPage, bool $onlyPublished = true): Pagerfanta\n+ public function searchNaive(string $searchTerm, int $page, int $amountPerPage, bool $onlyPublished = true): Pagerfanta\n{\n// First, create a querybuilder to get the fields that match the Query\n$qb = $this->getQueryBuilder()\n@@ -78,7 +97,7 @@ class ContentRepository extends ServiceEntityRepository\n$qb->addSelect('f')\n->leftJoin('content.fields', 'f')\n->andWhere($qb->expr()->like('f.value', ':search'))\n- ->setParameter('search', '%' . $search . '%');\n+ ->setParameter('search', '%' . $searchTerm . '%');\n// These are the ID's of content we need.\n$ids = array_column($qb->getQuery()->getArrayResult(), 'id');\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Rename 'search' to 'searchTerm'
|
95,144 |
29.03.2019 10:03:24
| -3,600 |
bb1d790128528cd0c59b00f6fc856ec8d05d65bc
|
Tweak makefile: these symlinks are in git, so unneeded here
|
[
{
"change_type": "MODIFY",
"old_path": "Makefile",
"new_path": "Makefile",
"diff": "@@ -71,15 +71,6 @@ e2e-wip:\ne2e-install:\ncd tests/e2e && npm install\nnode ./tests/e2e/node_modules/protractor/bin/webdriver-manager update --gecko=false\n- cd tests/e2e/step_definitions\n- ln -s ../node_modules/kakunin/dist/step_definitions/elements.js kakunin-elements.js\n- ln -s ../node_modules/kakunin/dist/step_definitions/debug.js kakunin-debug.js\n- ln -s ../node_modules/kakunin/dist/step_definitions/file.js kakunin-file.js\n- ln -s ../node_modules/kakunin/dist/step_definitions/form.js kakunin-form.js\n- ln -s ../node_modules/kakunin/dist/step_definitions/email.js kakunin-email.js\n- ln -s ../node_modules/kakunin/dist/step_definitions/generators.js kakunin-generators.js\n- ln -s ../node_modules/kakunin/dist/step_definitions/navigation.js kakunin-navigation.js\n- cd ../../..\ndb-create:\nbin/console doctrine:database:create\n"
},
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/search.twig",
"new_path": "public/theme/skeleton/search.twig",
"diff": "{{ block.content }}\n{% endif %}\n- <form method=\"get\" action=\"{{ path('search') }}\" id=\"searchform-inline\" enctype=\"text/plain\">\n+ <form method=\"get\" action=\"{{ path('search') }}\" id=\"searchform-main\" enctype=\"text/plain\">\n<input type=\"search\" value=\"{{ searchTerm|default() }}\" placeholder=\"{{ __('general.phrase.search-ellipsis') }}\" name=\"searchTerm\" >\n<button type=\"submit\">{{ __('general.phrase.search') }}</button>\n</form>\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Tweak makefile: these symlinks are in git, so unneeded here
|
95,144 |
29.03.2019 16:08:59
| -3,600 |
34f01c8f877d2494142ece7cf1ff31562e72aba5
|
Ensure that we get unique random taxonomies for fixtures
|
[
{
"change_type": "MODIFY",
"old_path": "src/DataFixtures/BaseFixture.php",
"new_path": "src/DataFixtures/BaseFixture.php",
"diff": "@@ -30,7 +30,7 @@ abstract class BaseFixture extends Fixture\nreturn $this->getReference($this->referencesIndex[$entityName][$randomReferenceKey]);\n}\n- protected function getRandomTaxonomy(string $type)\n+ protected function getRandomTaxonomies(string $type, int $amount): array\n{\nif (empty($this->taxonomyIndex)) {\nforeach (array_keys($this->referenceRepository->getReferences()) as $key) {\n@@ -42,11 +42,15 @@ abstract class BaseFixture extends Fixture\n}\nif (empty($this->taxonomyIndex[$type])) {\n- return null;\n+ return [];\n}\n- $randomReferenceKey = array_rand($this->taxonomyIndex[$type], 1);\n+ $taxonomies = [];\n- return $this->getReference($this->taxonomyIndex[$type][$randomReferenceKey]);\n+ foreach ((array) array_rand($this->taxonomyIndex[$type], $amount) as $key) {\n+ $taxonomies[] = $this->getReference($this->taxonomyIndex[$type][$key]);\n+ }\n+\n+ return $taxonomies;\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/DataFixtures/ContentFixtures.php",
"new_path": "src/DataFixtures/ContentFixtures.php",
"diff": "@@ -113,14 +113,10 @@ class ContentFixtures extends BaseFixture implements DependentFixtureInterface\n$taxonomyAmount = 1;\n}\n- for ($j = 1; $j <= $taxonomyAmount; $j++) {\n- $taxonomy = $this->getRandomTaxonomy($taxonomySlug);\n-\n- if ($taxonomy) {\n+ foreach ($this->getRandomTaxonomies($taxonomySlug, $taxonomyAmount) as $taxonomy) {\n$content->addTaxonomy($taxonomy);\n}\n}\n- }\n$manager->persist($content);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/DataFixtures/TaxonomyFixtures.php",
"new_path": "src/DataFixtures/TaxonomyFixtures.php",
"diff": "@@ -51,7 +51,7 @@ class TaxonomyFixtures extends BaseFixture\n}\n}\n- private function getDefaultOptions()\n+ private function getDefaultOptions(): array\n{\n$options = ['action', 'adult', 'adventure', 'alpha', 'animals', 'animation', 'anime', 'architecture', 'art',\n'astronomy', 'baby', 'batshitinsane', 'biography', 'biology', 'book', 'books', 'business',\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Ensure that we get unique random taxonomies for fixtures
|
95,144 |
29.03.2019 15:08:34
| -3,600 |
7d847e1eb3ea73e91f1fe6bf26f6576eddf12626
|
Clean-up of some Twig functions and filters.
|
[
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/partials/_aside.twig",
"new_path": "public/theme/skeleton/partials/_aside.twig",
"diff": "{# This part is only shown if there are no widgets in the 'aside_top' widgets slot. #}\n<div>\n{# The next section attempts to fill the panel in the sidebar with the contents of the\n- 'about-us'-block, if it exists. First, attempt to fetch the block with slug 'about-us' #}\n- {% setcontent block = \"block/about-us\" %}\n+ 'about'-block, if it exists. First, attempt to fetch the block by its slug #}\n+ {% setcontent block = \"blocks/about\" %}\n{# check if we have a title. If so, we know we have content to display. Otherwise, we will\noutput a default text, telling the user to create the 'blocks' in the backend. #}\n"
},
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/partials/_footer.twig",
"new_path": "public/theme/skeleton/partials/_footer.twig",
"diff": "<hr>\n<p>\n- {{ __(\"This website is <a href='%url%' target='_blank' title='Sophisticated, lightweight & simple CMS'>Built with Bolt</a>.\",{'%url%':'http://bolt.cm'}) }}\n+ {{ __('general.phrase.built-with-bolt') }}\n</p>\n{{ widgets('footer') }}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/DataFixtures/ContentFixtures.php",
"new_path": "src/DataFixtures/ContentFixtures.php",
"diff": "@@ -168,10 +168,12 @@ class ContentFixtures extends BaseFixture implements DependentFixtureInterface\n'slug' => 'This is a record in the \"Entries\" ContentType',\n];\n$records['blocks'][] = [\n- 'title' => 'About',\n+ 'title' => 'About This Site',\n+ 'slug' => 'about',\n];\n$records['blocks'][] = [\n'title' => 'Search',\n+ 'slug' => 'Search',\n];\n$records['tests'][] = [\n"
},
{
"change_type": "DELETE",
"old_path": "src/Twig/AdminExtension.php",
"new_path": null,
"diff": "-<?php\n-\n-declare(strict_types=1);\n-\n-namespace Bolt\\Twig;\n-\n-use Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface;\n-use Twig\\Extension\\AbstractExtension;\n-use Twig\\TwigFilter;\n-\n-class AdminExtension extends AbstractExtension\n-{\n- /** @var UrlGeneratorInterface */\n- private $urlGenerator;\n-\n- /**\n- * Constructor.\n- */\n- public function __construct(UrlGeneratorInterface $urlGenerator)\n- {\n- $this->urlGenerator = $urlGenerator;\n- }\n-\n- /**\n- * {@inheritdoc}\n- */\n- public function getFunctions()\n- {\n- return [\n- ];\n- }\n-\n- /**\n- * {@inheritdoc}\n- */\n- public function getFilters()\n- {\n- $safe = ['is_safe' => ['html']];\n-\n- return [\n- new TwigFilter('ymllink', [$this, 'ymllink'], $safe),\n- ];\n- }\n-\n- /**\n- * Create a link to edit a .yml file, if a filename is detected in the string. Mostly\n- * for use in Flashbag messages, to allow easy editing.\n- *\n- * @param string $str\n- *\n- * @return string Resulting string\n- */\n- public function ymllink($str): string\n- {\n- return preg_replace_callback(\n- '/([a-z0-9_-]+\\.yml)/i',\n- function ($matches) {\n- $path = $this->urlGenerator->generate('bolt_file_edit', [\n- 'area' => 'config',\n- 'file' => '/' . $matches[1],\n- ]);\n- return sprintf(' <a href=\"%s\">%s</a>', $path, $matches[1]);\n- },\n- $str\n- );\n- }\n-}\n"
},
{
"change_type": "DELETE",
"old_path": "src/Twig/AppExtension.php",
"new_path": null,
"diff": "-<?php\n-\n-declare(strict_types=1);\n-\n-namespace Bolt\\Twig;\n-\n-use Twig\\Extension\\AbstractExtension;\n-use Twig\\TwigFilter;\n-use Twig\\TwigFunction;\n-\n-class AppExtension extends AbstractExtension\n-{\n- public function __construct()\n- {\n- }\n-\n- /**\n- * {@inheritdoc}\n- */\n- public function getFilters(): array\n- {\n- $safe = ['is_safe' => ['html']];\n-\n- return [\n- new TwigFilter('order', [$this, 'dummy']),\n- new TwigFilter('unique', [$this, 'unique']),\n- new TwigFilter('localedatetime', [$this, 'localedatetime'], $safe),\n- new TwigFilter('showimage', [$this, 'dummy']),\n- new TwigFilter('ucwords', [$this, 'ucwords']),\n- ];\n- }\n-\n- /**\n- * {@inheritdoc}\n- */\n- public function getFunctions(): array\n- {\n- $safe = ['is_safe' => ['html']];\n-\n- return [\n- new TwigFunction('widgets', [$this, 'dummy'], $safe),\n- ];\n- }\n-\n- public function dummy($input = null)\n- {\n- return $input;\n- }\n-\n- public function ucwords($content, string $delimiters = ''): string\n- {\n- if (! $content) {\n- return '';\n- }\n-\n- return ucwords($content, $delimiters);\n- }\n-\n- public function unique($array): array\n- {\n- return array_unique($array);\n- }\n-\n- public function localedatetime($dateTime, $format = '%B %e, %Y %H:%M', $locale = 0)\n- {\n- if (! $dateTime instanceof \\DateTime) {\n- $dateTime = new \\DateTime($dateTime);\n- }\n-\n- // Check for Windows to find and replace the %e modifier correctly\n- // @see: http://php.net/strftime\n- $os = mb_strtoupper(mb_substr(PHP_OS, 0, 3));\n- $format = $os !== 'WIN' ? $format : preg_replace('#(?<!%)((?:%%)*)%e#', '\\1%#d', $format);\n-\n- // According to http://php.net/manual/en/function.setlocale.php manual\n- // if the second parameter is \"0\", the locale setting is not affected,\n- // only the current setting is returned.\n- $result = setlocale(LC_ALL, $locale);\n-\n- if ($result === false) {\n- // This shouldn't occur, but.. Dude!\n- // You ain't even got locale or English on your platform??\n- // Various things we could do. We could fail miserably, but a more\n- // graceful approach is to use the datetime to display a default\n- // format\n- // $this->systemLogger->error('No valid locale detected. Fallback on DateTime active.', ['event' => 'system']);\n-\n- return $dateTime->format('Y-m-d H:i:s');\n- }\n- $timestamp = $dateTime->getTimestamp();\n-\n- return strftime($format, $timestamp);\n- }\n-}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Twig/ArrayExtension.php",
"new_path": "src/Twig/ArrayExtension.php",
"diff": "@@ -39,11 +39,6 @@ final class ArrayExtension extends AbstractExtension\n];\n}\n- public function dummy($input = null)\n- {\n- return $input;\n- }\n-\n/**\n* Takes two arrays and returns a compiled array of unique, sorted values.\n*/\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Twig/ContentExtension.php",
"new_path": "src/Twig/ContentExtension.php",
"diff": "@@ -5,6 +5,7 @@ declare(strict_types=1);\nnamespace Bolt\\Twig;\nuse Bolt\\Entity\\Content;\n+use Bolt\\Entity\\Field;\nuse Bolt\\Entity\\Field\\Excerptable;\nuse Bolt\\Entity\\Field\\ImageField;\nuse Bolt\\Repository\\ContentRepository;\n@@ -50,6 +51,7 @@ class ContentExtension extends AbstractExtension\nnew TwigFilter('link', [$this, 'getLink'], $safe),\nnew TwigFilter('edit_link', [$this, 'getEditLink'], $safe),\nnew TwigFilter('taxonomies', [$this, 'getTaxonomies']),\n+ new TwigFilter('field_factory', [$this, 'getFieldFactory']),\n];\n}\n@@ -231,4 +233,13 @@ class ContentExtension extends AbstractExtension\nreturn new Collection($taxonomies);\n}\n+\n+ public function getFieldFactory(Content $content, string $name, ?Collection $definition = null): Field\n+ {\n+ if ($definition === null || $definition->isEmpty()) {\n+ $definition = new Collection(['type' => 'generic']);\n+ }\n+\n+ return Field::factory($definition, $name);\n+ }\n}\n"
},
{
"change_type": "DELETE",
"old_path": "src/Twig/FieldExtension.php",
"new_path": null,
"diff": "-<?php\n-\n-declare(strict_types=1);\n-\n-namespace Bolt\\Twig;\n-\n-use Bolt\\Entity\\Field;\n-use Tightenco\\Collect\\Support\\Collection;\n-use Twig\\Extension\\AbstractExtension;\n-use Twig\\TwigFunction;\n-\n-class FieldExtension extends AbstractExtension\n-{\n- public function getFunctions(): array\n- {\n- return [\n- new TwigFunction('field_factory', [$this, 'fieldFactory']),\n- ];\n- }\n-\n- public function fieldFactory(string $name, ?Collection $definition = null): Field\n- {\n- if ($definition === null || $definition->isEmpty()) {\n- $definition = new Collection(['type' => 'generic']);\n- }\n-\n- return Field::factory($definition, $name);\n- }\n-}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Twig/LocaleExtension.php",
"new_path": "src/Twig/LocaleExtension.php",
"diff": "@@ -10,6 +10,7 @@ use Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface;\nuse Symfony\\Contracts\\Translation\\TranslatorInterface;\nuse Tightenco\\Collect\\Support\\Collection;\nuse Twig\\Extension\\AbstractExtension;\n+use Twig\\TwigFilter;\nuse Twig\\TwigFunction;\nuse Twig_Environment;\n@@ -34,6 +35,18 @@ class LocaleExtension extends AbstractExtension\n$this->translator = $translator;\n}\n+ /**\n+ * {@inheritdoc}\n+ */\n+ public function getFilters(): array\n+ {\n+ $safe = ['is_safe' => ['html']];\n+\n+ return [\n+ new TwigFilter('localedatetime', [$this, 'localedatetime'], $safe),\n+ ];\n+ }\n+\n/**\n* {@inheritdoc}\n*/\n@@ -426,4 +439,35 @@ class LocaleExtension extends AbstractExtension\n'ZW' => 'Zimbabwe',\n]);\n}\n+\n+ public function localedatetime($dateTime, $format = '%B %e, %Y %H:%M', $locale = 0)\n+ {\n+ if (! $dateTime instanceof \\DateTime) {\n+ $dateTime = new \\DateTime($dateTime);\n+ }\n+\n+ // Check for Windows to find and replace the %e modifier correctly\n+ // @see: http://php.net/strftime\n+ $os = mb_strtoupper(mb_substr(PHP_OS, 0, 3));\n+ $format = $os !== 'WIN' ? $format : preg_replace('#(?<!%)((?:%%)*)%e#', '\\1%#d', $format);\n+\n+ // According to http://php.net/manual/en/function.setlocale.php manual\n+ // if the second parameter is \"0\", the locale setting is not affected,\n+ // only the current setting is returned.\n+ $result = setlocale(LC_ALL, $locale);\n+\n+ if ($result === false) {\n+ // This shouldn't occur, but.. Dude!\n+ // You ain't even got locale or English on your platform??\n+ // Various things we could do. We could fail miserably, but a more\n+ // graceful approach is to use the datetime to display a default\n+ // format\n+ // $this->systemLogger->error('No valid locale detected. Fallback on DateTime active.', ['event' => 'system']);\n+\n+ return $dateTime->format('Y-m-d H:i:s');\n+ }\n+ $timestamp = $dateTime->getTimestamp();\n+\n+ return strftime($format, $timestamp);\n+ }\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Twig/RecordExtension.php",
"new_path": "src/Twig/RecordExtension.php",
"diff": "@@ -53,7 +53,7 @@ class RecordExtension extends AbstractExtension\nreturn [\nnew TwigFunction('excerpt', [$this, 'excerpt'], $safe),\n- new TwigFunction('listtemplates', [$this, 'dummy']),\n+ new TwigFunction('listtemplates', [$this, 'listtemplates']),\nnew TwigFunction('pager', [$this, 'pager'], $env + $safe),\nnew TwigFunction('menu', [$this, 'menu'], $env + $safe),\nnew TwigFunction('sidebarmenu', [$this, 'sidebarmenu']),\n@@ -65,14 +65,9 @@ class RecordExtension extends AbstractExtension\n];\n}\n- public function dummy($input = null)\n+ public function listtemplates()\n{\n- return $input;\n- }\n-\n- public function dummy_with_env(Environment $env, $input = null)\n- {\n- return $input;\n+ return 'listtemplates placeholder';\n}\npublic function pager(Environment $env, Pagerfanta $records, string $template = '_sub_pager.twig', string $class = 'pagination', string $theme = 'default', int $surround = 3)\n"
},
{
"change_type": "DELETE",
"old_path": "src/Twig/RoutingExtension.php",
"new_path": null,
"diff": "-<?php\n-\n-declare(strict_types=1);\n-\n-namespace Bolt\\Twig;\n-\n-use Twig\\Extension\\AbstractExtension;\n-use Twig\\TwigFunction;\n-\n-/**\n- * Routing functionality Twig extension.\n- */\n-class RoutingExtension extends AbstractExtension\n-{\n- /**\n- * {@inheritdoc}\n- */\n- public function getFunctions()\n- {\n- return [\n- new TwigFunction('canonical', [$this, 'dummy']),\n- new TwigFunction('htmllang', [$this, 'dummy']),\n- ];\n- }\n-\n- public function dummy($input = null)\n- {\n- return $input;\n- }\n-}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Twig/TextExtension.php",
"new_path": "src/Twig/TextExtension.php",
"diff": "@@ -19,9 +19,9 @@ class TextExtension extends AbstractExtension\npublic function getFilters()\n{\nreturn [\n- new TwigFilter('json_decode', [$this, 'dummy']),\nnew TwigFilter('safestring', [$this, 'safeString']),\nnew TwigFilter('slug', [$this, 'slug']),\n+ new TwigFilter('ucwords', [$this, 'ucwords']),\n];\n}\n@@ -35,8 +35,12 @@ class TextExtension extends AbstractExtension\nreturn Str::slug((string) $str);\n}\n- public function dummy($input = null)\n+ public function ucwords($content, string $delimiters = ''): string\n{\n- return $input;\n+ if (! $content) {\n+ return '';\n+ }\n+\n+ return ucwords($content, $delimiters);\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/_base/layout.html.twig",
"new_path": "templates/_base/layout.html.twig",
"diff": "site-name=\"{% if config is defined %}{{ config.get('general/sitename') }}{% endif %}\"\n:menu=\"{{ sidebarmenu() }}\"\nuser=\"{{ user|default }}\"\n- :labels=\"{{ labels|json_decode }}\"\n+ :labels=\"{{ labels }}\"\n></admin-toolbar>\n</nav>\n<!-- End Admin Toolbar -->\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/content/_fields.html.twig",
"new_path": "templates/content/_fields.html.twig",
"diff": "{% for group in groups if group != 'Relations' %}\n+\n<div class=\"tab-pane {% if loop.first %}show active{% endif %}\" id=\"{{ group|slug }}\" role=\"tabpanel\"\naria-labelledby=\"{{ group|slug }}-tab\">\n{% for key, fielddefinition in record.definition.fields if fielddefinition.group == group %}\n{% if record.hasField(key) %}\n{% set field = record.getField(key)|translated(currentlocale) %}\n{% else %}\n- {% set field = field_factory(key, fielddefinition) %}\n+ {% set field = record|field_factory(key, fielddefinition) %}\n{% endif %}\n{% include [\n"
},
{
"change_type": "MODIFY",
"old_path": "translations/messages.en.xlf",
"new_path": "translations/messages.en.xlf",
"diff": "<target>Search</target>\n</segment>\n</unit>\n- <unit id=\"z0k8hRg\" name=\"9fb3e6e\">\n- <segment>\n- <source>9fb3e6e</source>\n- <target><![CDATA[This website is <a href='%url%' target='_blank' title='Sophisticated, lightweight & simple CMS'>Built with Bolt</a>.]]></target>\n- </segment>\n- </unit>\n<unit id=\"wNEwZy_\" name=\"contenttypes.generic.overview\">\n<segment>\n<source>contenttypes.generic.overview</source>\n<target>The Kitchensink</target>\n</segment>\n</unit>\n- <unit id=\"eq5YMQf\" name=\"9fb3e6e\">\n- <segment>\n- <source>This website is <a href='%url%' target='_blank' title='Sophisticated, lightweight & simple CMS'>Built with Bolt</a>.</source>\n- <target><![CDATA[This website is <a href='%url%' target='_blank' title='Sophisticated, lightweight & simple CMS'>Built with Bolt</a>.]]></target>\n- </segment>\n- </unit>\n<unit id=\"2CfJ3WY\" name=\"general.phrase.search-results-for\">\n<segment>\n<source>general.phrase.search-results-for</source>\n<segment>\n<source>general.phrase.no-search-term-provided</source>\n<target>Please provide a search term, in order to display relevant results.</target>\n+ <unit id=\"Pily_qo\" name=\"general.phrase.read-more\">\n+ <segment>\n+ <source>general.phrase.read-more</source>\n+ <target>Read More</target>\n+ </segment>\n+ </unit>\n+ <unit id=\"psOa_9x\" name=\"general.phrase.built-with-bolt\">\n+ <segment>\n+ <source>general.phrase.built-with-bolt</source>\n+ <target><![CDATA[This website is <a href='https://bolt.cm' target='_blank' title='Sophisticated, lightweight & simple CMS'>Built with Bolt</a>.]]></target>\n</segment>\n</unit>\n</file>\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Clean-up of some Twig functions and filters.
|
95,144 |
29.03.2019 18:00:10
| -3,600 |
5b184cfef3fa69ea2ce84be7495f68d2772fe9cf
|
Eliminate blank spaces in "New" menu
|
[
{
"change_type": "DELETE",
"old_path": "assets/js/app/login/Components/Admin/Toolbar.vue",
"new_path": null,
"diff": "-<template>\n- <div\n- class=\"admin__toolbar--body\"\n- :class=\"contrast ? 'is-light' : 'is-dark'\"\n- role=\"toolbar\"\n- >\n- <div class=\"toolbar--item is-brand\">\n- <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 91 79\">\n- <g fill-rule=\"evenodd\">\n- <path\n- d=\"M22.4439 78.14003L0 38.98236 22.75 0l45.19015.17305L90.3848 39.33448 67.63857 78.32135l-45.18714-.17305-.00752-.00827zm4.97036-7.58863l.00588.00667 35.31413.13936 17.77638-31.39679L62.96997 7.76328l-35.31649-.13935L9.87415 39.01708 27.41426 70.5514z\"\n- />\n- <path\n- fill-rule=\"nonzero\"\n- d=\"M31.58678 31.6h7.52066v15.04762h-7.52066z\"\n- />\n- <path\n- fill-rule=\"nonzero\"\n- d=\"M37.5657 35.3619h22.56198v7.52381H37.5657z\"\n- />\n- </g>\n- </svg>\n- <ul class=\"toolbar--menu\">\n- <li><a href=\"https://bolt.cm/\" target=\"_blank\">bolt.cm</a></li>\n- <li>\n- <a href=\"https://docs.bolt.cm/\" target=\"_blank\">{{\n- labels['about.bolt_documentation']\n- }}</a>\n- </li>\n- </ul>\n- </div>\n- <div class=\"toolbar--item is-new\">\n- <i class=\"fas fa-magic mr-2\"></i>{{ labels['action.create_new'] }}\n- <ul class=\"toolbar--menu\">\n- <li v-for=\"(item, index) in createMenu\" :key=\"index\">\n- <a :href=\"item.link_new\">{{ item.singular_name }}</a>\n- </li>\n- </ul>\n- </div>\n- <div class=\"toolbar--item is-site\">\n- <i class=\"fas fa-globe-americas mr-2\"></i>{{ siteName }}\n- <ul class=\"toolbar--menu\">\n- <li>\n- <a href=\"/\" target=\"_blank\">{{ labels['action.visit_site'] }}</a>\n- </li>\n- </ul>\n- </div>\n- <div class=\"toolbar--item is-profile\">\n- <i class=\"fas fa-user mr-2\"></i>{{ labels['general.greeting'] }}\n- <ul class=\"toolbar--menu\">\n- <li>\n- <a href=\"/bolt/profile-edit\">{{ labels['action.edit_profile'] }}</a>\n- </li>\n- <li>\n- <a href=\"/bolt/logout\">{{ labels['action.logout'] }}</a>\n- </li>\n- </ul>\n- </div>\n- </div>\n-</template>\n-\n-<script>\n-const tinycolor = require('tinycolor2');\n-\n-export default {\n- name: 'AdminToolbar',\n- props: ['siteName', 'menu', 'labels'],\n- data: () => ({\n- label: {},\n- }),\n- computed: {\n- contrast() {\n- const color = getComputedStyle(document.body).getPropertyValue(\n- '--admin-toolbar',\n- );\n- const test = tinycolor(color);\n- return test.isLight();\n- },\n- createMenu() {\n- return this.menu.filter(item => {\n- return (\n- (item.contentType !== null && !item.singleton) ||\n- (item.singleton && (item.submenu === null || item.submenu.length < 1))\n- );\n- });\n- },\n- },\n-};\n-</script>\n"
},
{
"change_type": "MODIFY",
"old_path": "assets/js/app/toolbar/Components/Toolbar.vue",
"new_path": "assets/js/app/toolbar/Components/Toolbar.vue",
"diff": "</g>\n</svg>\n<ul class=\"toolbar--menu\">\n- <li><a href=\"https://bolt.cm/\" target=\"_blank\">bolt.cm</a></li>\n+ <li><a href=\"https://bolt.cm/\" target=\"_blank\">Visit Bolt.cm</a></li>\n<li>\n<a href=\"https://docs.bolt.cm/\" target=\"_blank\">{{\nlabels['about.bolt_documentation']\n</ul>\n</div>\n<div class=\"toolbar--item is-site\">\n- <i class=\"fas fa-globe-americas mr-2\"></i>{{ siteName }}\n- <ul class=\"toolbar--menu\">\n- <li>\n- <a href=\"/\" target=\"_blank\">{{ labels['action.visit_site'] }}</a>\n- </li>\n- </ul>\n+ <a href=\"/\" target=\"_blank\">\n+ <i class=\"fas fa-globe-americas mr-2\"></i>{{ labels['action.visit_site'] }}: {{ siteName }}\n+ </a>\n</div>\n<div class=\"toolbar--item is-profile\">\n<i class=\"fas fa-user mr-2\"></i>{{ labels['general.greeting'] }}\n@@ -73,7 +70,7 @@ export default {\ncreateMenu() {\nreturn this.menu.filter(item => {\nreturn (\n- (item.contentType !== null && !item.singleton) ||\n+ (item.contentType !== null && !item.singleton && item.singular_name) ||\n(item.singleton && (item.submenu === null || item.submenu.length < 1))\n);\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "assets/scss/modules/admin/_toolbar.scss",
"new_path": "assets/scss/modules/admin/_toolbar.scss",
"diff": "}\n}\n- &.is-site,\n+ &.is-new,\n&.is-profile {\n.toolbar--menu {\nleft: auto;\n}\n}\n- &.is-site {\n+ &.is-new {\nmargin-left: auto;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "},\n\"dependencies\": {\n\"@babel/polyfill\": \"^7.4.0\",\n- \"@vue/cli-service\": \"^3.5.1\",\n+ \"@vue/cli-service\": \"^3.5.3\",\n\"axios\": \"^0.18.0\",\n\"baguettebox.js\": \"^1.11.0\",\n\"bootstrap\": \"^4.3.1\",\n\"jquery\": \"^3.3.1\",\n\"moment\": \"^2.24.0\",\n\"no-scroll\": \"^2.1.1\",\n- \"npm-check-updates\": \"^3.1.1\",\n\"popper.js\": \"^1.14.7\",\n\"register-service-worker\": \"^1.6.2\",\n\"simplemde\": \"^1.11.2\",\n\"@babel/plugin-transform-runtime\": \"^7.4.0\",\n\"@babel/polyfill\": \"^7.4.0\",\n\"@babel/preset-env\": \"^7.4.2\",\n- \"@symfony/webpack-encore\": \"^0.24.0\",\n+ \"@symfony/webpack-encore\": \"^0.26.0\",\n\"@vue/test-utils\": \"^1.0.0-beta.29\",\n\"ajv-keywords\": \"^3.4.0\",\n\"autoprefixer\": \"^9.5.0\",\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Eliminate blank spaces in "New" menu
|
95,144 |
29.03.2019 19:58:24
| -3,600 |
8b36eb9b7a9564f713cb122eca69db7532a08eb7
|
Replace `jsonlabels` with an array in Twig
|
[
{
"change_type": "MODIFY",
"old_path": "src/Twig/RecordExtension.php",
"new_path": "src/Twig/RecordExtension.php",
"diff": "@@ -11,7 +11,6 @@ use Bolt\\Repository\\TaxonomyRepository;\nuse Bolt\\Utils\\Excerpt;\nuse Doctrine\\Common\\Collections\\Collection;\nuse Pagerfanta\\Pagerfanta;\n-use Symfony\\Contracts\\Translation\\TranslatorInterface;\nuse Tightenco\\Collect\\Support\\Collection as LaravelCollection;\nuse Twig\\Environment;\nuse Twig\\Extension\\AbstractExtension;\n@@ -27,19 +26,15 @@ class RecordExtension extends AbstractExtension\n/** @var MenuBuilder */\nprivate $menuBuilder;\n- /** @var TranslatorInterface */\n- private $translator;\n-\n/** @var string */\nprivate $menu = null;\n/** @var TaxonomyRepository */\nprivate $taxonomyRepository;\n- public function __construct(MenuBuilder $menuBuilder, TranslatorInterface $translator, TaxonomyRepository $taxonomyRepository)\n+ public function __construct(MenuBuilder $menuBuilder, TaxonomyRepository $taxonomyRepository)\n{\n$this->menuBuilder = $menuBuilder;\n- $this->translator = $translator;\n$this->taxonomyRepository = $taxonomyRepository;\n}\n@@ -57,7 +52,6 @@ class RecordExtension extends AbstractExtension\nnew TwigFunction('pager', [$this, 'pager'], $env + $safe),\nnew TwigFunction('menu', [$this, 'getMenu'], $env + $safe),\nnew TwigFunction('sidebar_menu', [$this, 'getSidebarMenu']),\n- new TwigFunction('jsonlabels', [$this, 'jsonlabels']),\nnew TwigFunction('selectoptionsfromarray', [$this, 'selectoptionsfromarray']),\nnew TwigFunction('taxonomyoptions', [$this, 'taxonomyoptions']),\nnew TwigFunction('taxonomyvalues', [$this, 'taxonomyvalues']),\n@@ -115,19 +109,6 @@ class RecordExtension extends AbstractExtension\nreturn \"<i class='fas mr-2 fa-${icon}'></i>\";\n}\n- public function jsonlabels(array $labels, bool $pretty = false): string\n- {\n- $result = [];\n- $options = $pretty ? JSON_PRETTY_PRINT : 0;\n-\n- foreach ($labels as $label) {\n- $key = is_array($label) ? $label[0] : $label;\n- $result[$key] = $this->translator->trans(...(array) $label);\n- }\n-\n- return json_encode($result, $options);\n- }\n-\npublic function selectoptionsfromarray(Field $field): LaravelCollection\n{\n$values = $field->getDefinition()->get('values');\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/_base/layout.html.twig",
"new_path": "templates/_base/layout.html.twig",
"diff": "<!-- Admin Toolbar -->\n<nav id=\"toolbar\" class=\"admin__toolbar\">\n{% set user_display_name = user.displayName|default('Unknown user') %}\n- {% set labels = jsonlabels(['about.bolt_documentation', 'action.visit_site', 'action.create_new', ['general.greeting', {'%name%': user_display_name}], 'action.logout', 'action.edit_profile']) %}\n+\n+ {# Setting the labels and their localisations that are used in the sidebar-menu. #}\n+ {% set labels = {\n+ 'about.bolt_documentation': 'about.bolt_documentation'|trans,\n+ 'action.visit_site': 'action.visit_site'|trans,\n+ 'action.create_new': 'action.create_new'|trans,\n+ 'general.greeting': 'general.greeting'|trans({'%name%': user_display_name}),\n+ 'action.logout': 'action.logout'|trans,\n+ 'action.edit_profile': 'action.edit_profile'|trans\n+ }|json_encode %}\n+\n<admin-toolbar\nsite-name=\"{% if config is defined %}{{ config.get('general/sitename') }}{% endif %}\"\n:menu=\"{{ sidebar_menu() }}\"\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/_partials/_flash_messages.html.twig",
"new_path": "templates/_partials/_flash_messages.html.twig",
"diff": "-{% set labels = jsonlabels(['action.close_alert']) %}\n+{% set labels = {'action.close_alert': 'action.close_alert'|trans } %}\n+\n{% for type, messages in app.flashes %}\n{% for message in messages %}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Replace `jsonlabels` with an array in Twig
|
95,144 |
31.03.2019 18:39:36
| -7,200 |
97b5a759689e76019aa49053b66e193971a3f229
|
Fix ECS deprecation notices
|
[
{
"change_type": "MODIFY",
"old_path": "easy-coding-standard.yml",
"new_path": "easy-coding-standard.yml",
"diff": "@@ -93,16 +93,16 @@ services:\nparameters:\ncache_directory: var/cache/ecs\n- exclude_checkers:\n- - 'PhpCsFixer\\Fixer\\ClassNotation\\ClassAttributesSeparationFixer'\n- - 'PhpCsFixer\\Fixer\\ClassNotation\\OrderedClassElementsFixer'\n- - 'PhpCsFixer\\Fixer\\ControlStructure\\YodaStyleFixer'\n- - 'PhpCsFixer\\Fixer\\Operator\\ConcatSpaceFixer'\n- - 'PhpCsFixer\\Fixer\\Operator\\IncrementStyleFixer'\n- - 'PhpCsFixer\\Fixer\\Operator\\UnaryOperatorSpacesFixer'\n- - 'PhpCsFixer\\Fixer\\Phpdoc\\PhpdocAnnotationWithoutDotFixer'\n- - 'PhpCsFixer\\Fixer\\Phpdoc\\PhpdocSummaryFixer'\n- - 'PhpCsFixer\\Fixer\\Whitespace\\BlankLineBeforeStatementFixer'\n- - 'SlevomatCodingStandard\\Sniffs\\TypeHints\\TypeHintDeclarationSniff'\n- - 'Symplify\\CodingStandard\\Sniffs\\Debug\\CommentedOutCodeSniff' #to be removed before beta release\n- - 'Symplify\\CodingStandard\\Sniffs\\Debug\\DebugFunctionCallSniff' #to be removed before beta release\n+ skip:\n+ PhpCsFixer\\Fixer\\ClassNotation\\ClassAttributesSeparationFixer: ~\n+ PhpCsFixer\\Fixer\\ClassNotation\\OrderedClassElementsFixer: ~\n+ PhpCsFixer\\Fixer\\ControlStructure\\YodaStyleFixer: ~\n+ PhpCsFixer\\Fixer\\Operator\\ConcatSpaceFixer: ~\n+ PhpCsFixer\\Fixer\\Operator\\IncrementStyleFixer: ~\n+ PhpCsFixer\\Fixer\\Operator\\UnaryOperatorSpacesFixer: ~\n+ PhpCsFixer\\Fixer\\Phpdoc\\PhpdocAnnotationWithoutDotFixer: ~\n+ PhpCsFixer\\Fixer\\Phpdoc\\PhpdocSummaryFixer: ~\n+ PhpCsFixer\\Fixer\\Whitespace\\BlankLineBeforeStatementFixer: ~\n+ SlevomatCodingStandard\\Sniffs\\TypeHints\\TypeHintDeclarationSniff: ~\n+ Symplify\\CodingStandard\\Sniffs\\Debug\\CommentedOutCodeSniff: ~ #to be removed before beta release\n+ Symplify\\CodingStandard\\Sniffs\\Debug\\DebugFunctionCallSniff: ~ #to be removed before beta release\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Fix ECS deprecation notices
|
95,144 |
01.04.2019 16:52:04
| -7,200 |
1919b2f7dbd18259f5701a2ba0e842ab5e4bf520
|
Add 'bolt.backend_url' parameter
|
[
{
"change_type": "MODIFY",
"old_path": "config/packages/security.yaml",
"new_path": "config/packages/security.yaml",
"diff": "@@ -23,7 +23,7 @@ security:\nlogout:\npath: bolt_logout\n- target: homepage\n+ target: bolt_login\nremember_me:\nsecret: '%kernel.secret%'\n@@ -32,7 +32,6 @@ security:\naccess_control:\n# this is a catch-all for the admin area\n# additional security lives in the controllers\n- # @todo make admin area prefix configurable\n- - { path: '^/bolt/(login|resetpassword)$', roles: IS_AUTHENTICATED_ANONYMOUSLY }\n- - { path: '^/bolt', roles: ROLE_ADMIN }\n- - { path: '^/(%app_locales%)/bolt', roles: ROLE_ADMIN }\n+ - { path: '^%bolt.backend_url%/(login|resetpassword)$', roles: IS_AUTHENTICATED_ANONYMOUSLY }\n+ - { path: '^%bolt.backend_url%', roles: ROLE_ADMIN }\n+ - { path: '^/(%app_locales%)%bolt.backend_url%', roles: ROLE_ADMIN }\n"
},
{
"change_type": "MODIFY",
"old_path": "config/routes.yaml",
"new_path": "config/routes.yaml",
"diff": "@@ -19,7 +19,7 @@ frontend:\n# Place your own routes here, that have a LOWER priority than the default routes.\napi_entrypoint:\n- path: /bolt/api # moved to admin area firewall\n+ path: '%bolt.backend_url%/api'\ncontroller: api_platform.swagger.action.ui\n# ------------------------------------------------------------------------------\n@@ -27,11 +27,11 @@ api_entrypoint:\n# to modify the `prefix` so the Control Panel can be accessed at a custom URL.\ncontrol_panel_async:\nresource: '../src/Controller/Backend/Async'\n- prefix: /bolt/async # @todo make admin area prefix configurable\n+ prefix: '%bolt.backend_url%/async'\ncontrol_panel:\nresource: '../src/Controller/Backend/'\n- prefix: /bolt # @todo make admin area prefix configurable\n+ prefix: '%bolt.backend_url%'\n# ------------------------------------------------------------------------------\n# Examples:\n"
},
{
"change_type": "MODIFY",
"old_path": "config/services.yaml",
"new_path": "config/services.yaml",
"diff": "@@ -8,6 +8,7 @@ parameters:\ndoctrine.orm.entity_manager.class: Bolt\\Doctrine\\TranslatableEntityManager\nstof_doctrine_extensions.listener.translatable.class: Bolt\\EventListener\\PreTranslatableListener\nbolt.table_prefix: bolt_\n+ bolt.backend_url: /bolt\nservices:\n# default configuration for services in *this* file\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Add 'bolt.backend_url' parameter
|
95,144 |
01.04.2019 17:12:17
| -7,200 |
ae97ac2c603a686876d312e564969bef551253e3
|
Fix links in Vue component
|
[
{
"change_type": "MODIFY",
"old_path": "assets/js/app/toolbar/Components/Toolbar.vue",
"new_path": "assets/js/app/toolbar/Components/Toolbar.vue",
"diff": "<i class=\"fas fa-user mr-2\"></i>{{ labels['general.greeting'] }}\n<ul class=\"toolbar--menu\">\n<li>\n- <a href=\"/bolt/profile-edit\">{{ labels['action.edit_profile'] }}</a>\n+ <a :href=\"backend_prefix + 'profile-edit'\">{{ labels['action.edit_profile'] }}</a>\n</li>\n<li>\n- <a href=\"/bolt/logout\">{{ labels['action.logout'] }}</a>\n+ <a :href=\"backend_prefix + 'logout'\">{{ labels['action.logout'] }}</a>\n</li>\n</ul>\n</div>\n@@ -61,7 +61,7 @@ const tinycolor = require('tinycolor2');\nexport default {\nname: 'Toolbar',\n- props: ['siteName', 'menu', 'labels'],\n+ props: ['siteName', 'menu', 'labels', 'backend_prefix'],\ncomputed: {\ncontrast() {\nconst color = tinycolor(this.toolbarColor);\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/_base/layout.html.twig",
"new_path": "templates/_base/layout.html.twig",
"diff": ":menu=\"{{ sidebarmenu() }}\"\nuser=\"{{ user|default }}\"\n:labels=\"{{ labels|json_decode }}\"\n+ :backend_prefix=\"{{ path('bolt_dashboard') }}\"\n></admin-toolbar>\n</nav>\n<!-- End Admin Toolbar -->\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Fix links in Vue component
|
95,144 |
29.03.2019 17:25:17
| -3,600 |
4d73781987da697625b9de10b1258fa025b7e653
|
Refactor uses of `$env` to `$twig`
|
[
{
"change_type": "MODIFY",
"old_path": "src/Twig/RecordExtension.php",
"new_path": "src/Twig/RecordExtension.php",
"diff": "@@ -64,7 +64,7 @@ class RecordExtension extends AbstractExtension\nreturn 'list_templates placeholder';\n}\n- public function pager(Environment $env, Pagerfanta $records, string $template = '_sub_pager.twig', string $class = 'pagination', string $theme = 'default', int $surround = 3)\n+ public function pager(Environment $twig, Pagerfanta $records, string $template = '_sub_pager.twig', string $class = 'pagination', string $theme = 'default', int $surround = 3)\n{\n$context = [\n'records' => $records,\n@@ -73,10 +73,10 @@ class RecordExtension extends AbstractExtension\n'theme' => $theme,\n];\n- return $env->render($template, $context);\n+ return $twig->render($template, $context);\n}\n- public function getMenu(Environment $env, string $template = ''): string\n+ public function getMenu(Environment $twig, string $template = ''): string\n{\n// @todo See Github issue https://github.com/bolt/four/issues/253\nreturn '[menu placeholder]';\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Twig/WidgetExtension.php",
"new_path": "src/Twig/WidgetExtension.php",
"diff": "@@ -29,7 +29,7 @@ class WidgetExtension extends AbstractExtension\n];\n}\n- public function dummy(Environment $env, $input = null)\n+ public function dummy(Environment $twig, $input = null)\n{\n// @todo See Github issue https://github.com/bolt/four/issues/135\nreturn '<!-- Widget \"' . $input . '\" -->';\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Refactor uses of `$env` to `$twig`
|
95,144 |
30.03.2019 17:37:01
| -3,600 |
5f7dddac5d91820ecc83d0c8206b3fdede6e1813
|
Add $name option
|
[
{
"change_type": "MODIFY",
"old_path": "src/Twig/RecordExtension.php",
"new_path": "src/Twig/RecordExtension.php",
"diff": "@@ -81,7 +81,7 @@ class RecordExtension extends AbstractExtension\npublic function getMenu(Environment $twig, string $template = ''): string\n{\n$context = [\n- 'menu' => $this->frontendMenuBuilder->getMenu(),\n+ 'menu' => $this->frontendMenuBuilder->getMenu($name),\n'class' => $class,\n'bool' => $withsubmenus,\n];\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Add $name option
|
95,144 |
31.03.2019 18:25:08
| -7,200 |
95f92d1875a5bd9ac51fa08acdef45b4a4cbc7ab
|
Mark properties private
|
[
{
"change_type": "MODIFY",
"old_path": "src/Menu/FrontendMenuBuilder.php",
"new_path": "src/Menu/FrontendMenuBuilder.php",
"diff": "@@ -68,7 +68,7 @@ class FrontendMenuBuilder\n}\n}\n- public function setUri($link = ''): string\n+ private function setUri($link = ''): string\n{\n$link = trim($link, '/');\n@@ -89,7 +89,7 @@ class FrontendMenuBuilder\nreturn $link;\n}\n- public function getContent(string $link): ?Content\n+ private function getContent(string $link): ?Content\n{\n$parts = explode('/', $link);\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Mark properties private
|
95,144 |
01.04.2019 14:37:45
| -7,200 |
7c506bfb1af6f75a77e98e68d49859480adad49b
|
Add MenuParserTest.php
|
[
{
"change_type": "ADD",
"old_path": null,
"new_path": "tests/php/Configuration/Parser/MenuParserTest.php",
"diff": "+<?php\n+\n+declare(strict_types=1);\n+\n+namespace Bolt\\Tests\\Configuration\\Parser;\n+\n+use Bolt\\Configuration\\Parser\\MenuParser;\n+use PHPUnit\\Framework\\TestCase;\n+use Tightenco\\Collect\\Support\\Collection;\n+\n+class MenuParserTest extends TestCase\n+{\n+ /** @var MenuParser */\n+ private $menuParser;\n+\n+ protected function setUp(): void\n+ {\n+ $this->menuParser = new MenuParser();\n+ }\n+\n+ public function testCanParse(): void\n+ {\n+ $config = $this->menuParser->parse();\n+\n+ $this->assertInstanceOf(Collection::class, $config);\n+ }\n+\n+ public function testHasMenu(): void\n+ {\n+ $config = $this->menuParser->parse();\n+\n+ $this->assertCount(1, $config);\n+\n+ $this->assertArrayHasKey('main', $config);\n+ $this->assertCount(4, $config['main']);\n+\n+ $this->assertArrayNotHasKey('foo', $config);\n+ }\n+}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Add MenuParserTest.php
|
95,144 |
05.04.2019 07:06:05
| -7,200 |
304de227d8d2ac4c583bcfc8baf553ea5914bf84
|
Remove unneeded 'contenttype' key from menu struct
|
[
{
"change_type": "MODIFY",
"old_path": "assets/js/app/sidebar/Components/Menu/index.vue",
"new_path": "assets/js/app/sidebar/Components/Menu/index.vue",
"diff": "v-else\n:href=\"item.link\"\nclass=\"admin__sidebar--link\"\n- :class=\"{\n- 'has-menu': item.submenu !== null || item.contenttype !== null,\n- }\"\n+ :class=\"{'has-menu': item.submenu !== null}\"\n>\n<i class=\"fas mr-2 link--icon\" :class=\"item.icon\"></i\n><span class=\"link--text\">{{ item.name }}</span>\n- <template v-if=\"item.submenu !== null || item.contenttype !== null\">\n+ <template v-if=\"item.submenu !== null\">\n<i class=\"fas fa-caret-right link--caret\"></i>\n<sub-menu :item=\"item\"></sub-menu>\n</template>\n"
},
{
"change_type": "MODIFY",
"old_path": "assets/js/app/toolbar/Components/Toolbar.vue",
"new_path": "assets/js/app/toolbar/Components/Toolbar.vue",
"diff": "@@ -70,7 +70,7 @@ export default {\ncreateMenu() {\nreturn this.menu.filter(item => {\nreturn (\n- (item.contentType !== null && !item.singleton && item.singular_name) ||\n+ (!item.singleton && item.singular_name) ||\n(item.singleton && (item.submenu === null || item.submenu.length < 1))\n);\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Menu/MenuBuilder.php",
"new_path": "src/Menu/MenuBuilder.php",
"diff": "@@ -82,7 +82,6 @@ class MenuBuilder\n'singular_slug' => $contentType['singular_slug'],\n'icon' => $contentType['icon_many'],\n'link_new' => $this->urlGenerator->generate('bolt_content_new', ['contentType' => $contentType['slug']]),\n- 'content_type' => $contentType['slug'],\n'singleton' => $contentType['singleton'],\n'active' => $contentType['slug'] === 'pages' ? true : false,\n'submenu' => $this->getLatestRecords($contentType['slug']),\n@@ -341,7 +340,6 @@ class MenuBuilder\n'icon' => $child->getExtra('icon'),\n'link' => $child->getUri(),\n'link_new' => $child->getExtra('link_new'),\n- 'contenttype' => $child->getExtra('contenttype'),\n'singleton' => $child->getExtra('singleton'),\n'type' => $child->getExtra('type'),\n'active' => $child->getExtra('active'),\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Remove unneeded 'contenttype' key from menu struct
|
95,144 |
05.04.2019 15:46:41
| -7,200 |
9b00b9b050a4ab90ca76c682a7bdd5f9b7f7b3bd
|
Extracting (and caching) menus
|
[
{
"change_type": "MODIFY",
"old_path": "config/services.yaml",
"new_path": "config/services.yaml",
"diff": "@@ -39,7 +39,7 @@ services:\ntags:\n- { name: doctrine.event_listener, event: postLoad }\n- Bolt\\Menu\\MenuBuilder:\n+ Bolt\\Menu\\BackendMenuBuilder:\narguments: [\"@knp_menu.factory\"]\ntags:\n- { name: knp_menu.menu_builder, method: createSidebarMenu, alias: sidebar } # The alias is what is used to retrieve the menu\n"
},
{
"change_type": "RENAME",
"old_path": "src/Menu/MenuBuilder.php",
"new_path": "src/Menu/BackendMenuBuilder.php",
"diff": "@@ -11,10 +11,9 @@ use Bolt\\Repository\\ContentRepository;\nuse Bolt\\Twig\\ContentExtension;\nuse Knp\\Menu\\FactoryInterface;\nuse Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface;\n-use Symfony\\Component\\Stopwatch\\Stopwatch;\nuse Symfony\\Contracts\\Translation\\TranslatorInterface;\n-class MenuBuilder\n+class BackendMenuBuilder\n{\n/** @var FactoryInterface */\nprivate $menuFactory;\n@@ -22,9 +21,6 @@ class MenuBuilder\n/** @var Config */\nprivate $config;\n- /** @var Stopwatch */\n- private $stopwatch;\n-\n/** @var ContentRepository */\nprivate $contentRepository;\n@@ -37,11 +33,10 @@ class MenuBuilder\n/** @var ContentExtension */\nprivate $contentExtension;\n- public function __construct(FactoryInterface $menuFactory, Config $config, Stopwatch $stopwatch, ContentRepository $contentRepository, UrlGeneratorInterface $urlGenerator, TranslatorInterface $translator, ContentExtension $contentExtension)\n+ public function __construct(FactoryInterface $menuFactory, Config $config, ContentRepository $contentRepository, UrlGeneratorInterface $urlGenerator, TranslatorInterface $translator, ContentExtension $contentExtension)\n{\n$this->menuFactory = $menuFactory;\n$this->config = $config;\n- $this->stopwatch = $stopwatch;\n$this->contentRepository = $contentRepository;\n$this->urlGenerator = $urlGenerator;\n$this->translator = $translator;\n@@ -50,8 +45,6 @@ class MenuBuilder\npublic function createSidebarMenu()\n{\n- $this->stopwatch->start('bolt.sidebar');\n-\n$t = $this->translator;\n$menu = $this->menuFactory->createItem('root');\n@@ -277,8 +270,6 @@ class MenuBuilder\n],\n]);\n- $this->stopwatch->stop('bolt.sidebar');\n-\nreturn $menu;\n}\n@@ -288,13 +279,10 @@ class MenuBuilder\n$contentType = ContentType::factory($slug, $this->config->get('contenttypes'));\n/** @var Content[] $records */\n- $this->stopwatch->start('menuBuilder.findLatest');\n$records = $this->contentRepository->findLatest($contentType, 5);\n- $this->stopwatch->stop('menuBuilder.findLatest');\n$result = [];\n- $this->stopwatch->start('menuBuilder.parseLatest');\n/** @var Content $record */\nforeach ($records as $record) {\n$result[] = [\n@@ -305,7 +293,6 @@ class MenuBuilder\n'icon' => $record->getIcon(),\n];\n}\n- $this->stopwatch->stop('menuBuilder.parseLatest');\nreturn $result;\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Menu/CachedBackendMenuBuilder.php",
"diff": "+<?php\n+\n+declare(strict_types=1);\n+\n+namespace Bolt\\Menu;\n+\n+use Psr\\SimpleCache\\CacheInterface;\n+use Symfony\\Component\\Stopwatch\\Stopwatch;\n+\n+class CachedBackendMenuBuilder\n+{\n+ /** @var CacheInterface */\n+ private $cache;\n+\n+ /** @var BackendMenuBuilder */\n+ private $menuBuilder;\n+\n+ /** @var Stopwatch */\n+ private $stopwatch;\n+\n+ public function __construct(CacheInterface $cache, BackendMenuBuilder $menuBuilder, Stopwatch $stopwatch)\n+ {\n+ $this->cache = $cache;\n+ $this->menuBuilder = $menuBuilder;\n+ $this->stopwatch = $stopwatch;\n+ }\n+\n+ public function getMenu(bool $pretty = false): string\n+ {\n+ $key = 'backendmenu_' . (int) $pretty;\n+\n+ if ($this->cache->has($key)) {\n+ $menu = $this->cache->get($key);\n+ } else {\n+ $this->stopwatch->start('bolt.sidebarMenu');\n+\n+ $menuArray = $this->menuBuilder->getMenu();\n+ $options = $pretty ? JSON_PRETTY_PRINT : 0;\n+ $menu = json_encode($menuArray, $options);\n+\n+ $this->cache->set($key, $menu);\n+\n+ $this->stopwatch->stop('bolt.sidebarMenu');\n+ }\n+\n+ return $menu;\n+ }\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Menu/CachedFrontendMenuBuilder.php",
"diff": "+<?php\n+\n+declare(strict_types=1);\n+\n+namespace Bolt\\Menu;\n+\n+use Bolt\\Collection\\DeepCollection;\n+use Psr\\SimpleCache\\CacheInterface;\n+use Symfony\\Component\\Stopwatch\\Stopwatch;\n+\n+class CachedFrontendMenuBuilder\n+{\n+ /** @var CacheInterface */\n+ private $cache;\n+\n+ /** @var FrontendMenuBuilder */\n+ private $menuBuilder;\n+\n+ /** @var Stopwatch */\n+ private $stopwatch;\n+\n+ public function __construct(CacheInterface $cache, FrontendMenuBuilder $menuBuilder, Stopwatch $stopwatch)\n+ {\n+ $this->cache = $cache;\n+ $this->menuBuilder = $menuBuilder;\n+ $this->stopwatch = $stopwatch;\n+ }\n+\n+ public function getMenu(?string $name = ''): ?DeepCollection\n+ {\n+ $key = 'frontendmenu_' . ($name ?: 'default');\n+\n+ if ($this->cache->has($key)) {\n+ $menu = $this->cache->get($key);\n+ } else {\n+ $this->stopwatch->start('bolt.frontendMenu');\n+\n+ $menu = $this->menuBuilder->getMenu($name);\n+\n+ $this->cache->set($key, $menu);\n+\n+ $this->stopwatch->stop('bolt.frontendMenu');\n+ }\n+\n+ return $menu;\n+ }\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Twig/BackendMenuExtension.php",
"diff": "+<?php\n+\n+declare(strict_types=1);\n+\n+namespace Bolt\\Twig;\n+\n+use Bolt\\Menu\\CachedBackendMenuBuilder;\n+use Twig\\Extension\\AbstractExtension;\n+use Twig\\TwigFunction;\n+\n+class BackendMenuExtension extends AbstractExtension\n+{\n+ /** @var CachedBackendMenuBuilder */\n+ private $menuBuilder;\n+\n+ public function __construct(CachedBackendMenuBuilder $menuBuilder)\n+ {\n+ $this->menuBuilder = $menuBuilder;\n+ }\n+\n+ /**\n+ * {@inheritdoc}\n+ */\n+ public function getFunctions(): array\n+ {\n+ return [\n+ new TwigFunction('sidebar_menu', [$this, 'getSidebarMenu']),\n+ ];\n+ }\n+\n+ public function getSidebarMenu($pretty = false): string\n+ {\n+ return $this->menuBuilder->getMenu($pretty);\n+ }\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Twig/FrontendMenuExtension.php",
"diff": "+<?php\n+\n+declare(strict_types=1);\n+\n+namespace Bolt\\Twig;\n+\n+use Bolt\\Menu\\FrontendMenuBuilder;\n+use Twig\\Environment;\n+use Twig\\Extension\\AbstractExtension;\n+use Twig\\TwigFunction;\n+\n+class FrontendMenuExtension extends AbstractExtension\n+{\n+ /** @var FrontendMenuBuilder */\n+ private $menuBuilder;\n+\n+ public function __construct(FrontendMenuBuilder $menuBuilder)\n+ {\n+ $this->menuBuilder = $menuBuilder;\n+ }\n+\n+ /**\n+ * {@inheritdoc}\n+ */\n+ public function getFunctions(): array\n+ {\n+ $safe = ['is_safe' => ['html']];\n+ $env = ['needs_environment' => true];\n+\n+ return [\n+ new TwigFunction('menu', [$this, 'getMenu'], $env + $safe),\n+ ];\n+ }\n+\n+ public function getMenu(Environment $twig, ?string $name = null, string $template = '_sub_menu.twig', string $class = '', bool $withsubmenus = true): string\n+ {\n+ $context = [\n+ 'menu' => $this->menuBuilder->getMenu($name),\n+ 'class' => $class,\n+ 'withsubmenus' => $withsubmenus,\n+ ];\n+\n+ return $twig->render($template, $context);\n+ }\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Twig/RecordExtension.php",
"new_path": "src/Twig/RecordExtension.php",
"diff": "@@ -6,8 +6,6 @@ namespace Bolt\\Twig;\nuse Bolt\\Entity\\Content;\nuse Bolt\\Entity\\Field;\n-use Bolt\\Menu\\FrontendMenuBuilder;\n-use Bolt\\Menu\\MenuBuilder;\nuse Bolt\\Repository\\TaxonomyRepository;\nuse Bolt\\Utils\\Excerpt;\nuse Doctrine\\Common\\Collections\\Collection;\n@@ -24,29 +22,18 @@ use Twig\\TwigFunction;\n*/\nclass RecordExtension extends AbstractExtension\n{\n- /** @var MenuBuilder */\n- private $menuBuilder;\n-\n- /** @var string */\n- private $sidebarMenu = null;\n-\n/** @var TaxonomyRepository */\nprivate $taxonomyRepository;\n- /** @var FrontendMenuBuilder */\n- private $frontendMenuBuilder;\n-\n- public function __construct(MenuBuilder $menuBuilder, TaxonomyRepository $taxonomyRepository, FrontendMenuBuilder $frontendMenuBuilder)\n+ public function __construct(TaxonomyRepository $taxonomyRepository)\n{\n- $this->menuBuilder = $menuBuilder;\n$this->taxonomyRepository = $taxonomyRepository;\n- $this->frontendMenuBuilder = $frontendMenuBuilder;\n}\n/**\n* {@inheritdoc}\n*/\n- public function getFunctions()\n+ public function getFunctions(): array\n{\n$safe = ['is_safe' => ['html']];\n$env = ['needs_environment' => true];\n@@ -55,8 +42,6 @@ class RecordExtension extends AbstractExtension\nnew TwigFunction('excerpt', [$this, 'excerpt'], $safe),\nnew TwigFunction('list_templates', [$this, 'getListTemplates']),\nnew TwigFunction('pager', [$this, 'pager'], $env + $safe),\n- new TwigFunction('menu', [$this, 'getMenu'], $env + $safe),\n- new TwigFunction('sidebar_menu', [$this, 'getSidebarMenu']),\nnew TwigFunction('selectoptionsfromarray', [$this, 'selectoptionsfromarray']),\nnew TwigFunction('taxonomyoptions', [$this, 'taxonomyoptions']),\nnew TwigFunction('taxonomyvalues', [$this, 'taxonomyvalues']),\n@@ -81,33 +66,11 @@ class RecordExtension extends AbstractExtension\nreturn $twig->render($template, $context);\n}\n- public function getMenu(Environment $twig, ?string $name = null, string $template = '_sub_menu.twig', string $class = '', bool $withsubmenus = true): string\n- {\n- $context = [\n- 'menu' => $this->frontendMenuBuilder->getMenu($name),\n- 'class' => $class,\n- 'withsubmenus' => $withsubmenus,\n- ];\n-\n- return $twig->render($template, $context);\n- }\n-\npublic static function excerpt(string $text, int $length = 100): string\n{\nreturn Excerpt::getExcerpt($text, $length);\n}\n- public function getSidebarMenu($pretty = false): string\n- {\n- if (! $this->sidebarMenu) {\n- $menuArray = $this->menuBuilder->getMenu();\n- $options = $pretty ? JSON_PRETTY_PRINT : 0;\n- $this->sidebarMenu = json_encode($menuArray, $options);\n- }\n-\n- return $this->sidebarMenu;\n- }\n-\npublic function icon(?Content $record = null, string $icon = 'question-circle'): string\n{\nif ($record instanceof Content) {\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Extracting (and caching) menus
|
95,144 |
05.04.2019 16:47:49
| -7,200 |
0d43124bcf5cfcc46fa87468e5b3f70ff25addda
|
Small CS-fix
|
[
{
"change_type": "MODIFY",
"old_path": "src/Controller/Frontend/DetailController.php",
"new_path": "src/Controller/Frontend/DetailController.php",
"diff": "@@ -30,8 +30,8 @@ class DetailController extends TwigAwareController\n*/\nprivate $fieldRepository;\n- public function __construct(TemplateChooser $templateChooser, ContentRepository $contentRepository, FieldRepository $fieldRepository\n- ) {\n+ public function __construct(TemplateChooser $templateChooser, ContentRepository $contentRepository, FieldRepository $fieldRepository)\n+ {\n$this->templateChooser = $templateChooser;\n$this->contentRepository = $contentRepository;\n$this->fieldRepository = $fieldRepository;\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Small CS-fix
|
95,144 |
11.04.2019 16:31:26
| -7,200 |
78a4025f73315dc387a9aad7fa2d97aacc96b2c1
|
First work on implementing Editor.js / Codex field
|
[
{
"change_type": "ADD",
"old_path": null,
"new_path": "assets/js/app/editor/Components/Editor/Editor/Editor.vue",
"diff": "+<template>\n+ Hoi\n+</template>\n+\n+<script>\n+ import { Editor } from 'vue-editor-js'\n+\n+ export default {\n+ components: {\n+ Editor,\n+ }\n+ }\n+</script>t\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "assets/js/app/editor/index.js",
"new_path": "assets/js/app/editor/index.js",
"diff": "@@ -17,10 +17,13 @@ import {\nSlug,\nText,\nTextarea,\n+ Editor\n} from './Components/Editor';\nimport { Language } from './Components/General';\n+// import Editor from 'vue-editor-js';\n+\nnew Vue({\nstore,\nel: '#editor',\n@@ -37,5 +40,6 @@ new Vue({\n\"editor-text\": Text,\n\"editor-textarea\": Textarea,\n\"general-language\": Language,\n+ \"editor\": Editor\n}\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "config/bolt/contenttypes.yaml",
"new_path": "config/bolt/contenttypes.yaml",
"diff": "@@ -331,35 +331,8 @@ tests:\nslug:\ntype: slug\nuses: title\n- text_markup:\n- type: text\n- allow_html: true\n- text_plain:\n- type: text\n- allow_html: false\n- html_field:\n- type: html\n- image:\n- type: image\n- postfix: An image, actually _named_ image.\n- picture:\n- type: image\n- postfix: An image, named differently.\n- markdown_field:\n- type: markdown\n- textarea_field:\n- type: textarea\n- selectfield:\n- type: select\n- values:\n- foo: Foooo\n- bar: Bario\n- baz: BAzzazza\n- multiselect:\n- type: select\n- values: [ A-tuin, Donatello, Rafael, Leonardo, Michelangelo, Koopa, Squirtle ]\n- multiple: true\n- postfix: \"Select your favourite turtle(s).\"\n+ content:\n+ type: codex\ntaxonomy: [ groups, categories, tags, foobars ]\nrecord_template: test.twig\nlisting_template: listing.twig\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"@babel/plugin-transform-runtime\": \"^7.4.0\",\n\"@babel/polyfill\": \"^7.4.0\",\n\"@babel/preset-env\": \"^7.4.2\",\n+ \"@editorjs/editorjs\": \"^2.12.4\",\n\"@symfony/webpack-encore\": \"^0.26.0\",\n\"@vue/test-utils\": \"^1.0.0-beta.29\",\n\"ajv-keywords\": \"^3.4.0\",\n\"sass-loader\": \"^7.1.0\",\n\"stylelint\": \"^9.10.1\",\n\"stylelint-config-standard\": \"^18.2.0\",\n+ \"vue-editor-js\": \"^0.2.0\",\n\"vue-jest\": \"^3.0.4\",\n\"vue-loader\": \"^15.7.0\",\n\"vue-router\": \"^3.0.2\",\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Entity/Field/CodexField.php",
"diff": "+<?php\n+\n+declare(strict_types=1);\n+\n+namespace Bolt\\Entity\\Field;\n+\n+use Bolt\\Entity\\Field;\n+use Doctrine\\ORM\\Mapping as ORM;\n+\n+/**\n+ * @ORM\\Entity\n+ */\n+class CodexField extends Field implements Excerptable\n+{\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/_base/layout.html.twig",
"new_path": "templates/_base/layout.html.twig",
"diff": "{{ encore_entry_script_tags('bolt') }}\n{% endblock %}\n+\n</body>\n</html>\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "templates/_partials/fields/codex.html.twig",
"diff": "+{% extends '@bolt/_partials/fields/_base.html.twig' %}\n+\n+{% block field %}\n+\n+voor:\n+ <editor\n+ autofocus\n+ holder-id=\"codex-editor\"\n+ save-button-id=\"save-button\"\n+ :init-data=\"initData\"\n+ @save=\"save\"\n+ @ready=\"onReady\"\n+ @change=\"onChange\"\n+ />\n+ :na\n+\n+{% endblock %}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/content/edit.html.twig",
"new_path": "templates/content/edit.html.twig",
"diff": "{# This 'topsection' gets output _before_ the main form, allowing `dump()`, without breaking Vue #}\n{% block topsection %}\n+\n{% endblock %}\n{% block main %}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
First work on implementing Editor.js / Codex field
|
95,144 |
11.04.2019 17:52:11
| -7,200 |
3264eacd813840f574e9e90b4b5ab4e9984ed392
|
Working on image fixtures
|
[
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/DataFixtures/ImagesFixtures.php",
"diff": "+<?php\n+\n+declare(strict_types=1);\n+\n+namespace Bolt\\DataFixtures;\n+\n+use Bolt\\Collection\\DeepCollection;\n+use Bolt\\Configuration\\Config;\n+use Bolt\\Entity\\Content;\n+use Bolt\\Entity\\Field;\n+use Bolt\\Enum\\Statuses;\n+use Doctrine\\Common\\DataFixtures\\DependentFixtureInterface;\n+use Doctrine\\Common\\Persistence\\ObjectManager;\n+use Faker\\Factory;\n+use Faker\\Generator;\n+use Gedmo\\Translatable\\Entity\\Repository\\TranslationRepository;\n+use Gedmo\\Translatable\\Entity\\Translation;\n+use Tightenco\\Collect\\Support\\Collection;\n+\n+class ImagesFixtures extends BaseFixture\n+{\n+ /** @var Generator */\n+ private $faker;\n+\n+ /** @var Collection */\n+ private $config;\n+\n+ private $lastTitle = null;\n+\n+ /** @var array */\n+ private $presetRecords = [];\n+\n+ const AMOUNT = 10;\n+\n+ public function __construct(Config $config)\n+ {\n+ $this->urls = [\n+ 'https://source.unsplash.com/1280x768/?business,workspace,interior/',\n+ 'https://source.unsplash.com/1920x640/?cityscape,landscape,nature/',\n+ 'https://source.unsplash.com/1280x768/?animal,koala,kitten,puppy,cute/',\n+ 'https://source.unsplash.com/1280x768/?technology/',\n+ ];\n+\n+ }\n+\n+\n+\n+ public function load(ObjectManager $manager): void\n+ {\n+ $this->loadContent($manager);\n+\n+ $manager->flush();\n+ }\n+\n+ private function loadContent(ObjectManager $manager): void\n+ {\n+ echo \"tralalala\";\n+\n+ $outputPath = dirname(dirname(__DIR__)) . '/public/files/stock/';\n+\n+ if (!is_dir($outputPath)) {\n+ mkdir($outputPath);\n+ }\n+\n+ for ($i = 1; $i < $this::AMOUNT; $i++) {\n+ $url = $this->urls[array_rand($this->urls)] . rand(10000, 99999);\n+\n+\n+ }\n+\n+\n+ }\n+\n+}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Working on image fixtures
|
95,144 |
12.04.2019 15:46:04
| -7,200 |
6aba6ba8764342951570b5f562669bf04d62ab9f
|
Fixtures with Files and Images
|
[
{
"change_type": "MODIFY",
"old_path": "src/Content/MediaFactory.php",
"new_path": "src/Content/MediaFactory.php",
"diff": "@@ -4,6 +4,7 @@ declare(strict_types=1);\nnamespace Bolt\\Content;\n+use Bolt\\Configuration\\Areas;\nuse Bolt\\Configuration\\Config;\nuse Bolt\\Controller\\UserTrait;\nuse Bolt\\Entity\\Media;\n@@ -15,6 +16,7 @@ use Symfony\\Component\\Finder\\SplFileInfo;\nuse Symfony\\Component\\HttpKernel\\Exception\\UnsupportedMediaTypeHttpException;\nuse Symfony\\Component\\Security\\Core\\Authentication\\Token\\Storage\\TokenStorageInterface;\nuse Tightenco\\Collect\\Support\\Collection;\n+use Webmozart\\PathUtil\\Path;\nclass MediaFactory\n{\n@@ -31,8 +33,9 @@ class MediaFactory\n/** @var Collection */\nprivate $mediaTypes;\n+ private $areas;\n- public function __construct(Config $config, MediaRepository $mediaRepository, TokenStorageInterface $tokenStorage)\n+ public function __construct(Config $config, Areas $areas, MediaRepository $mediaRepository, TokenStorageInterface $tokenStorage)\n{\n$this->config = $config;\n$this->mediaRepository = $mediaRepository;\n@@ -40,20 +43,23 @@ class MediaFactory\n$this->exif = Reader::factory(Reader::TYPE_NATIVE);\n$this->mediaTypes = $config->getMediaTypes();\n+ $this->areas = $areas;\n}\npublic function createOrUpdateMedia(SplFileInfo $file, string $area, ?string $title = null): Media\n{\n+ $path = Path::makeRelative($file->getPath(). '/', $this->areas->get($area, 'basepath'));\n+\n$media = $this->mediaRepository->findOneBy([\n'area' => $area,\n- 'path' => $file->getRelativePath(),\n+ 'path' => $path,\n'filename' => $file->getFilename(),\n]);\nif ($media === null) {\n$media = new Media();\n$media->setFilename($file->getFilename())\n- ->setPath($file->getRelativePath())\n+ ->setPath($path)\n->setArea($area);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/DataFixtures/BaseFixture.php",
"new_path": "src/DataFixtures/BaseFixture.php",
"diff": "@@ -4,13 +4,30 @@ declare(strict_types=1);\nnamespace Bolt\\DataFixtures;\n+use Bolt\\Configuration\\Areas;\n+use Bolt\\Configuration\\Config;\nuse Doctrine\\Bundle\\FixturesBundle\\Fixture;\n+use Symfony\\Component\\Finder\\Finder;\n+use Tightenco\\Collect\\Support\\Collection;\n+use Webmozart\\PathUtil\\Path;\nabstract class BaseFixture extends Fixture\n{\nprivate $referencesIndex = [];\nprivate $taxonomyIndex = [];\n+ /** @var Config */\n+ protected $config;\n+\n+ /** @var Areas */\n+ protected $areas;\n+\n+ public function __construct(Config $config, Areas $areas)\n+ {\n+ $this->config = $config;\n+ $this->areas = $areas;\n+ }\n+\nprotected function getRandomReference(string $entityName)\n{\nif (isset($this->referencesIndex[$entityName]) === false) {\n@@ -53,4 +70,29 @@ abstract class BaseFixture extends Fixture\nreturn $taxonomies;\n}\n+\n+ protected function getImagesIndex($path): Collection\n+ {\n+ $finder = $this->findFiles($path);\n+\n+ $files = [];\n+\n+ foreach ($finder as $file) {\n+ $files[$file->getFilename()] = $file;\n+ }\n+\n+ return new Collection($files);\n+ }\n+\n+ private function findFiles(string $base): Finder\n+ {\n+ $fullpath = Path::canonicalize($base);\n+\n+ $glob = '*.{jpg,png,gif,jpeg}';\n+\n+ $finder = new Finder();\n+ $finder->in($fullpath)->depth('< 2')->sortByName()->name($glob)->files();\n+\n+ return $finder;\n+ }\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/DataFixtures/ContentFixtures.php",
"new_path": "src/DataFixtures/ContentFixtures.php",
"diff": "@@ -5,6 +5,7 @@ declare(strict_types=1);\nnamespace Bolt\\DataFixtures;\nuse Bolt\\Collection\\DeepCollection;\n+use Bolt\\Configuration\\Areas;\nuse Bolt\\Configuration\\Config;\nuse Bolt\\Entity\\Content;\nuse Bolt\\Entity\\Field;\n@@ -22,19 +23,23 @@ class ContentFixtures extends BaseFixture implements DependentFixtureInterface\n/** @var Generator */\nprivate $faker;\n- /** @var Collection */\n- private $config;\n-\nprivate $lastTitle = null;\n/** @var array */\nprivate $presetRecords = [];\n- public function __construct(Config $config)\n+ /** @var Collection */\n+ private $imagesIndex;\n+\n+ public function __construct(Config $config, Areas $areas)\n{\n+ parent::__construct($config, $areas);\n+\n$this->faker = Factory::create();\n$this->presetRecords = $this->getPresetRecords();\n- $this->config = $config->get('contenttypes');\n+\n+ $path = $areas->get('files', 'basepath') . '/stock/';\n+ $this->imagesIndex = $this->getImagesIndex($path);\n}\npublic function getDependencies()\n@@ -57,7 +62,7 @@ class ContentFixtures extends BaseFixture implements DependentFixtureInterface\n/** @var TranslationRepository $translationRepository */\n$translationRepository = $manager->getRepository(Translation::class);\n- foreach ($this->config as $contentType) {\n+ foreach ($this->config->get('contenttypes') as $contentType) {\n$amount = $contentType['singleton'] ? 1 : (int) ($contentType['listing_records'] * 3);\nfor ($i = 1; $i <= $amount; $i++) {\n@@ -139,9 +144,12 @@ class ContentFixtures extends BaseFixture implements DependentFixtureInterface\n$data = [$this->faker->paragraphs(3, true)];\nbreak;\ncase 'image':\n+ case 'file':\n+ $randomImage = $this->imagesIndex->random();\n$data = [\n- 'filename' => 'kitten.jpg',\n- 'alt' => 'A cute kitten',\n+ 'filename' => 'stock/' . $randomImage->getFilename(),\n+ 'alt' => $this->faker->sentence(4, true),\n+ 'title' => $this->faker->sentence(7, true),\n];\nbreak;\ncase 'slug':\n"
},
{
"change_type": "MODIFY",
"old_path": "src/DataFixtures/TaxonomyFixtures.php",
"new_path": "src/DataFixtures/TaxonomyFixtures.php",
"diff": "@@ -5,6 +5,7 @@ declare(strict_types=1);\nnamespace Bolt\\DataFixtures;\nuse Bolt\\Collection\\DeepCollection;\n+use Bolt\\Configuration\\Areas;\nuse Bolt\\Configuration\\Config;\nuse Bolt\\Entity\\Taxonomy;\nuse Bolt\\Utils\\Str;\n@@ -12,14 +13,9 @@ use Doctrine\\Common\\Persistence\\ObjectManager;\nclass TaxonomyFixtures extends BaseFixture\n{\n- /**\n- * @var DeepCollection\n- */\n- private $config;\n-\n- public function __construct(Config $config)\n+ public function __construct(Config $config, Areas $areas)\n{\n- $this->config = $config->get('taxonomies');\n+ parent::__construct($config, $areas);\n}\npublic function load(ObjectManager $manager): void\n@@ -32,7 +28,7 @@ class TaxonomyFixtures extends BaseFixture\nprivate function loadTaxonomies(ObjectManager $manager): void\n{\n$order = 1;\n- foreach ($this->config as $taxonomyDefinition) {\n+ foreach ($this->config->get('taxonomies') as $taxonomyDefinition) {\n/** @var DeepCollection $taxonomyDefinition */\n$options = $taxonomyDefinition->isKeyEmpty('options') ? $this->getDefaultOptions() : $taxonomyDefinition['options'];\n"
},
{
"change_type": "MODIFY",
"old_path": "src/DataFixtures/UserFixtures.php",
"new_path": "src/DataFixtures/UserFixtures.php",
"diff": "@@ -4,6 +4,8 @@ declare(strict_types=1);\nnamespace Bolt\\DataFixtures;\n+use Bolt\\Configuration\\Areas;\n+use Bolt\\Configuration\\Config;\nuse Bolt\\Entity\\User;\nuse Doctrine\\Common\\Persistence\\ObjectManager;\nuse Symfony\\Component\\Security\\Core\\Encoder\\UserPasswordEncoderInterface;\n@@ -13,8 +15,9 @@ class UserFixtures extends BaseFixture\n/** @var UserPasswordEncoderInterface */\nprivate $passwordEncoder;\n- public function __construct(UserPasswordEncoderInterface $passwordEncoder)\n+ public function __construct(Config $config, Areas $areas, UserPasswordEncoderInterface $passwordEncoder)\n{\n+ parent::__construct($config, $areas);\n$this->passwordEncoder = $passwordEncoder;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Entity/Media.php",
"new_path": "src/Entity/Media.php",
"diff": "@@ -281,8 +281,10 @@ class Media\nreturn $this->author;\n}\n- public function setAuthor(?User $author): void\n+ public function setAuthor(?User $author): self\n{\n$this->author = $author;\n+\n+ return $this;\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/_partials/fields/image.html.twig",
"new_path": "templates/_partials/fields/image.html.twig",
"diff": "<editor-image\n:name=\"'{{ name }}'\"\n:filename=\"'{{ field.get('filename') }}'\"\n- :thumbnail=\"'{{ field|thumbnail(width=1200, height=1200, area='files', path=setPath) }}'\"\n+ :thumbnail=\"'{{ field|thumbnail(width=1200, height=1200, area='files') }}'\"\n:title=\"'{{ field.get('title') }}'\"\n:alt=\"'{{ field.get('alt') }}'\"\n:media=\"'{{ field.get('media') }}'\"\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Fixtures with Files and Images
|
95,144 |
13.04.2019 13:30:05
| -7,200 |
4d31453e85ddeff08426e24af50c0c416acbc682
|
Cleanup of constructors
|
[
{
"change_type": "MODIFY",
"old_path": "src/DataFixtures/BaseFixture.php",
"new_path": "src/DataFixtures/BaseFixture.php",
"diff": "@@ -4,8 +4,6 @@ declare(strict_types=1);\nnamespace Bolt\\DataFixtures;\n-use Bolt\\Configuration\\Areas;\n-use Bolt\\Configuration\\Config;\nuse Doctrine\\Bundle\\FixturesBundle\\Fixture;\nuse Symfony\\Component\\Finder\\Finder;\nuse Tightenco\\Collect\\Support\\Collection;\n@@ -16,18 +14,6 @@ abstract class BaseFixture extends Fixture\nprivate $referencesIndex = [];\nprivate $taxonomyIndex = [];\n- /** @var Config */\n- protected $config;\n-\n- /** @var Areas */\n- protected $areas;\n-\n- public function __construct(Config $config, Areas $areas)\n- {\n- $this->config = $config;\n- $this->areas = $areas;\n- }\n-\nprotected function getRandomReference(string $entityName)\n{\nif (isset($this->referencesIndex[$entityName]) === false) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/DataFixtures/ContentFixtures.php",
"new_path": "src/DataFixtures/ContentFixtures.php",
"diff": "@@ -31,12 +31,18 @@ class ContentFixtures extends BaseFixture implements DependentFixtureInterface\n/** @var Collection */\nprivate $imagesIndex;\n+ /** @var Config */\n+ private $config;\n+\n+ /** @var Areas */\n+ private $areas;\n+\npublic function __construct(Config $config, Areas $areas)\n{\n- parent::__construct($config, $areas);\n-\n$this->faker = Factory::create();\n$this->presetRecords = $this->getPresetRecords();\n+ $this->config = $config;\n+ $this->areas = $areas;\n}\npublic function getDependencies()\n"
},
{
"change_type": "MODIFY",
"old_path": "src/DataFixtures/ImagesFixtures.php",
"new_path": "src/DataFixtures/ImagesFixtures.php",
"diff": "@@ -5,7 +5,6 @@ declare(strict_types=1);\nnamespace Bolt\\DataFixtures;\nuse Bolt\\Configuration\\Areas;\n-use Bolt\\Configuration\\Config;\nuse Bolt\\Content\\MediaFactory;\nuse Doctrine\\Common\\Persistence\\ObjectManager;\nuse Faker\\Factory;\n@@ -21,12 +20,15 @@ class ImagesFixtures extends BaseFixture\n/** @var Collection */\nprivate $urls;\n- private const AMOUNT = 10;\n-\n/** @var MediaFactory */\nprivate $mediaFactory;\n- public function __construct(Config $config, Areas $areas, MediaFactory $mediaFactory)\n+ /** @var Areas */\n+ private $areas;\n+\n+ private const AMOUNT = 10;\n+\n+ public function __construct(Areas $areas, MediaFactory $mediaFactory)\n{\n$this->urls = new Collection([\n'https://source.unsplash.com/1280x1024/?business,workspace,interior/',\n@@ -35,9 +37,9 @@ class ImagesFixtures extends BaseFixture\n'https://source.unsplash.com/1280x1024/?technology/',\n]);\n- parent::__construct($config, $areas);\n$this->faker = Factory::create();\n$this->mediaFactory = $mediaFactory;\n+ $this->areas = $areas;\n}\npublic function load(ObjectManager $manager): void\n"
},
{
"change_type": "MODIFY",
"old_path": "src/DataFixtures/TaxonomyFixtures.php",
"new_path": "src/DataFixtures/TaxonomyFixtures.php",
"diff": "@@ -5,7 +5,6 @@ declare(strict_types=1);\nnamespace Bolt\\DataFixtures;\nuse Bolt\\Collection\\DeepCollection;\n-use Bolt\\Configuration\\Areas;\nuse Bolt\\Configuration\\Config;\nuse Bolt\\Entity\\Taxonomy;\nuse Bolt\\Utils\\Str;\n@@ -13,9 +12,12 @@ use Doctrine\\Common\\Persistence\\ObjectManager;\nclass TaxonomyFixtures extends BaseFixture\n{\n- public function __construct(Config $config, Areas $areas)\n+ /** @var Config */\n+ private $config;\n+\n+ public function __construct(Config $config)\n{\n- parent::__construct($config, $areas);\n+ $this->config = $config;\n}\npublic function load(ObjectManager $manager): void\n"
},
{
"change_type": "MODIFY",
"old_path": "src/DataFixtures/UserFixtures.php",
"new_path": "src/DataFixtures/UserFixtures.php",
"diff": "@@ -4,8 +4,6 @@ declare(strict_types=1);\nnamespace Bolt\\DataFixtures;\n-use Bolt\\Configuration\\Areas;\n-use Bolt\\Configuration\\Config;\nuse Bolt\\Entity\\User;\nuse Doctrine\\Common\\Persistence\\ObjectManager;\nuse Symfony\\Component\\Security\\Core\\Encoder\\UserPasswordEncoderInterface;\n@@ -15,9 +13,8 @@ class UserFixtures extends BaseFixture\n/** @var UserPasswordEncoderInterface */\nprivate $passwordEncoder;\n- public function __construct(Config $config, Areas $areas, UserPasswordEncoderInterface $passwordEncoder)\n+ public function __construct(UserPasswordEncoderInterface $passwordEncoder)\n{\n- parent::__construct($config, $areas);\n$this->passwordEncoder = $passwordEncoder;\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Cleanup of constructors
|
95,144 |
14.04.2019 08:52:08
| -7,200 |
2feb2e5e06c7ee4f66ee49e72f8747a4439b89c1
|
ninja-fix some text formatting
|
[
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -166,10 +166,10 @@ These are the translations used in Bolt. We rely on the community to expand on n\ntranslations, and keep them up to date. If you wish to participate, read the\n[instructions here][translations].\n-Are are several translation-related commands:\n-- `bin/console translation:download` - downloads translations from Loco (replaces all local ones)\n-- `bin/console translation:sync bolt down` - downloads translations from Loco (replaces local changes if there is a conflict)\n-- `bin/console translation:sync bolt up` - sends updated translations to Loco\n+Several translation-related Console commands are available:\n+- `bin/console translation:download` - Download translations from Loco (replaces all local ones)\n+- `bin/console translation:sync bolt down` - Download translations from Loco (replaces local changes if there is a conflict)\n+- `bin/console translation:sync bolt up` - Sends updated translations to Loco\n[fowler]: https://martinfowler.com/articles/practical-test-pyramid.html\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
ninja-fix some text formatting
|
95,112 |
14.04.2019 01:08:08
| -7,200 |
ad7b9c2ede1b7f433ff95bd0e8e427c16ebea3fe
|
Fix integration with API Platform 2.4, the other way around
|
[
{
"change_type": "MODIFY",
"old_path": "src/Content/MediaFactory.php",
"new_path": "src/Content/MediaFactory.php",
"diff": "@@ -92,7 +92,7 @@ class MediaFactory\nreturn;\n}\n- $size = getimagesize($file->getRealpath());\n+ $size = @getimagesize($file->getRealpath());\nif ($size !== false) {\n$media->setWidth($size[0])\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Entity/Content.php",
"new_path": "src/Entity/Content.php",
"diff": "@@ -30,7 +30,7 @@ use Tightenco\\Collect\\Support\\Collection as LaravelCollection;\n* })\n* @ORM\\HasLifecycleCallbacks\n*/\n-class Content implements \\JsonSerializable\n+class Content\n{\nuse ContentLocalizeTrait;\nuse ContentExtrasTrait;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Entity/ContentExtrasTrait.php",
"new_path": "src/Entity/ContentExtrasTrait.php",
"diff": "@@ -40,35 +40,4 @@ trait ContentExtrasTrait\n'editLink' => $this->contentExtension->getEditLink($content),\n];\n}\n-\n- public function jsonSerialize(): array\n- {\n- /** @var Content $content */\n- $content = $this;\n-\n- if ($this->getDefinition() === null) {\n- return [];\n- }\n-\n- return [\n- 'id' => $content->getId(),\n- 'contentType' => $content->getContentType(),\n- 'slug' => $content->getSlug(),\n- 'author' => [\n- 'id' => $content->getAuthor()->getId(),\n- 'displayName' => $content->getAuthor()->getDisplayName(),\n- 'username' => $content->getAuthor()->getUsername(),\n- 'email' => $content->getAuthor()->getEmail(),\n- ],\n- 'fields' => $content->getFieldValues(),\n- 'taxonomies' => $content->getTaxonomyValues(),\n- 'extras' => $this->getExtras(),\n- 'status' => $content->getStatus(),\n- 'icon' => $content->getIcon(),\n- 'createdAt' => $content->getCreatedAt(),\n- 'modifiedAt' => $content->getModifiedAt(),\n- 'publishedAt' => $content->getPublishedAt(),\n- 'depublishedAt' => $content->getDepublishedAt(),\n- ];\n- }\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Repository/ContentRepository.php",
"new_path": "src/Repository/ContentRepository.php",
"diff": "@@ -138,7 +138,7 @@ class ContentRepository extends ServiceEntityRepository\n'field.id = slug.id'\n)\n->andWhere('slug.value = :slug')\n- ->setParameter('slug', json_encode([$slug]))\n+ ->setParameter('slug', \\GuzzleHttp\\json_encode([$slug]))\n->getQuery()\n->getOneOrNullResult();\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Repository/FieldRepository.php",
"new_path": "src/Repository/FieldRepository.php",
"diff": "@@ -27,7 +27,7 @@ class FieldRepository extends ServiceEntityRepository\nreturn $qb ?: $this->createQueryBuilder('field');\n}\n- public function findOneBySlug($slug): ?Field\n+ public function findOneBySlug(string $slug): ?Field\n{\nreturn $this->getQueryBuilder()\n->andWhere('field.value = :slug')\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Twig/JsonExtension.php",
"diff": "+<?php\n+\n+declare(strict_types=1);\n+\n+namespace Bolt\\Twig;\n+\n+use Bolt\\Entity\\Content;\n+use Symfony\\Component\\Serializer\\Normalizer\\NormalizerInterface;\n+use Twig\\Extension\\AbstractExtension;\n+use Twig\\TwigFilter;\n+\n+class JsonExtension extends AbstractExtension\n+{\n+ private const SERIALIZE_GROUP = 'get_content';\n+\n+ /**\n+ * @var NormalizerInterface\n+ */\n+ private $normalizer;\n+\n+ public function __construct(NormalizerInterface $normalizer)\n+ {\n+ $this->normalizer = $normalizer;\n+ }\n+\n+ /**\n+ * {@inheritdoc}\n+ */\n+ public function getFilters()\n+ {\n+ return [\n+ new TwigFilter('normalize_records', [$this, 'normalizeRecords']),\n+ new TwigFilter('json_records', [$this, 'jsonRecords']),\n+ ];\n+ }\n+\n+ public function jsonRecords($records): string\n+ {\n+ return \\GuzzleHttp\\json_encode($this->normalizeRecords($records));\n+ }\n+\n+ public function normalizeRecords($records): array\n+ {\n+ if ($records instanceof Content) {\n+ return $this->contentToArray($records);\n+ }\n+\n+ if (is_array($records)) {\n+ $normalizedRecords = $records;\n+ } elseif (is_iterable($records)) {\n+ $normalizedRecords = iterator_to_array($records);\n+ } else {\n+ throw new \\InvalidArgumentException();\n+ }\n+\n+ return array_map([$this, 'contentToArray'], $normalizedRecords);\n+ }\n+\n+ private function contentToArray(Content $content): array\n+ {\n+ // we do it that way because in current API Platform version a Resource can't implement \\JsonSerializable\n+ return $this->normalizer->normalize($content, null, ['group' => [self::SERIALIZE_GROUP]]);\n+ }\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/_partials/_content_listing.html.twig",
"new_path": "templates/_partials/_content_listing.html.twig",
"diff": "<!-- listing records -->\n<listing-records\ntype=\"{{ type }}\"\n- :data=\"{{ records|json_encode }}\"\n+ :data=\"{{ records|json_records }}\"\n>\n</listing-records>\n<!-- end listing records -->\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Fix integration with API Platform 2.4, the other way around
|
95,112 |
14.04.2019 10:42:51
| -7,200 |
c4772e30eabd741c707e344738ba0855e321d974
|
Update API platform version in composer.json
|
[
{
"change_type": "MODIFY",
"old_path": "composer.json",
"new_path": "composer.json",
"diff": "\"ext-json\": \"*\",\n\"ext-mbstring\": \"*\",\n\"ext-pdo\": \"*\",\n- \"api-platform/core\": \"v2.4.0-beta.1\",\n+ \"api-platform/core\": \"^2.4\",\n\"bolt/common\": \"^2.0.2\",\n\"cocur/slugify\": \"^3.1\",\n\"doctrine/annotations\": \"^1.0\",\n]\n},\n\"conflict\": {\n- \"symfony/symfony\": \"*\",\n- \"api-platform/core\": \"v2.4.0-beta.2\"\n+ \"symfony/symfony\": \"*\"\n},\n\"extra\": {\n\"symfony\": {\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Update API platform version in composer.json
|
95,144 |
14.04.2019 13:10:56
| -7,200 |
af1b6b84a063c6a6460bfaafa3771874d67c9d9f
|
Rename `$location` -> `$locationName`
|
[
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/Async/UploadController.php",
"new_path": "src/Controller/Backend/Async/UploadController.php",
"diff": "@@ -55,10 +55,10 @@ class UploadController\nreturn new JsonResponse(['error' => ['message' => 'Invalid CSRF token']], Response::HTTP_FORBIDDEN);\n}\n- $location = $request->query->get('location', '');\n+ $locationName = $request->query->get('location', '');\n$path = $request->query->get('path', '');\n- $target = $this->config->getPath($location, true, $path);\n+ $target = $this->config->getPath($locationName, true, $path);\n$uploadHandler = new Handler($target, [\nHandler::OPTION_AUTOCONFIRM => true,\n@@ -86,7 +86,7 @@ class UploadController\nif ($result->isValid()) {\ntry {\n- $media = $this->mediaFactory->createFromFilename($location, $path, $result->__get('name'));\n+ $media = $this->mediaFactory->createFromFilename($locationName, $path, $result->__get('name'));\n$this->em->persist($media);\n$this->em->flush();\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Rename `$location` -> `$locationName`
|
95,112 |
14.04.2019 13:29:05
| -7,200 |
1a89d82b90cc6a25b9f65f91ea5ee1660a73eae3
|
Mark MenuBuilder classes as final
|
[
{
"change_type": "MODIFY",
"old_path": "src/Menu/BackendMenuBuilder.php",
"new_path": "src/Menu/BackendMenuBuilder.php",
"diff": "@@ -13,7 +13,7 @@ use Knp\\Menu\\ItemInterface;\nuse Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface;\nuse Symfony\\Contracts\\Translation\\TranslatorInterface;\n-class BackendMenuBuilder implements BackendMenuBuilderInterface\n+final class BackendMenuBuilder implements BackendMenuBuilderInterface\n{\npublic const MAX_LATEST_RECORDS = 5;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Menu/CachedBackendMenuBuilder.php",
"new_path": "src/Menu/CachedBackendMenuBuilder.php",
"diff": "@@ -6,7 +6,7 @@ namespace Bolt\\Menu;\nuse Psr\\SimpleCache\\CacheInterface;\n-class CachedBackendMenuBuilder implements BackendMenuBuilderInterface\n+final class CachedBackendMenuBuilder implements BackendMenuBuilderInterface\n{\n/** @var CacheInterface */\nprivate $cache;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Menu/CachedFrontendMenuBuilder.php",
"new_path": "src/Menu/CachedFrontendMenuBuilder.php",
"diff": "@@ -6,7 +6,7 @@ namespace Bolt\\Menu;\nuse Psr\\SimpleCache\\CacheInterface;\n-class CachedFrontendMenuBuilder implements FrontendMenuBuilderInterface\n+final class CachedFrontendMenuBuilder implements FrontendMenuBuilderInterface\n{\n/** @var CacheInterface */\nprivate $cache;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Menu/FrontendMenuBuilder.php",
"new_path": "src/Menu/FrontendMenuBuilder.php",
"diff": "@@ -11,7 +11,7 @@ use Bolt\\Repository\\ContentRepository;\nuse Bolt\\Twig\\ContentExtension;\nuse Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface;\n-class FrontendMenuBuilder implements FrontendMenuBuilderInterface\n+final class FrontendMenuBuilder implements FrontendMenuBuilderInterface\n{\n/** @var Config */\nprivate $config;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Menu/StopwatchBackendMenuBuilder.php",
"new_path": "src/Menu/StopwatchBackendMenuBuilder.php",
"diff": "@@ -6,7 +6,7 @@ namespace Bolt\\Menu;\nuse Symfony\\Component\\Stopwatch\\Stopwatch;\n-class StopwatchBackendMenuBuilder implements BackendMenuBuilderInterface\n+final class StopwatchBackendMenuBuilder implements BackendMenuBuilderInterface\n{\n/** @var BackendMenuBuilderInterface */\nprivate $menuBuilder;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Menu/StopwatchFrontendMenuBuilder.php",
"new_path": "src/Menu/StopwatchFrontendMenuBuilder.php",
"diff": "@@ -6,7 +6,7 @@ namespace Bolt\\Menu;\nuse Symfony\\Component\\Stopwatch\\Stopwatch;\n-class StopwatchFrontendMenuBuilder implements FrontendMenuBuilderInterface\n+final class StopwatchFrontendMenuBuilder implements FrontendMenuBuilderInterface\n{\n/** @var FrontendMenuBuilderInterface */\nprivate $menuBuilder;\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Mark MenuBuilder classes as final
|
95,144 |
09.04.2019 08:52:09
| -7,200 |
ba0c56ea4582d45ecd919b24a429529066a51588
|
CS fixes to widgets / snippets
|
[
{
"change_type": "MODIFY",
"old_path": "src/Snippet/Manager.php",
"new_path": "src/Snippet/Manager.php",
"diff": "@@ -13,6 +13,7 @@ use Symfony\\Component\\HttpFoundation\\Request;\nuse Symfony\\Component\\HttpFoundation\\RequestStack;\nuse Symfony\\Component\\HttpFoundation\\Response;\nuse Tightenco\\Collect\\Support\\Collection;\n+use Twig\\Environment;\nclass Manager\n{\n@@ -51,11 +52,11 @@ class Manager\n]);\n}\n- public function getSnippet($name): void\n+ public function getSnippet(string $name): void\n{\n}\n- public function getWidget($twig, $name): string\n+ public function getWidget(Environment $twig, string $name): string\n{\n$widget = $this->queue->where('name', $name)->first();\n@@ -64,7 +65,7 @@ class Manager\n}\n}\n- public function getWidgets($twig, string $target)\n+ public function getWidgets(Environment $twig, string $target): string\n{\n$widgets = $this->queue->where('target', $target)->sortBy('priority');\n@@ -77,7 +78,10 @@ class Manager\nreturn $output;\n}\n- public function invoke($twig, $callback)\n+ /**\n+ * @param BaseWidget|string|callable $callback\n+ */\n+ public function invoke(Environment $twig, $callback): string\n{\nif (is_string($callback)) {\nreturn $callback;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Snippet/Zone.php",
"new_path": "src/Snippet/Zone.php",
"diff": "@@ -47,10 +47,8 @@ class Zone\n/**\n* Check if request is for a specific zone.\n- *\n- * @param string $value\n*/\n- public static function is(Request $request, $value): bool\n+ public static function is(Request $request, string $value): bool\n{\nreturn static::get($request) === $value;\n}\n@@ -65,10 +63,8 @@ class Zone\n/**\n* Set the current zone.\n- *\n- * @param string $value\n*/\n- public static function set(Request $request, $value): void\n+ public static function set(Request $request, string $value): void\n{\n$request->attributes->set(static::KEY, $value);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Twig/SnippetExtension.php",
"new_path": "src/Twig/SnippetExtension.php",
"diff": "@@ -13,7 +13,7 @@ class SnippetExtension extends AbstractExtension\n/**\n* {@inheritdoc}\n*/\n- public function getFunctions()\n+ public function getFunctions(): array\n{\n$safe = ['is_safe' => ['html']];\n$env = ['needs_environment' => true];\n@@ -24,12 +24,12 @@ class SnippetExtension extends AbstractExtension\n];\n}\n- public function getSnippet(Environment $twig, ?string $name = null)\n+ public function getSnippet(Environment $twig, $name = null): string\n{\nreturn \"-- Snippet ${name} --\";\n}\n- public function getSnippetList()\n+ public function getSnippetList(): array\n{\nreturn [];\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Twig/WidgetExtension.php",
"new_path": "src/Twig/WidgetExtension.php",
"diff": "@@ -24,7 +24,7 @@ class WidgetExtension extends AbstractExtension\n/**\n* {@inheritdoc}\n*/\n- public function getFunctions()\n+ public function getFunctions(): array\n{\n$safe = ['is_safe' => ['html']];\n$env = ['needs_environment' => true];\n@@ -38,17 +38,17 @@ class WidgetExtension extends AbstractExtension\n];\n}\n- public function getWidget(Environment $twig, $name)\n+ public function getWidget(Environment $twig, string $name): string\n{\nreturn $this->snippetManager->getWidget($twig, $name);\n}\n- public function getWidgets(Environment $twig, $target)\n+ public function getWidgets(Environment $twig, string $target): string\n{\nreturn $this->snippetManager->getWidgets($twig, $target);\n}\n- public function dummy(Environment $twig, $input = null)\n+ public function dummy(Environment $twig, $input = null): string\n{\n// @todo See Github issue https://github.com/bolt/four/issues/135\nreturn '<!-- Widget \"' . $input . '\" -->';\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/BaseWidget.php",
"new_path": "src/Widget/BaseWidget.php",
"diff": "@@ -35,6 +35,7 @@ class BaseWidget\npublic function setName(string $name): self\n{\n$this->name = $name;\n+\nreturn $this;\n}\n@@ -46,6 +47,7 @@ class BaseWidget\npublic function setType(string $type): self\n{\n$this->type = $type;\n+\nreturn $this;\n}\n@@ -57,6 +59,7 @@ class BaseWidget\npublic function setTarget(string $target): self\n{\n$this->target = $target;\n+\nreturn $this;\n}\n@@ -68,6 +71,7 @@ class BaseWidget\npublic function setPriority(int $priority): self\n{\n$this->priority = $priority;\n+\nreturn $this;\n}\n@@ -76,12 +80,14 @@ class BaseWidget\nreturn $this->priority;\n}\n- public function setTwig(Environment $twig): void\n+ public function setTwig(Environment $twig): self\n{\n$this->twig = $twig;\n+\n+ return $this;\n}\n- public function invoke(?string $template = null)\n+ public function invoke(?string $template = null): string\n{\nif ($template === null) {\n$template = $this->template;\n@@ -97,9 +103,11 @@ class BaseWidget\n);\n}\n- public function setTemplate(string $template): void\n+ public function setTemplate(string $template): self\n{\n$this->template = $template;\n+\n+ return $this;\n}\npublic function getTemplate(): string\n@@ -107,9 +115,11 @@ class BaseWidget\nreturn $this->template;\n}\n- public function setRequest(Request $request): void\n+ public function setRequest(Request $request): self\n{\n$this->request = $request;\n+\n+ return $this;\n}\npublic function getRequest(): Request\n@@ -117,11 +127,13 @@ class BaseWidget\nreturn $this->request;\n}\n- public function setResponse(?Response $response = null): void\n+ public function setResponse(?Response $response = null): self\n{\nif ($response !== null) {\n$this->response = $response;\n}\n+\n+ return $this;\n}\npublic function getResponse(): ?Response\n@@ -129,9 +141,11 @@ class BaseWidget\nreturn $this->response;\n}\n- public function setZone(string $zone): void\n+ public function setZone(string $zone): self\n{\n$this->zone = $zone;\n+\n+ return $this;\n}\npublic function getZone(): string\n@@ -142,6 +156,7 @@ class BaseWidget\npublic function getSlug(): string\n{\n$slugify = Slugify::create();\n+\nreturn $slugify->slugify($this->name);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/NewsWidget.php",
"new_path": "src/Widget/NewsWidget.php",
"diff": "@@ -19,7 +19,7 @@ class NewsWidget extends BaseWidget\nprotected $priority = 150;\nprotected $template = '@bolt/widgets/news.twig';\n- public function invoke(?string $template = null)\n+ public function invoke(?string $template = null): string\n{\n$news = $this->getNews();\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
CS fixes to widgets / snippets
|
95,144 |
10.04.2019 06:53:07
| -7,200 |
03fe08aa7944bd1fc04a99c2a124efd10dc90783
|
Don't use "Manager", use "Snippets", cause that's what they are.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Controller/TwigAwareController.php",
"new_path": "src/Controller/TwigAwareController.php",
"diff": "@@ -6,7 +6,7 @@ namespace Bolt\\Controller;\nuse Bolt\\Configuration\\Config;\nuse Bolt\\Entity\\Field\\TemplateselectField;\n-use Bolt\\Snippet\\Manager;\n+use Bolt\\Snippets;\nuse Bolt\\Version;\nuse Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController;\nuse Symfony\\Component\\HttpFoundation\\Response;\n@@ -21,8 +21,8 @@ class TwigAwareController extends AbstractController\n/** @var Environment */\nprotected $twig;\n- /** @var Manager */\n- private $snippetManager;\n+ /** @var Snippets */\n+ private $snippets;\n/** @var Manager */\nprivate $snippetManager;\n@@ -30,13 +30,13 @@ class TwigAwareController extends AbstractController\n/**\n* @required\n*/\n- public function setAutowire(Config $config, Environment $twig, Manager $snippetManager): void\n+ public function setAutowire(Config $config, Environment $twig, Snippets $snippets): void\n{\n$this->config = $config;\n$this->twig = $twig;\n- $this->snippetManager = $snippetManager;\n+ $this->snippets = $snippets;\n- $this->snippetManager->registerBoltSnippets();\n+ $this->snippets->registerBoltSnippets();\n}\n/**\n@@ -81,7 +81,7 @@ class TwigAwareController extends AbstractController\n$response->setContent($content);\n// Process the snippet Queue on the Response\n- $this->snippetManager->processQueue($response);\n+ $this->snippets->processQueue($response);\nreturn $response;\n}\n"
},
{
"change_type": "RENAME",
"old_path": "src/Snippet/Manager.php",
"new_path": "src/Snippets.php",
"diff": "declare(strict_types=1);\n-namespace Bolt\\Snippet;\n+namespace Bolt;\n+use Bolt\\Snippet\\QueueProcessor;\n+use Bolt\\Snippet\\Target;\n+use Bolt\\Snippet\\Zone;\nuse Bolt\\Widget\\BaseWidget;\nuse Bolt\\Widget\\BoltHeaderWidget;\nuse Bolt\\Widget\\CanonicalLinkWidget;\n@@ -15,7 +18,7 @@ use Symfony\\Component\\HttpFoundation\\Response;\nuse Tightenco\\Collect\\Support\\Collection;\nuse Twig\\Environment;\n-class Manager\n+class Snippets\n{\n/** @var Collection */\nprivate $queue;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Twig/WidgetExtension.php",
"new_path": "src/Twig/WidgetExtension.php",
"diff": "@@ -4,7 +4,7 @@ declare(strict_types=1);\nnamespace Bolt\\Twig;\n-use Bolt\\Snippet\\Manager;\n+use Bolt\\Snippets;\nuse Twig\\Environment;\nuse Twig\\Extension\\AbstractExtension;\nuse Twig\\TwigFunction;\n@@ -14,12 +14,12 @@ use Twig\\TwigFunction;\n*/\nclass WidgetExtension extends AbstractExtension\n{\n- /** @var Manager */\n- private $snippetManager;\n+ /** @var Snippets */\n+ private $snippets;\n- public function __construct(Manager $snippetManager)\n+ public function __construct(Snippets $snippets)\n{\n- $this->snippetManager = $snippetManager;\n+ $this->snippets = $snippets;\n}\n/**\n* {@inheritdoc}\n@@ -40,12 +40,12 @@ class WidgetExtension extends AbstractExtension\npublic function getWidget(Environment $twig, string $name): string\n{\n- return $this->snippetManager->getWidget($twig, $name);\n+ return $this->snippets->getWidget($twig, $name);\n}\npublic function getWidgets(Environment $twig, string $target): string\n{\n- return $this->snippetManager->getWidgets($twig, $target);\n+ return $this->snippets->getWidgets($twig, $target);\n}\npublic function dummy(Environment $twig, $input = null): string\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/BaseWidget.php",
"new_path": "src/Widget/BaseWidget.php",
"diff": "@@ -159,5 +159,4 @@ class BaseWidget\nreturn $slugify->slugify($this->name);\n}\n-\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Don't use "Manager", use "Snippets", cause that's what they are.
|
95,144 |
13.04.2019 14:50:37
| -7,200 |
af5a6b5d94b0c570a28ec3c6b643644f12c2cb4f
|
Fix in typehint
|
[
{
"change_type": "MODIFY",
"old_path": "src/Snippet/Zone.php",
"new_path": "src/Snippet/Zone.php",
"diff": "@@ -56,7 +56,7 @@ class Zone\n/**\n* Get the current zone.\n*/\n- public static function get(Request $request): ?string\n+ public static function get(Request $request): string\n{\nreturn $request->attributes->get(static::KEY) ?: static::NOWHERE;\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Fix in typehint
|
95,144 |
13.04.2019 14:58:19
| -7,200 |
28e7331b9fa6e179f5e2d5f14ded13eb81ff6a28
|
Make widgets use __invoke
|
[
{
"change_type": "MODIFY",
"old_path": "src/Snippet/Injector.php",
"new_path": "src/Snippet/Injector.php",
"diff": "@@ -60,7 +60,7 @@ class Injector\nif ($snippet['callback'] instanceof BaseWidget) {\n$snippet['callback']->setResponse($response);\n- $output = $snippet['callback']->invoke();\n+ $output = $snippet['callback']();\n} else {\n$output = $snippet['callback'];\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Snippets.php",
"new_path": "src/Snippets.php",
"diff": "@@ -101,7 +101,7 @@ class Snippets\nif ($twig !== null) {\n$callback->setTwig($twig);\n}\n- return $callback->invoke();\n+ return $callback();\n}\nreturn '<!-- No callback -->';\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/BaseWidget.php",
"new_path": "src/Widget/BaseWidget.php",
"diff": "@@ -87,7 +87,7 @@ class BaseWidget\nreturn $this;\n}\n- public function invoke(?string $template = null): string\n+ public function __invoke(?string $template = null): string\n{\nif ($template === null) {\n$template = $this->template;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/BoltHeaderWidget.php",
"new_path": "src/Widget/BoltHeaderWidget.php",
"diff": "@@ -14,7 +14,7 @@ class BoltHeaderWidget extends BaseWidget\nprotected $target = Target::NOWHERE;\nprotected $zone = Zone::FRONTEND;\n- public function invoke(?string $template = null): string\n+ public function __invoke(?string $template = null): string\n{\n$this->response->headers->set('X-Powered-By', 'Bolt', false);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/NewsWidget.php",
"new_path": "src/Widget/NewsWidget.php",
"diff": "@@ -19,7 +19,7 @@ class NewsWidget extends BaseWidget\nprotected $priority = 150;\nprotected $template = '@bolt/widgets/news.twig';\n- public function invoke(?string $template = null): string\n+ public function __invoke(?string $template = null): string\n{\n$news = $this->getNews();\n@@ -33,7 +33,7 @@ class NewsWidget extends BaseWidget\n'datefetched' => '2019-04-04 07:25:00',\n];\n- return parent::invoke($template);\n+ return parent::__invoke($template);\n}\n/**\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Make widgets use __invoke
|
95,144 |
13.04.2019 15:21:59
| -7,200 |
99a7ffa7b6b2cece53da79e27e6c89e8b733294a
|
Don't pass around $twig
|
[
{
"change_type": "MODIFY",
"old_path": "src/Snippets.php",
"new_path": "src/Snippets.php",
"diff": "@@ -29,11 +29,15 @@ class Snippets\n/** @var QueueProcessor */\nprivate $queueProcessor;\n- public function __construct(RequestStack $requestStack, QueueProcessor $queueProcessor)\n+ /** @var Environment */\n+ private $twig;\n+\n+ public function __construct(RequestStack $requestStack, QueueProcessor $queueProcessor, Environment $twig)\n{\n$this->queue = new Collection([]);\n$this->request = $requestStack->getCurrentRequest();\n$this->queueProcessor = $queueProcessor;\n+ $this->twig = $twig;\n}\n/**\n@@ -58,6 +62,7 @@ class Snippets\npublic function registerWidget(BaseWidget $widget): void\n{\n$widget->setRequest($this->request);\n+ $widget->setTwig($this->twig);\n$this->queue->push([\n'priority' => $widget->getPriority(),\n@@ -68,23 +73,23 @@ class Snippets\n]);\n}\n- public function getWidget(string $name, ?Environment $twig = null): string\n+ public function getWidget(string $name): string\n{\n$widget = $this->queue->where('name', $name)->first();\nif ($widget) {\n- return $this->invoke($widget['callback'], $twig);\n+ return $this->invoke($widget['callback']);\n}\n}\n- public function getWidgets(string $target, Environment $twig): string\n+ public function getWidgets(string $target): string\n{\n$widgets = $this->queue->where('target', $target)->sortBy('priority');\n$output = '';\nforeach ($widgets as $widget) {\n- $output .= $this->invoke($widget['callback'], $twig);\n+ $output .= $this->invoke($widget['callback']);\n}\nreturn $output;\n@@ -93,14 +98,11 @@ class Snippets\n/**\n* @param BaseWidget|string|callable $callback\n*/\n- public function invoke($callback, ?Environment $twig = null): string\n+ public function invoke($callback): string\n{\nif (is_string($callback)) {\nreturn $callback;\n} elseif ($callback instanceof BaseWidget) {\n- if ($twig !== null) {\n- $callback->setTwig($twig);\n- }\nreturn $callback();\n}\n@@ -121,8 +123,5 @@ class Snippets\n$this->registerSnippet('<meta name=\"generator\" content=\"Bolt\">', Target::END_OF_HEAD);\n$this->registerWidget(new CanonicalLinkWidget());\n$this->registerWidget(new BoltHeaderWidget());\n-\n- // @todo Determine if a favicon is something we want in 2019, by default\n- // $this->registerWidget(new FaviconWidget());\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Twig/WidgetExtension.php",
"new_path": "src/Twig/WidgetExtension.php",
"diff": "@@ -30,25 +30,25 @@ class WidgetExtension extends AbstractExtension\n$env = ['needs_environment' => true];\nreturn [\n- new TwigFunction('countwidgets', [$this, 'dummy'], $safe + $env),\n+ new TwigFunction('countwidgets', [$this, 'dummy'], $safe),\nnew TwigFunction('listwidgets', [$this, 'dummy'], $safe),\n- new TwigFunction('haswidgets', [$this, 'dummy'], $safe + $env),\n- new TwigFunction('widgets', [$this, 'getWidgets'], $safe + $env),\n- new TwigFunction('widget', [$this, 'getWidget'], $safe + $env),\n+ new TwigFunction('haswidgets', [$this, 'dummy'], $safe),\n+ new TwigFunction('widgets', [$this, 'getWidgets'], $safe),\n+ new TwigFunction('widget', [$this, 'getWidget'], $safe),\n];\n}\n- public function getWidget(Environment $twig, string $name): string\n+ public function getWidget(string $name): string\n{\n- return $this->snippets->getWidget($name, $twig);\n+ return $this->snippets->getWidget($name);\n}\n- public function getWidgets(Environment $twig, string $target): string\n+ public function getWidgets(string $target): string\n{\n- return $this->snippets->getWidgets($target, $twig);\n+ return $this->snippets->getWidgets($target);\n}\n- public function dummy(Environment $twig, $input = null): string\n+ public function dummy($input = null): string\n{\n// @todo See Github issue https://github.com/bolt/four/issues/135\nreturn '<!-- Widget \"' . $input . '\" -->';\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/php/SnippetsTest.php",
"new_path": "tests/php/SnippetsTest.php",
"diff": "@@ -55,7 +55,7 @@ class SnippetsTest extends TestCase\n);\n}\n- public function testHeaderWidget(): void\n+ public function testProcessHeaderWidget(): void\n{\n$queueprocessor = new QueueProcessor(new Injector());\n$requestStack = new RequestStack();\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Don't pass around $twig
|
95,144 |
14.04.2019 16:38:38
| -7,200 |
e03e844097618c8e30b7c7580c1a9ce9ed4810cb
|
Make snippets into a type of widget!
|
[
{
"change_type": "MODIFY",
"old_path": "src/Controller/TwigAwareController.php",
"new_path": "src/Controller/TwigAwareController.php",
"diff": "@@ -6,8 +6,8 @@ namespace Bolt\\Controller;\nuse Bolt\\Configuration\\Config;\nuse Bolt\\Entity\\Field\\TemplateselectField;\n-use Bolt\\Snippets;\nuse Bolt\\Version;\n+use Bolt\\Widgets;\nuse Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController;\nuse Symfony\\Component\\HttpFoundation\\Response;\nuse Tightenco\\Collect\\Support\\Collection;\n@@ -21,19 +21,19 @@ class TwigAwareController extends AbstractController\n/** @var Environment */\nprotected $twig;\n- /** @var Snippets */\n- private $snippets;\n+ /** @var Widgets */\n+ private $widgets;\n/**\n* @required\n*/\n- public function setAutowire(Config $config, Environment $twig, Snippets $snippets): void\n+ public function setAutowire(Config $config, Environment $twig, Widgets $widgets): void\n{\n$this->config = $config;\n$this->twig = $twig;\n- $this->snippets = $snippets;\n+ $this->widgets = $widgets;\n- $this->snippets->registerBoltSnippets();\n+ $this->widgets->registerBoltWidgets();\n}\n/**\n@@ -78,8 +78,6 @@ class TwigAwareController extends AbstractController\n$response->setContent($content);\n// Process the snippet Queue on the Response\n- $response = $this->snippets->processQueue($response);\n-\n- return $response;\n+ return $this->widgets->processQueue($response);\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/EventSubscriber/ZoneSubscriber.php",
"new_path": "src/EventSubscriber/ZoneSubscriber.php",
"diff": "@@ -16,7 +16,7 @@ use Symfony\\Component\\HttpKernel\\KernelEvents;\nclass ZoneSubscriber implements EventSubscriberInterface\n{\n- const PRIORITY = 31;\n+ public const PRIORITY = 31;\n/**\n* Kernel request listener callback.\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Snippet/QueueProcessor.php",
"new_path": "src/Snippet/QueueProcessor.php",
"diff": "@@ -18,6 +18,8 @@ class QueueProcessor\n/** @var array */\nprivate $matchedComments = [];\n+ private $matchedCommentsCount = 0;\n+\npublic function __construct(Injector $injector)\n{\n$this->injector = $injector;\n@@ -54,7 +56,7 @@ class QueueProcessor\n*/\npublic function pregCallback(array $c): string\n{\n- $key = '###bolt-comment-' . count((array) $this->matchedComments) . '###';\n+ $key = '###bolt-comment-' . $this->matchedCommentsCount++ . '###';\n// Add it to the array of matched comments.\n$this->matchedComments['/' . $key . '/'] = $c[0];\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Twig/WidgetExtension.php",
"new_path": "src/Twig/WidgetExtension.php",
"diff": "@@ -4,7 +4,7 @@ declare(strict_types=1);\nnamespace Bolt\\Twig;\n-use Bolt\\Snippets;\n+use Bolt\\Widgets;\nuse Twig\\Extension\\AbstractExtension;\nuse Twig\\TwigFunction;\n@@ -13,10 +13,10 @@ use Twig\\TwigFunction;\n*/\nclass WidgetExtension extends AbstractExtension\n{\n- /** @var Snippets */\n+ /** @var Widgets */\nprivate $snippets;\n- public function __construct(Snippets $snippets)\n+ public function __construct(Widgets $snippets)\n{\n$this->snippets = $snippets;\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Widget/SnippetWidget.php",
"diff": "+<?php\n+\n+declare(strict_types=1);\n+\n+namespace Bolt\\Widget;\n+\n+use Bolt\\Snippet\\Target;\n+use Bolt\\Snippet\\Zone;\n+\n+class SnippetWidget extends BaseWidget\n+{\n+ protected $name = 'Nameless Snippet';\n+ protected $type = 'snippet';\n+ protected $target = Target::NOWHERE;\n+ protected $zone = Zone::NOWHERE;\n+ protected $priority = 200;\n+ protected $snippet = '';\n+\n+ public function getSnippet(): string\n+ {\n+ return $this->snippet;\n+ }\n+\n+ public function setSnippet(string $snippet): self\n+ {\n+ $this->snippet = $snippet;\n+\n+ return $this;\n+ }\n+\n+ public function __invoke(?string $template = null): string\n+ {\n+ return $this->getSnippet();\n+ }\n+}\n"
},
{
"change_type": "RENAME",
"old_path": "src/Snippets.php",
"new_path": "src/Widgets.php",
"diff": "@@ -11,6 +11,7 @@ use Bolt\\Widget\\BaseWidget;\nuse Bolt\\Widget\\BoltHeaderWidget;\nuse Bolt\\Widget\\CanonicalLinkWidget;\nuse Bolt\\Widget\\NewsWidget;\n+use Bolt\\Widget\\SnippetWidget;\nuse Bolt\\Widget\\WeatherWidget;\nuse Symfony\\Component\\HttpFoundation\\Request;\nuse Symfony\\Component\\HttpFoundation\\RequestStack;\n@@ -18,7 +19,7 @@ use Symfony\\Component\\HttpFoundation\\Response;\nuse Tightenco\\Collect\\Support\\Collection;\nuse Twig\\Environment;\n-class Snippets\n+class Widgets\n{\n/** @var Collection */\nprivate $queue;\n@@ -40,25 +41,6 @@ class Snippets\n$this->twig = $twig;\n}\n- /**\n- * @param BaseWidget|string|callable $callback\n- */\n- public function registerSnippet(\n- $callback,\n- string $target = Target::NOWHERE,\n- string $zone = Zone::FRONTEND,\n- string $name = 'nameless snippet',\n- int $priority = 100\n- ): void {\n- $this->queue->push([\n- 'priority' => $priority,\n- 'target' => $target,\n- 'name' => $name,\n- 'zone' => $zone,\n- 'callback' => $callback,\n- ]);\n- }\n-\npublic function registerWidget(BaseWidget $widget): void\n{\n$widget->setRequest($this->request);\n@@ -112,18 +94,22 @@ class Snippets\npublic function processQueue(Response $response): Response\n{\n$zone = Zone::getFromRequest($this->request);\n- $response = $this->queueProcessor->process($response, $this->queue, $zone);\n-\n- return $response;\n+ return $this->queueProcessor->process($response, $this->queue, $zone);\n}\n- public function registerBoltSnippets(): void\n+ public function registerBoltWidgets(): void\n{\n$this->registerWidget(new WeatherWidget());\n$this->registerWidget(new NewsWidget());\n-\n- $this->registerSnippet('<meta name=\"generator\" content=\"Bolt\">', Target::END_OF_HEAD);\n$this->registerWidget(new CanonicalLinkWidget());\n$this->registerWidget(new BoltHeaderWidget());\n+\n+ $metaTagSnippet = (new SnippetWidget())\n+ ->setName('Meta Generator tag snippet')\n+ ->setTarget(Target::END_OF_HEAD)\n+ ->setZone(Zone::FRONTEND)\n+ ->setSnippet('<meta name=\"generator\" content=\"Bolt\">');\n+\n+ $this->registerWidget($metaTagSnippet);\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/php/SnippetsTest.php",
"new_path": "tests/php/SnippetsTest.php",
"diff": "@@ -8,7 +8,7 @@ use Bolt\\Snippet\\Injector;\nuse Bolt\\Snippet\\QueueProcessor;\nuse Bolt\\Snippet\\Target;\nuse Bolt\\Snippet\\Zone;\n-use Bolt\\Snippets;\n+use Bolt\\Widgets;\nuse Bolt\\Widget\\BoltHeaderWidget;\nuse Bolt\\Widget\\WeatherWidget;\nuse PHPUnit\\Framework\\TestCase;\n@@ -29,7 +29,7 @@ class SnippetsTest extends TestCase\n$loader = new ArrayLoader(['weather.twig' => '[Hello, weather!]']);\n$twig = new Environment($loader);\n- $snippets = new Snippets($requestStack, $queueprocessor, $twig);\n+ $snippets = new Widgets($requestStack, $queueprocessor, $twig);\n$response = new Response('<html><body>foo</body></html>');\n$snippets->registerSnippet('*foo*', Target::END_OF_BODY, Zone::NOWHERE, 'test');\n@@ -47,7 +47,7 @@ class SnippetsTest extends TestCase\n$loader = new ArrayLoader(['weather.twig' => '[Hello, weather!]']);\n$twig = new Environment($loader);\n- $snippets = new Snippets($requestStack, $queueprocessor, $twig);\n+ $snippets = new Widgets($requestStack, $queueprocessor, $twig);\n$weatherWidget = new WeatherWidget();\n$weatherWidget->setTemplate('weather.twig');\n@@ -69,7 +69,7 @@ class SnippetsTest extends TestCase\n$loader = new ArrayLoader(['weather.twig' => '[Hello, weather!]']);\n$twig = new Environment($loader);\n- $snippets = new Snippets($requestStack, $queueprocessor, $twig);\n+ $snippets = new Widgets($requestStack, $queueprocessor, $twig);\n$response = new Response('<html><body>foo</body></html>');\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Make snippets into a type of widget!
|
95,144 |
14.04.2019 17:14:58
| -7,200 |
7e1acddc91d1a8c78e3f9e68c4f4191a679637d5
|
Added TwigAware Interface
|
[
{
"change_type": "MODIFY",
"old_path": "src/Snippet/Target.php",
"new_path": "src/Snippet/Target.php",
"diff": "@@ -77,9 +77,6 @@ class Target\npublic const NOWHERE = 'nowhere';\n- /**\n- * Returns all possible target locations (which are constants).\n- */\npublic function listAll(): array\n{\n$reflection = new ReflectionClass($this);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/BaseWidget.php",
"new_path": "src/Widget/BaseWidget.php",
"diff": "@@ -93,7 +93,11 @@ class BaseWidget\n$template = $this->template;\n}\n+ if ($this instanceof TwigAware) {\n$output = $this->twig->render($template, $this->context);\n+ } else {\n+ $output = $template;\n+ }\nreturn sprintf(\n'<div id=\"widget-%s\" name=\"%s\">%s</div>',\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/NewsWidget.php",
"new_path": "src/Widget/NewsWidget.php",
"diff": "@@ -11,7 +11,7 @@ use Bolt\\Version;\nuse GuzzleHttp\\Client;\nuse GuzzleHttp\\Exception\\RequestException;\n-class NewsWidget extends BaseWidget\n+class NewsWidget extends BaseWidget implements TwigAware\n{\nprotected $name = 'News Widget';\nprotected $type = 'widget';\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Widget/TwigAware.php",
"diff": "+<?php\n+\n+namespace Bolt\\Widget;\n+\n+/**\n+ * Interface TwigAware - Widgets that make use of a template to render their\n+ * contents need to implement this interface, in order to access the current\n+ * Twig\\Environment and to render a Twig template.\n+ */\n+interface TwigAware\n+{\n+\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/WeatherWidget.php",
"new_path": "src/Widget/WeatherWidget.php",
"diff": "@@ -6,7 +6,7 @@ namespace Bolt\\Widget;\nuse Bolt\\Snippet\\Target;\n-class WeatherWidget extends BaseWidget\n+class WeatherWidget extends BaseWidget implements TwigAware\n{\nprotected $name = 'Weather Widget';\nprotected $type = 'widget';\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widgets.php",
"new_path": "src/Widgets.php",
"diff": "@@ -12,6 +12,7 @@ use Bolt\\Widget\\BoltHeaderWidget;\nuse Bolt\\Widget\\CanonicalLinkWidget;\nuse Bolt\\Widget\\NewsWidget;\nuse Bolt\\Widget\\SnippetWidget;\n+use Bolt\\Widget\\TwigAware;\nuse Bolt\\Widget\\WeatherWidget;\nuse Symfony\\Component\\HttpFoundation\\Request;\nuse Symfony\\Component\\HttpFoundation\\RequestStack;\n@@ -44,7 +45,10 @@ class Widgets\npublic function registerWidget(BaseWidget $widget): void\n{\n$widget->setRequest($this->request);\n+\n+ if ($widget instanceof TwigAware) {\n$widget->setTwig($this->twig);\n+ }\n$this->queue->push([\n'priority' => $widget->getPriority(),\n@@ -60,7 +64,7 @@ class Widgets\n$widget = $this->queue->where('name', $name)->first();\nif ($widget) {\n- return $this($widget['callback']);\n+ return $widget['callback']();\n}\n}\n@@ -71,26 +75,12 @@ class Widgets\n$output = '';\nforeach ($widgets as $widget) {\n- $output .= $this($widget['callback']);\n+ $output .= $widget['callback']();\n}\nreturn $output;\n}\n- /**\n- * @param BaseWidget|string|callable $callback\n- */\n- public function __invoke($callback): string\n- {\n- if (is_string($callback)) {\n- return $callback;\n- } elseif ($callback instanceof BaseWidget) {\n- return $callback();\n- }\n-\n- return '<!-- No callback -->';\n- }\n-\npublic function processQueue(Response $response): Response\n{\n$zone = Zone::getFromRequest($this->request);\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Added TwigAware Interface
|
95,144 |
14.04.2019 17:33:12
| -7,200 |
b58de9388533e1f9bda669e223ca60eeaca57038
|
More cleanup on Widgets
|
[
{
"change_type": "DELETE",
"old_path": "src/Twig/SnippetExtension.php",
"new_path": null,
"diff": "-<?php\n-\n-declare(strict_types=1);\n-\n-namespace Bolt\\Twig;\n-\n-use Twig\\Environment;\n-use Twig\\Extension\\AbstractExtension;\n-use Twig\\TwigFunction;\n-\n-class SnippetExtension extends AbstractExtension\n-{\n- /**\n- * {@inheritdoc}\n- */\n- public function getFunctions(): array\n- {\n- $safe = ['is_safe' => ['html']];\n- $env = ['needs_environment' => true];\n-\n- return [\n- new TwigFunction('snippet', [$this, 'getSnippet'], $env + $safe),\n- new TwigFunction('snippetList', [$this, 'getSnippetList']),\n- ];\n- }\n-\n- public function getSnippet(Environment $twig, $name = null): string\n- {\n- return \"-- Snippet ${name} --\";\n- }\n-\n- public function getSnippetList(): array\n- {\n- return [];\n- }\n-}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/BaseWidget.php",
"new_path": "src/Widget/BaseWidget.php",
"diff": "@@ -32,9 +32,15 @@ class BaseWidget\n/** @var Response */\nprotected $response;\n+ /** @var string */\n+ protected $slug;\n+\npublic function setName(string $name): self\n{\n+ $slugify = Slugify::create();\n+\n$this->name = $name;\n+ $this->slug = $slugify->slugify($this->name);\nreturn $this;\n}\n@@ -159,8 +165,6 @@ class BaseWidget\npublic function getSlug(): string\n{\n- $slugify = Slugify::create();\n-\n- return $slugify->slugify($this->name);\n+ return $this->slug;\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/TwigAware.php",
"new_path": "src/Widget/TwigAware.php",
"diff": "<?php\n+declare(strict_types=1);\n+\nnamespace Bolt\\Widget;\n/**\n@@ -9,5 +11,4 @@ namespace Bolt\\Widget;\n*/\ninterface TwigAware\n{\n-\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/php/Snippet/InjectorTest.php",
"new_path": "tests/php/Snippet/InjectorTest.php",
"diff": "@@ -14,8 +14,7 @@ class InjectorTest extends TestCase\n{\npublic function providerTarget()\n{\n- $o = new \\ReflectionClass(Target::class);\n- $constants = (new Collection(array_keys($o->getConstants())))\n+ $constants = (new Collection(array_keys((new Target)->listAll())))\n->filter(function ($v) {\nreturn mb_strpos($v, 'WIDGET') === false && mb_strpos($v, 'NOWHERE') === false;\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/php/Snippet/ZoneTest.php",
"new_path": "tests/php/Snippet/ZoneTest.php",
"diff": "@@ -25,7 +25,7 @@ class ZoneTest extends TestCase\nreturn $constants->toArray();\n}\n- public function testGet(): void\n+ public function testGetDefaultZone(): void\n{\n$request = Request::createFromGlobals();\n"
},
{
"change_type": "RENAME",
"old_path": "tests/php/SnippetsTest.php",
"new_path": "tests/php/WidgetsTest.php",
"diff": "@@ -18,9 +18,9 @@ use Symfony\\Component\\HttpFoundation\\Response;\nuse Twig\\Environment;\nuse Twig\\Loader\\ArrayLoader;\n-class SnippetsTest extends TestCase\n+class WidgetsTest extends TestCase\n{\n- public function testSnippet(): void\n+ public function testProcessWidgetsInQueue(): void\n{\n$queueprocessor = new QueueProcessor(new Injector());\n$requestStack = new RequestStack();\n@@ -29,16 +29,16 @@ class SnippetsTest extends TestCase\n$loader = new ArrayLoader(['weather.twig' => '[Hello, weather!]']);\n$twig = new Environment($loader);\n- $snippets = new Widgets($requestStack, $queueprocessor, $twig);\n+ $widgets = new Widgets($requestStack, $queueprocessor, $twig);\n$response = new Response('<html><body>foo</body></html>');\n- $snippets->registerSnippet('*foo*', Target::END_OF_BODY, Zone::NOWHERE, 'test');\n- $snippets->processQueue($response);\n+ $widgets->registerSnippet('*foo*', Target::END_OF_BODY, Zone::NOWHERE, 'test');\n+ $widgets->processQueue($response);\n$this->assertSame(\"<html><body>foo</body></html>*foo*\\n\", $response->getContent());\n}\n- public function testWidget(): void\n+ public function testRenderWidget(): void\n{\n$queueprocessor = new QueueProcessor(new Injector());\n$requestStack = new RequestStack();\n@@ -47,16 +47,16 @@ class SnippetsTest extends TestCase\n$loader = new ArrayLoader(['weather.twig' => '[Hello, weather!]']);\n$twig = new Environment($loader);\n- $snippets = new Widgets($requestStack, $queueprocessor, $twig);\n+ $widgets = new Widgets($requestStack, $queueprocessor, $twig);\n$weatherWidget = new WeatherWidget();\n$weatherWidget->setTemplate('weather.twig');\n- $snippets->registerWidget($weatherWidget);\n+ $widgets->registerWidget($weatherWidget);\n$this->assertSame(\n'<div id=\"widget-weather-widget\" name=\"Weather Widget\">[Hello, weather!]</div>',\n- $snippets->renderWidgetByName('Weather Widget')\n+ $widgets->renderWidgetByName('Weather Widget')\n);\n}\n@@ -69,15 +69,15 @@ class SnippetsTest extends TestCase\n$loader = new ArrayLoader(['weather.twig' => '[Hello, weather!]']);\n$twig = new Environment($loader);\n- $snippets = new Widgets($requestStack, $queueprocessor, $twig);\n+ $widgets = new Widgets($requestStack, $queueprocessor, $twig);\n$response = new Response('<html><body>foo</body></html>');\n$headerWidget = new BoltHeaderWidget();\n$headerWidget->setZone(Zone::NOWHERE);\n- $snippets->registerWidget($headerWidget);\n- $snippets->processQueue($response);\n+ $widgets->registerWidget($headerWidget);\n+ $widgets->processQueue($response);\n$this->assertSame('Bolt', $response->headers->get('X-Powered-By'));\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
More cleanup on Widgets
|
95,144 |
14.04.2019 18:26:30
| -7,200 |
66fdaec8a364fc1d6a0ed62ee228bd7fefa186db
|
Working on widgets
|
[
{
"change_type": "RENAME",
"old_path": "src/Snippet/Injector.php",
"new_path": "src/Snippet/HtmlInjector.php",
"diff": "@@ -11,7 +11,7 @@ use Symfony\\Component\\HttpFoundation\\Response;\n/**\n* Class for matching HTML elements and injecting text.\n*/\n-class Injector\n+class HtmlInjector\n{\n/**\n* Get a map of function names to locations. We don't have unique callbacks\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Snippet/QueueProcessor.php",
"new_path": "src/Snippet/QueueProcessor.php",
"diff": "@@ -12,7 +12,7 @@ use Tightenco\\Collect\\Support\\Collection;\n*/\nclass QueueProcessor\n{\n- /** @var Injector */\n+ /** @var HtmlInjector */\nprotected $injector;\n/** @var array */\n@@ -20,7 +20,7 @@ class QueueProcessor\nprivate $matchedCommentsCount = 0;\n- public function __construct(Injector $injector)\n+ public function __construct(HtmlInjector $injector)\n{\n$this->injector = $injector;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Twig/WidgetExtension.php",
"new_path": "src/Twig/WidgetExtension.php",
"diff": "@@ -14,11 +14,11 @@ use Twig\\TwigFunction;\nclass WidgetExtension extends AbstractExtension\n{\n/** @var Widgets */\n- private $snippets;\n+ private $widgetRenderer;\n- public function __construct(Widgets $snippets)\n+ public function __construct(Widgets $widgets)\n{\n- $this->snippets = $snippets;\n+ $this->widgetRenderer = $widgets;\n}\n/**\n* {@inheritdoc}\n@@ -38,12 +38,12 @@ class WidgetExtension extends AbstractExtension\npublic function renderWidgetByName(string $name): string\n{\n- return $this->snippets->renderWidgetByName($name);\n+ return $this->widgetRenderer->renderWidgetByName($name);\n}\npublic function renderWidgetsForTarget(string $target): string\n{\n- return $this->snippets->renderWidgetsForTarget($target);\n+ return $this->widgetRenderer->renderWidgetsForTarget($target);\n}\npublic function dummy($input = null): string\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/BaseWidget.php",
"new_path": "src/Widget/BaseWidget.php",
"diff": "@@ -32,15 +32,13 @@ class BaseWidget\n/** @var Response */\nprotected $response;\n- /** @var string */\n+ /** @var ?string */\nprotected $slug;\npublic function setName(string $name): self\n{\n- $slugify = Slugify::create();\n-\n$this->name = $name;\n- $this->slug = $slugify->slugify($this->name);\n+ $this->slug = null;\nreturn $this;\n}\n@@ -165,6 +163,11 @@ class BaseWidget\npublic function getSlug(): string\n{\n+ if ($this->slug === null) {\n+ $slugify = Slugify::create();\n+ $this->slug = $slugify->slugify($this->name);\n+ }\n+\nreturn $this->slug;\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/BoltHeaderWidget.php",
"new_path": "src/Widget/BoltHeaderWidget.php",
"diff": "@@ -16,7 +16,7 @@ class BoltHeaderWidget extends BaseWidget\npublic function __invoke(?string $template = null): string\n{\n- $this->response->headers->set('X-Powered-By', 'Bolt', false);\n+ $this->getResponse()->headers->set('X-Powered-By', 'Bolt', false);\nreturn '';\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/NewsWidget.php",
"new_path": "src/Widget/NewsWidget.php",
"diff": "@@ -11,7 +11,7 @@ use Bolt\\Version;\nuse GuzzleHttp\\Client;\nuse GuzzleHttp\\Exception\\RequestException;\n-class NewsWidget extends BaseWidget implements TwigAware\n+class NewsWidget extends BaseWidget implements TwigAware, RequestAware\n{\nprotected $name = 'News Widget';\nprotected $type = 'widget';\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Widget/RequestAware.php",
"diff": "+<?php\n+\n+declare(strict_types=1);\n+\n+namespace Bolt\\Widget;\n+\n+/**\n+ * Interface RequestAware - Widgets that make use of a template to render their\n+ * contents need to implement this interface, in order to access the current\n+ * Twig\\Environment and to render a Twig template.\n+ */\n+interface RequestAware\n+{\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widgets.php",
"new_path": "src/Widgets.php",
"diff": "@@ -11,6 +11,7 @@ use Bolt\\Widget\\BaseWidget;\nuse Bolt\\Widget\\BoltHeaderWidget;\nuse Bolt\\Widget\\CanonicalLinkWidget;\nuse Bolt\\Widget\\NewsWidget;\n+use Bolt\\Widget\\RequestAware;\nuse Bolt\\Widget\\SnippetWidget;\nuse Bolt\\Widget\\TwigAware;\nuse Bolt\\Widget\\WeatherWidget;\n@@ -44,7 +45,9 @@ class Widgets\npublic function registerWidget(BaseWidget $widget): void\n{\n+ if ($widget instanceof RequestAware) {\n$widget->setRequest($this->request);\n+ }\nif ($widget instanceof TwigAware) {\n$widget->setTwig($this->twig);\n"
},
{
"change_type": "RENAME",
"old_path": "tests/php/Snippet/InjectorTest.php",
"new_path": "tests/php/Snippet/HtmlInjectorTest.php",
"diff": "@@ -4,17 +4,18 @@ declare(strict_types=1);\nnamespace Bolt\\Tests\\Asset;\n-use Bolt\\Snippet\\Injector;\n+use Bolt\\Snippet\\HtmlInjector;\nuse Bolt\\Snippet\\Target;\nuse PHPUnit\\Framework\\TestCase;\nuse Symfony\\Component\\HttpFoundation\\Response;\nuse Tightenco\\Collect\\Support\\Collection;\n-class InjectorTest extends TestCase\n+class HtmlInjectorTest extends TestCase\n{\npublic function providerTarget()\n{\n- $constants = (new Collection(array_keys((new Target)->listAll())))\n+ $list = (new Target())->listAll();\n+ $constants = (new Collection(array_keys($list)))\n->filter(function ($v) {\nreturn mb_strpos($v, 'WIDGET') === false && mb_strpos($v, 'NOWHERE') === false;\n})\n@@ -31,7 +32,7 @@ class InjectorTest extends TestCase\npublic function testMap(string $constant): void\n{\n$constant = constant('Bolt\\Snippet\\Target::' . $constant);\n- $injector = new Injector();\n+ $injector = new HtmlInjector();\nself::assertArrayHasKey($constant, $injector->getMap());\n}\n@@ -43,7 +44,7 @@ class InjectorTest extends TestCase\n{\n$expected = file_get_contents(__DIR__ . '/../../fixtures/Injector/result.' . $constant . '.html');\n$constant = constant('Bolt\\Snippet\\Target::' . $constant);\n- $injector = new Injector();\n+ $injector = new HtmlInjector();\n$snippet = [\n'callback' => 'koala',\n@@ -61,8 +62,7 @@ class InjectorTest extends TestCase\n*/\npublic function testInjectInvalidLocation(string $constant): void\n{\n- $constant = constant('Bolt\\Snippet\\Target::' . $constant);\n- $injector = new Injector();\n+ $injector = new HtmlInjector();\n$snippet = [\n'callback' => 'koala',\n@@ -82,7 +82,7 @@ class InjectorTest extends TestCase\npublic function testInjectEmptyHtml(string $constant): void\n{\n$constant = constant('Bolt\\Snippet\\Target::' . $constant);\n- $injector = new Injector();\n+ $injector = new HtmlInjector();\n$snippet = [\n'callback' => 'koala',\n@@ -101,7 +101,7 @@ class InjectorTest extends TestCase\npublic function testInjectTagSoup(string $constant): void\n{\n$constant = constant('Bolt\\Snippet\\Target::' . $constant);\n- $injector = new Injector();\n+ $injector = new HtmlInjector();\n$snippet = [\n'callback' => 'koala',\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/php/WidgetsTest.php",
"new_path": "tests/php/WidgetsTest.php",
"diff": "@@ -4,13 +4,14 @@ declare(strict_types=1);\nnamespace Bolt\\Tests;\n-use Bolt\\Snippet\\Injector;\n+use Bolt\\Snippet\\HtmlInjector;\nuse Bolt\\Snippet\\QueueProcessor;\nuse Bolt\\Snippet\\Target;\nuse Bolt\\Snippet\\Zone;\n-use Bolt\\Widgets;\nuse Bolt\\Widget\\BoltHeaderWidget;\n+use Bolt\\Widget\\SnippetWidget;\nuse Bolt\\Widget\\WeatherWidget;\n+use Bolt\\Widgets;\nuse PHPUnit\\Framework\\TestCase;\nuse Symfony\\Component\\HttpFoundation\\Request;\nuse Symfony\\Component\\HttpFoundation\\RequestStack;\n@@ -22,7 +23,7 @@ class WidgetsTest extends TestCase\n{\npublic function testProcessWidgetsInQueue(): void\n{\n- $queueprocessor = new QueueProcessor(new Injector());\n+ $queueprocessor = new QueueProcessor(new HtmlInjector());\n$requestStack = new RequestStack();\n$requestStack->push(Request::createFromGlobals());\n@@ -32,7 +33,11 @@ class WidgetsTest extends TestCase\n$widgets = new Widgets($requestStack, $queueprocessor, $twig);\n$response = new Response('<html><body>foo</body></html>');\n- $widgets->registerSnippet('*foo*', Target::END_OF_BODY, Zone::NOWHERE, 'test');\n+ $snippet = (new SnippetWidget())\n+ ->setSnippet('*foo*')\n+ ->setTarget(Target::END_OF_BODY);\n+\n+ $widgets->registerWidget($snippet);\n$widgets->processQueue($response);\n$this->assertSame(\"<html><body>foo</body></html>*foo*\\n\", $response->getContent());\n@@ -40,7 +45,7 @@ class WidgetsTest extends TestCase\npublic function testRenderWidget(): void\n{\n- $queueprocessor = new QueueProcessor(new Injector());\n+ $queueprocessor = new QueueProcessor(new HtmlInjector());\n$requestStack = new RequestStack();\n$requestStack->push(Request::createFromGlobals());\n@@ -62,7 +67,7 @@ class WidgetsTest extends TestCase\npublic function testProcessHeaderWidget(): void\n{\n- $queueprocessor = new QueueProcessor(new Injector());\n+ $queueprocessor = new QueueProcessor(new HtmlInjector());\n$requestStack = new RequestStack();\n$requestStack->push(Request::createFromGlobals());\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Working on widgets
|
95,144 |
17.04.2019 07:10:56
| -7,200 |
f3cdbd86957698b5d8d00905db9874207a8bf484
|
Make WidgetInterface
|
[
{
"change_type": "MODIFY",
"old_path": "src/Widget/BaseWidget.php",
"new_path": "src/Widget/BaseWidget.php",
"diff": "@@ -11,7 +11,7 @@ use Symfony\\Component\\HttpFoundation\\Request;\nuse Symfony\\Component\\HttpFoundation\\Response;\nuse Twig\\Environment;\n-class BaseWidget\n+class BaseWidget implements WidgetInterface\n{\nprotected $name = 'Nameless widget';\nprotected $type = 'widget';\n@@ -35,7 +35,7 @@ class BaseWidget\n/** @var ?string */\nprotected $slug;\n- public function setName(string $name): self\n+ public function setName(string $name): WidgetInterface\n{\n$this->name = $name;\n$this->slug = null;\n@@ -48,7 +48,7 @@ class BaseWidget\nreturn $this->name;\n}\n- public function setType(string $type): self\n+ public function setType(string $type): WidgetInterface\n{\n$this->type = $type;\n@@ -60,7 +60,7 @@ class BaseWidget\nreturn $this->type;\n}\n- public function setTarget(string $target): self\n+ public function setTarget(string $target): WidgetInterface\n{\n$this->target = $target;\n@@ -72,7 +72,7 @@ class BaseWidget\nreturn $this->target;\n}\n- public function setPriority(int $priority): self\n+ public function setPriority(int $priority): WidgetInterface\n{\n$this->priority = $priority;\n@@ -84,7 +84,7 @@ class BaseWidget\nreturn $this->priority;\n}\n- public function setTwig(Environment $twig): self\n+ public function setTwig(Environment $twig): WidgetInterface\n{\n$this->twig = $twig;\n@@ -116,7 +116,7 @@ class BaseWidget\n);\n}\n- public function setTemplate(string $template): self\n+ public function setTemplate(string $template): WidgetInterface\n{\n$this->template = $template;\n@@ -128,7 +128,7 @@ class BaseWidget\nreturn $this->template;\n}\n- public function setRequest(Request $request): self\n+ public function setRequest(Request $request): WidgetInterface\n{\n$this->request = $request;\n@@ -140,7 +140,7 @@ class BaseWidget\nreturn $this->request;\n}\n- public function setResponse(?Response $response = null): self\n+ public function setResponse(?Response $response = null): WidgetInterface\n{\nif ($response !== null) {\n$this->response = $response;\n@@ -154,7 +154,7 @@ class BaseWidget\nreturn $this->response;\n}\n- public function setZone(string $zone): self\n+ public function setZone(string $zone): WidgetInterface\n{\n$this->zone = $zone;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/RequestAware.php",
"new_path": "src/Widget/RequestAware.php",
"diff": "@@ -12,7 +12,7 @@ use Symfony\\Component\\HttpFoundation\\Request;\n*/\ninterface RequestAware\n{\n- public function setRequest(Request $request): BaseWidget;\n+ public function setRequest(Request $request): WidgetInterface;\npublic function getRequest(): Request;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/TwigAware.php",
"new_path": "src/Widget/TwigAware.php",
"diff": "@@ -13,7 +13,7 @@ use Twig\\Environment;\n*/\ninterface TwigAware\n{\n- public function setTwig(Environment $twig): BaseWidget;\n+ public function setTwig(Environment $twig): WidgetInterface;\npublic function getTwig(): Environment;\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Widget/WidgetInterface.php",
"diff": "+<?php\n+\n+declare(strict_types=1);\n+\n+namespace Bolt\\Widget;\n+\n+use Symfony\\Component\\HttpFoundation\\Request;\n+use Symfony\\Component\\HttpFoundation\\Response;\n+use Twig\\Environment;\n+\n+interface WidgetInterface\n+{\n+ public function setName(string $name): self;\n+\n+ public function getName(): string;\n+\n+ public function setType(string $type): self;\n+\n+ public function getType(): string;\n+\n+ public function setTarget(string $target): self;\n+\n+ public function getTarget(): string;\n+\n+ public function setPriority(int $priority): self;\n+\n+ public function getPriority(): int;\n+\n+ public function setTwig(Environment $twig): self;\n+\n+ public function getTwig(): Environment;\n+\n+ public function setTemplate(string $template): self;\n+\n+ public function getTemplate(): string;\n+\n+ public function setRequest(Request $request): self;\n+\n+ public function getRequest(): Request;\n+\n+ public function setResponse(?Response $response = null): self;\n+\n+ public function getResponse(): ?Response;\n+\n+ public function setZone(string $zone): self;\n+\n+ public function getZone(): string;\n+\n+ public function getSlug(): string;\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widgets.php",
"new_path": "src/Widgets.php",
"diff": "@@ -7,7 +7,6 @@ namespace Bolt;\nuse Bolt\\Snippet\\QueueProcessor;\nuse Bolt\\Snippet\\Target;\nuse Bolt\\Snippet\\Zone;\n-use Bolt\\Widget\\BaseWidget;\nuse Bolt\\Widget\\BoltHeaderWidget;\nuse Bolt\\Widget\\CanonicalLinkWidget;\nuse Bolt\\Widget\\NewsWidget;\n@@ -15,6 +14,7 @@ use Bolt\\Widget\\RequestAware;\nuse Bolt\\Widget\\SnippetWidget;\nuse Bolt\\Widget\\TwigAware;\nuse Bolt\\Widget\\WeatherWidget;\n+use Bolt\\Widget\\WidgetInterface;\nuse Symfony\\Component\\HttpFoundation\\Request;\nuse Symfony\\Component\\HttpFoundation\\RequestStack;\nuse Symfony\\Component\\HttpFoundation\\Response;\n@@ -43,7 +43,7 @@ class Widgets\n$this->twig = $twig;\n}\n- public function registerWidget(BaseWidget $widget): void\n+ public function registerWidget(WidgetInterface $widget): void\n{\nif ($widget instanceof RequestAware) {\n$widget->setRequest($this->request);\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Make WidgetInterface
|
95,144 |
17.04.2019 17:33:53
| -7,200 |
2af894851f7f42f997fb12bcee2c8e4a0077d0b3
|
Making Traits (in progress)
|
[
{
"change_type": "MODIFY",
"old_path": "src/Widget/BaseWidget.php",
"new_path": "src/Widget/BaseWidget.php",
"diff": "@@ -20,9 +20,6 @@ class BaseWidget implements WidgetInterface\nprotected $priority = 0;\nprotected $context = [];\n- /** @var Environment */\n- protected $twig;\n-\n/** @var string */\nprotected $template;\n@@ -84,25 +81,13 @@ class BaseWidget implements WidgetInterface\nreturn $this->priority;\n}\n- public function setTwig(Environment $twig): WidgetInterface\n- {\n- $this->twig = $twig;\n-\n- return $this;\n- }\n-\n- public function getTwig(): Environment\n- {\n- return $this->twig;\n- }\n-\npublic function __invoke(?string $template = null): string\n{\nif ($template === null) {\n$template = $this->template;\n}\n- if ($this instanceof TwigAware) {\n+ if ($this->hasTrait(TwigAware::class)) {\n$output = $this->twig->render($template, $this->context);\n} else {\n$output = $template;\n@@ -175,4 +160,29 @@ class BaseWidget implements WidgetInterface\nreturn $this->slug;\n}\n+\n+ public function hasTrait(string $classname)\n+ {\n+ return in_array($classname, $this->getTraits());\n+ }\n+\n+ /**\n+ * Get all `class_uses` traits from current class, as well as from its\n+ * parent classes and traits.\n+ */\n+ private function getTraits(): array\n+ {\n+ $class = $this;\n+ $traits = [];\n+\n+ do {\n+ $traits = array_merge(class_uses($class), $traits);\n+ } while($class = get_parent_class($class));\n+\n+ foreach ($traits as $trait => $same) {\n+ $traits = array_merge(class_uses($trait), $traits);\n+ }\n+\n+ return array_unique($traits);\n+ }\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/NewsWidget.php",
"new_path": "src/Widget/NewsWidget.php",
"diff": "@@ -11,8 +11,10 @@ use Bolt\\Version;\nuse GuzzleHttp\\Client;\nuse GuzzleHttp\\Exception\\RequestException;\n-class NewsWidget extends BaseWidget implements TwigAware, RequestAware\n+class NewsWidget extends BaseWidget implements RequestAware\n{\n+ use TwigAware;\n+\nprotected $name = 'News Widget';\nprotected $type = 'widget';\nprotected $target = Target::WIDGET_BACK_DASHBOARD_ASIDE_TOP;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/TwigAware.php",
"new_path": "src/Widget/TwigAware.php",
"diff": "@@ -11,9 +11,20 @@ use Twig\\Environment;\n* contents need to implement this interface, in order to access the current\n* Twig\\Environment and to render a Twig template.\n*/\n-interface TwigAware\n+trait TwigAware\n{\n- public function setTwig(Environment $twig): WidgetInterface;\n+ /** @var Environment */\n+ protected $twig;\n- public function getTwig(): Environment;\n+ public function setTwig(Environment $twig): WidgetInterface\n+ {\n+ $this->twig = $twig;\n+\n+ return $this;\n+ }\n+\n+ public function getTwig(): Environment\n+ {\n+ return $this->twig;\n+ }\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/WeatherWidget.php",
"new_path": "src/Widget/WeatherWidget.php",
"diff": "@@ -6,8 +6,10 @@ namespace Bolt\\Widget;\nuse Bolt\\Snippet\\Target;\n-class WeatherWidget extends BaseWidget implements TwigAware\n+class WeatherWidget extends BaseWidget\n{\n+ use TwigAware;\n+\nprotected $name = 'Weather Widget';\nprotected $type = 'widget';\nprotected $target = Target::WIDGET_BACK_DASHBOARD_ASIDE_TOP;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/WidgetInterface.php",
"new_path": "src/Widget/WidgetInterface.php",
"diff": "@@ -26,18 +26,10 @@ interface WidgetInterface\npublic function getPriority(): int;\n- public function setTwig(Environment $twig): self;\n-\n- public function getTwig(): Environment;\n-\npublic function setTemplate(string $template): self;\npublic function getTemplate(): string;\n- public function setRequest(Request $request): self;\n-\n- public function getRequest(): Request;\n-\npublic function setResponse(?Response $response = null): self;\npublic function getResponse(): ?Response;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widgets.php",
"new_path": "src/Widgets.php",
"diff": "@@ -49,7 +49,7 @@ class Widgets\n$widget->setRequest($this->request);\n}\n- if ($widget instanceof TwigAware) {\n+ if ($widget->hasTrait(TwigAware::class)) {\n$widget->setTwig($this->twig);\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Making Traits (in progress)
|
95,144 |
17.04.2019 20:25:05
| -7,200 |
1794ef6a5a1af7898b51333993c3e9dbe5cec743
|
Updating Traits
|
[
{
"change_type": "MODIFY",
"old_path": "src/Widget/BaseWidget.php",
"new_path": "src/Widget/BaseWidget.php",
"diff": "@@ -7,9 +7,7 @@ namespace Bolt\\Widget;\nuse Bolt\\Snippet\\Target;\nuse Bolt\\Snippet\\Zone;\nuse Cocur\\Slugify\\Slugify;\n-use Symfony\\Component\\HttpFoundation\\Request;\nuse Symfony\\Component\\HttpFoundation\\Response;\n-use Twig\\Environment;\nclass BaseWidget implements WidgetInterface\n{\n@@ -23,9 +21,6 @@ class BaseWidget implements WidgetInterface\n/** @var string */\nprotected $template;\n- /** @var Request */\n- protected $request;\n-\n/** @var Response */\nprotected $response;\n@@ -113,18 +108,6 @@ class BaseWidget implements WidgetInterface\nreturn $this->template;\n}\n- public function setRequest(Request $request): WidgetInterface\n- {\n- $this->request = $request;\n-\n- return $this;\n- }\n-\n- public function getRequest(): Request\n- {\n- return $this->request;\n- }\n-\npublic function setResponse(?Response $response = null): WidgetInterface\n{\nif ($response !== null) {\n@@ -163,7 +146,7 @@ class BaseWidget implements WidgetInterface\npublic function hasTrait(string $classname)\n{\n- return in_array($classname, $this->getTraits());\n+ return in_array($classname, $this->getTraits(), true);\n}\n/**\n@@ -177,9 +160,10 @@ class BaseWidget implements WidgetInterface\ndo {\n$traits = array_merge(class_uses($class), $traits);\n- } while($class = get_parent_class($class));\n+ $class = get_parent_class($class);\n+ } while ($class);\n- foreach ($traits as $trait => $same) {\n+ foreach (array_keys($traits) as $trait) {\n$traits = array_merge(class_uses($trait), $traits);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/NewsWidget.php",
"new_path": "src/Widget/NewsWidget.php",
"diff": "@@ -11,9 +11,10 @@ use Bolt\\Version;\nuse GuzzleHttp\\Client;\nuse GuzzleHttp\\Exception\\RequestException;\n-class NewsWidget extends BaseWidget implements RequestAware\n+class NewsWidget extends BaseWidget\n{\nuse TwigAware;\n+ use RequestAware;\nprotected $name = 'News Widget';\nprotected $type = 'widget';\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/RequestAware.php",
"new_path": "src/Widget/RequestAware.php",
"diff": "@@ -7,12 +7,23 @@ namespace Bolt\\Widget;\nuse Symfony\\Component\\HttpFoundation\\Request;\n/**\n- * Interface RequestAware - Widgets that make use of the Request to provide\n- * their functionality need to implement this interface.\n+ * Trait RequestAware - Widgets that make use of the Request to provide\n+ * their functionality need to use this trait.\n*/\n-interface RequestAware\n+trait RequestAware\n{\n- public function setRequest(Request $request): WidgetInterface;\n+ /** @var Request */\n+ protected $request;\n- public function getRequest(): Request;\n+ public function setRequest(Request $request): WidgetInterface\n+ {\n+ $this->request = $request;\n+\n+ return $this;\n+ }\n+\n+ public function getRequest(): Request\n+ {\n+ return $this->request;\n+ }\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/TwigAware.php",
"new_path": "src/Widget/TwigAware.php",
"diff": "@@ -7,8 +7,8 @@ namespace Bolt\\Widget;\nuse Twig\\Environment;\n/**\n- * Interface TwigAware - Widgets that make use of a template to render their\n- * contents need to implement this interface, in order to access the current\n+ * Trait TwigAware - Widgets that make use of a template to render their\n+ * contents need to use this Trait, in order to access the current\n* Twig\\Environment and to render a Twig template.\n*/\ntrait TwigAware\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/WidgetInterface.php",
"new_path": "src/Widget/WidgetInterface.php",
"diff": "@@ -4,9 +4,7 @@ declare(strict_types=1);\nnamespace Bolt\\Widget;\n-use Symfony\\Component\\HttpFoundation\\Request;\nuse Symfony\\Component\\HttpFoundation\\Response;\n-use Twig\\Environment;\ninterface WidgetInterface\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widgets.php",
"new_path": "src/Widgets.php",
"diff": "@@ -45,7 +45,7 @@ class Widgets\npublic function registerWidget(WidgetInterface $widget): void\n{\n- if ($widget instanceof RequestAware) {\n+ if ($widget->hasTrait(RequestAware::class)) {\n$widget->setRequest($this->request);\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Updating Traits
|
95,144 |
17.04.2019 21:01:46
| -7,200 |
1ed954b7b3ff104c17e7bc9a94f33e952f2acc0e
|
no traits, back to Interface
|
[
{
"change_type": "MODIFY",
"old_path": "src/Widget/BaseWidget.php",
"new_path": "src/Widget/BaseWidget.php",
"diff": "@@ -7,7 +7,9 @@ namespace Bolt\\Widget;\nuse Bolt\\Snippet\\Target;\nuse Bolt\\Snippet\\Zone;\nuse Cocur\\Slugify\\Slugify;\n+use Symfony\\Component\\HttpFoundation\\Request;\nuse Symfony\\Component\\HttpFoundation\\Response;\n+use Twig\\Environment;\nclass BaseWidget implements WidgetInterface\n{\n@@ -27,6 +29,12 @@ class BaseWidget implements WidgetInterface\n/** @var ?string */\nprotected $slug;\n+ /** @var Request */\n+ private $request;\n+\n+ /** @var Environment */\n+ private $twig;\n+\npublic function setName(string $name): WidgetInterface\n{\n$this->name = $name;\n@@ -82,7 +90,7 @@ class BaseWidget implements WidgetInterface\n$template = $this->template;\n}\n- if ($this->hasTrait(TwigAware::class)) {\n+ if ($this instanceof TwigAware) {\n$output = $this->twig->render($template, $this->context);\n} else {\n$output = $template;\n@@ -108,6 +116,30 @@ class BaseWidget implements WidgetInterface\nreturn $this->template;\n}\n+ public function setTwig(Environment $twig): WidgetInterface\n+ {\n+ $this->twig = $twig;\n+\n+ return $this;\n+ }\n+\n+ public function getTwig(): Environment\n+ {\n+ return $this->twig;\n+ }\n+\n+ public function setRequest(Request $request): WidgetInterface\n+ {\n+ $this->request = $request;\n+\n+ return $this;\n+ }\n+\n+ public function getRequest(): Request\n+ {\n+ return $this->request;\n+ }\n+\npublic function setResponse(?Response $response = null): WidgetInterface\n{\nif ($response !== null) {\n@@ -143,30 +175,4 @@ class BaseWidget implements WidgetInterface\nreturn $this->slug;\n}\n-\n- public function hasTrait(string $classname)\n- {\n- return in_array($classname, $this->getTraits(), true);\n- }\n-\n- /**\n- * Get all `class_uses` traits from current class, as well as from its\n- * parent classes and traits.\n- */\n- private function getTraits(): array\n- {\n- $class = $this;\n- $traits = [];\n-\n- do {\n- $traits = array_merge(class_uses($class), $traits);\n- $class = get_parent_class($class);\n- } while ($class);\n-\n- foreach (array_keys($traits) as $trait) {\n- $traits = array_merge(class_uses($trait), $traits);\n- }\n-\n- return array_unique($traits);\n- }\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/NewsWidget.php",
"new_path": "src/Widget/NewsWidget.php",
"diff": "@@ -11,11 +11,8 @@ use Bolt\\Version;\nuse GuzzleHttp\\Client;\nuse GuzzleHttp\\Exception\\RequestException;\n-class NewsWidget extends BaseWidget\n+class NewsWidget extends BaseWidget implements TwigAware, RequestAware\n{\n- use TwigAware;\n- use RequestAware;\n-\nprotected $name = 'News Widget';\nprotected $type = 'widget';\nprotected $target = Target::WIDGET_BACK_DASHBOARD_ASIDE_TOP;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/RequestAware.php",
"new_path": "src/Widget/RequestAware.php",
"diff": "@@ -7,23 +7,12 @@ namespace Bolt\\Widget;\nuse Symfony\\Component\\HttpFoundation\\Request;\n/**\n- * Trait RequestAware - Widgets that make use of the Request to provide\n- * their functionality need to use this trait.\n+ * Interface RequestAware - Widgets that make use of the Request to provide\n+ * their functionality need to implement this interface.\n*/\n-trait RequestAware\n+interface RequestAware\n{\n- /** @var Request */\n- protected $request;\n+ public function setRequest(Request $request): WidgetInterface;\n- public function setRequest(Request $request): WidgetInterface\n- {\n- $this->request = $request;\n-\n- return $this;\n- }\n-\n- public function getRequest(): Request\n- {\n- return $this->request;\n- }\n+ public function getRequest(): Request;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/TwigAware.php",
"new_path": "src/Widget/TwigAware.php",
"diff": "@@ -7,24 +7,13 @@ namespace Bolt\\Widget;\nuse Twig\\Environment;\n/**\n- * Trait TwigAware - Widgets that make use of a template to render their\n- * contents need to use this Trait, in order to access the current\n+ * Interface TwigAware - Widgets that make use of a template to render their\n+ * contents need to implement this interface, in order to access the current\n* Twig\\Environment and to render a Twig template.\n*/\n-trait TwigAware\n+interface TwigAware\n{\n- /** @var Environment */\n- protected $twig;\n+ public function setTwig(Environment $twig): WidgetInterface;\n- public function setTwig(Environment $twig): WidgetInterface\n- {\n- $this->twig = $twig;\n-\n- return $this;\n- }\n-\n- public function getTwig(): Environment\n- {\n- return $this->twig;\n- }\n+ public function getTwig(): Environment;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/WeatherWidget.php",
"new_path": "src/Widget/WeatherWidget.php",
"diff": "@@ -6,10 +6,8 @@ namespace Bolt\\Widget;\nuse Bolt\\Snippet\\Target;\n-class WeatherWidget extends BaseWidget\n+class WeatherWidget extends BaseWidget implements TwigAware\n{\n- use TwigAware;\n-\nprotected $name = 'Weather Widget';\nprotected $type = 'widget';\nprotected $target = Target::WIDGET_BACK_DASHBOARD_ASIDE_TOP;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widgets.php",
"new_path": "src/Widgets.php",
"diff": "@@ -45,11 +45,10 @@ class Widgets\npublic function registerWidget(WidgetInterface $widget): void\n{\n- if ($widget->hasTrait(RequestAware::class)) {\n+ if ($widget instanceof RequestAware) {\n$widget->setRequest($this->request);\n}\n-\n- if ($widget->hasTrait(TwigAware::class)) {\n+ if ($widget instanceof TwigAware) {\n$widget->setTwig($this->twig);\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
no traits, back to Interface
|
95,112 |
18.04.2019 09:40:55
| -7,200 |
6572c5d8326111819d29c92f30da202266644136
|
Use default filter instead of is defined in Twig
|
[
{
"change_type": "MODIFY",
"old_path": "Makefile",
"new_path": "Makefile",
"diff": "@@ -26,16 +26,19 @@ csclear:\ncscheck:\nmake csclear\nvendor/bin/ecs check src\n+ vendor/bin/ecs check tests/spec --config vendor/symplify/easy-coding-standard/config/common/namespaces.yml\n+ vendor/bin/ecs check tests/php --config vendor/symplify/easy-coding-standard/config/common/namespaces.yml\n+ vendor/bin/ecs check tests/php --config vendor/symplify/easy-coding-standard/config/common/phpunit.yml\n+ vendor/bin/ecs check tests/php --config vendor/symplify/easy-coding-standard/config/common/strict.yml\nmake stancheck\ncsfix:\nmake csclear\nvendor/bin/ecs check src --fix\n- make stancheck\n-\n-csfix-tests:\n- make csclear\n- vendor/bin/ecs check tests/php --fix\n+ vendor/bin/ecs check tests/spec --fix --config vendor/symplify/easy-coding-standard/config/common/namespaces.yml\n+ vendor/bin/ecs check tests/php --fix --config vendor/symplify/easy-coding-standard/config/common/namespaces.yml\n+ vendor/bin/ecs check tests/php --fix --config vendor/symplify/easy-coding-standard/config/common/phpunit.yml\n+ vendor/bin/ecs check tests/php --fix --config vendor/symplify/easy-coding-standard/config/common/strict.yml\nmake stancheck\nstancheck:\n"
},
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/index.twig",
"new_path": "public/theme/skeleton/index.twig",
"diff": "{% block main %}\n- {% if record is defined %}\n+ {% if record|default %}\n<h1><a href=\"{{ record|link }}\">{{ record|title }}</a></h1>\n"
},
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/listing.twig",
"new_path": "public/theme/skeleton/listing.twig",
"diff": "'all records tagged with kittens'. #}\n{# If used for listing a taxonomy, we add a heading.: #}\n- {% if taxonomytype is defined %}\n+ {% if taxonomy|default %}\n<h1>\n{{ __('general.phrase.overview-for') }}\n{% if taxonomy.options[slug] is defined %}\n"
},
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/partials/_master.twig",
"new_path": "public/theme/skeleton/partials/_master.twig",
"diff": "{# make sure we always display a proper title: The record's title if there is one, appended with the\nsitename. If there is no title, we append the sitename with the payoff, if there is one. #}\n<title>\n- {%- if record is defined and record.title %}{{ record.title }} | {% endif -%}\n- {{ config.get('general/sitename') -}}\n- {% if record is not defined and config.has('general/payoff') %} | {{ config.get('general/payoff') }}{% endif -%}\n+ {%- if record|default and record.title -%}\n+ {{- record.title ~ ' | ' -}}\n+ {%- endif -%}\n+ {{- config.get('general/sitename') -}}\n+ {%- if record|default == null and config.has('general/payoff') -%}\n+ {{- ' | ' ~ config.get('general/payoff') -}}\n+ {%- endif -%}\n</title>\n{#<link rel=\"stylesheet\" href=\"{{ asset('css/normalize.css', 'theme') }}\">#}\n{#<link rel=\"stylesheet\" href=\"{{ asset('css/sakura.css', 'theme') }}\">#}\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/_base/layout.html.twig",
"new_path": "templates/_base/layout.html.twig",
"diff": "}|json_encode %}\n<admin-toolbar\n- site-name=\"{% if config is defined %}{{ config.get('general/sitename') }}{% endif %}\"\n+ site-name=\"{{ config.get('general/sitename') }}\"\n:menu=\"{{ admin_menu_json }}\"\nuser=\"{{ user|default }}\"\n:labels=\"{{ labels }}\"\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/spec/Bolt/Menu/BackendMenuBuilderSpec.php",
"new_path": "tests/spec/Bolt/Menu/BackendMenuBuilderSpec.php",
"diff": "@@ -10,7 +10,6 @@ use Bolt\\Repository\\ContentRepository;\nuse Bolt\\Twig\\ContentExtension;\nuse Knp\\Menu\\FactoryInterface;\nuse Knp\\Menu\\ItemInterface;\n-use Knp\\Menu\\MenuItem;\nuse PhpSpec\\ObjectBehavior;\nuse Prophecy\\Argument;\nuse Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface;\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Use default filter instead of is defined in Twig
|
95,144 |
19.04.2019 13:50:00
| -7,200 |
81bd5888c03bac1d69d1fd91a1db88bdf75780b2
|
Clarify pinning of PHP 7.1.18 in Travis.yml
|
[
{
"change_type": "MODIFY",
"old_path": ".travis.yml",
"new_path": ".travis.yml",
"diff": "@@ -12,8 +12,9 @@ cache:\nmatrix:\nfast_finish: true\ninclude:\n+ # Pinned to 7.1.18, because Travis defaults to 7.1.6, which has broken SSL/TLS. See: https://github.com/travis-ci/travis-ci/issues/6339\n+ - php: 7.1.18\n- php: 7.1.18\n- - php: 7.1\nenv: COMPOSER_FLAGS=\"--prefer-lowest\"\n- php: 7.2\n- php: 7.3\n@@ -21,7 +22,7 @@ matrix:\nenv: COMPOSER_FLAGS=\"--ignore-platform-reqs\"\nallow_failures:\n- php: nightly\n- - php: 7.1\n+ - php: 7.1.18\nenv: COMPOSER_FLAGS=\"--prefer-lowest\"\nbefore_install:\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Clarify pinning of PHP 7.1.18 in Travis.yml
|
95,144 |
19.04.2019 14:51:19
| -7,200 |
a92f288f4f410295c97386e5df23163bc4e0b9a8
|
Don't add arrays to queue, but just the $widgets
|
[
{
"change_type": "MODIFY",
"old_path": "src/Snippet/HtmlInjector.php",
"new_path": "src/Snippet/HtmlInjector.php",
"diff": "@@ -6,6 +6,7 @@ namespace Bolt\\Snippet;\nuse Bolt\\Common\\Str;\nuse Bolt\\Widget\\BaseWidget;\n+use Bolt\\Widget\\WidgetInterface;\nuse Symfony\\Component\\HttpFoundation\\Response;\n/**\n@@ -52,18 +53,21 @@ class HtmlInjector\n];\n}\n- public function inject(array $snippet, Response $response): void\n+ public function inject(WidgetInterface $widget, Response $response): void\n{\n$html = $response->getContent();\n$functionMap = $this->getMap();\n- $target = $snippet['target'];\n+ $target = $widget->getTarget();\n- if ($snippet['callback'] instanceof BaseWidget) {\n- $snippet['callback']->setResponse($response);\n- $output = $snippet['callback']();\n- } else {\n- $output = $snippet['callback'];\n- }\n+ dump('snippet ' . (string) $widget->getName());\n+\n+ dump($widget);\n+\n+ $widget->setResponse($response);\n+\n+ $output = $widget();\n+\n+ dump($output);\nif (isset($functionMap[$target])) {\n$html = $this->{$functionMap[$target]}($output, $html);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Snippet/QueueProcessor.php",
"new_path": "src/Snippet/QueueProcessor.php",
"diff": "@@ -32,9 +32,9 @@ class QueueProcessor\n// $this->matchedComments array\npreg_replace_callback('/<!--(.*)-->/Uis', [$this, 'pregCallback'], $response->getContent());\n- foreach ($queue as $snippet) {\n- if ($snippet['zone'] === $zone) {\n- $this->injector->inject($snippet, $response);\n+ foreach ($queue as $widget) {\n+ if ($widget->getZone() === $zone) {\n+ $this->injector->inject($widget, $response);\n}\n// unset($this->queue[$key]);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/SnippetWidget.php",
"new_path": "src/Widget/SnippetWidget.php",
"diff": "@@ -19,7 +19,7 @@ class SnippetWidget extends BaseWidget\npublic function __construct(?string $snippet = null, ?string $name = null, ?string $target = null, ?string $zone = null)\n{\nif ($snippet !== null) {\n- $this->setName($snippet);\n+ $this->setTemplate($snippet);\n}\nif ($name !== null) {\n@@ -27,28 +27,16 @@ class SnippetWidget extends BaseWidget\n}\nif ($target !== null) {\n- $this->setName($target);\n+ $this->setTarget($target);\n}\nif ($zone !== null) {\n- $this->setName($zone);\n+ $this->setZone($zone);\n}\n}\n- public function getSnippet(): string\n- {\n- return $this->snippet;\n- }\n-\n- public function setSnippet(string $snippet): self\n- {\n- $this->snippet = $snippet;\n-\n- return $this;\n- }\n-\npublic function __invoke(?string $template = null): string\n{\n- return $this->getSnippet();\n+ return $this->getTemplate();\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widgets.php",
"new_path": "src/Widgets.php",
"diff": "@@ -52,32 +52,32 @@ class Widgets\n$widget->setTwig($this->twig);\n}\n- $this->queue->push([\n- 'priority' => $widget->getPriority(),\n- 'target' => $widget->getTarget(),\n- 'name' => $widget->getName(),\n- 'zone' => $widget->getZone(),\n- 'callback' => $widget,\n- ]);\n+ $this->queue->push($widget);\n}\npublic function renderWidgetByName(string $name): string\n{\n- $widget = $this->queue->where('name', $name)->first();\n+ $widget = $this->queue->filter(function(WidgetInterface $widget) use ($name) {\n+ return $widget->getName() === $name;\n+ })->first();\nif ($widget) {\n- return $widget['callback']();\n+ return $widget();\n}\n}\npublic function renderWidgetsForTarget(string $target): string\n{\n- $widgets = $this->queue->where('target', $target)->sortBy('priority');\n+ $widgets = $this->queue->filter(function(WidgetInterface $widget) use ($target) {\n+ return $widget->getTarget() === $target;\n+ })->sortBy(function (WidgetInterface $widget) {\n+ return $widget->getPriority();\n+ });\n$output = '';\nforeach ($widgets as $widget) {\n- $output .= $widget['callback']();\n+ $output .= $widget();\n}\nreturn $output;\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Don't add arrays to queue, but just the $widgets
|
95,144 |
19.04.2019 15:27:21
| -7,200 |
a70075676e517b3ca442f4ca08a52da9e89de022
|
Refactor `Zone` to `RequestZone`.
|
[
{
"change_type": "MODIFY",
"old_path": "src/EventSubscriber/ZoneSubscriber.php",
"new_path": "src/EventSubscriber/ZoneSubscriber.php",
"diff": "@@ -7,7 +7,7 @@ namespace Bolt\\EventSubscriber;\nuse Bolt\\Controller\\Backend\\Async\\AsyncZone;\nuse Bolt\\Controller\\Backend\\BackendZone;\nuse Bolt\\Controller\\Frontend\\FrontendZone;\n-use Bolt\\Snippet\\Zone;\n+use Bolt\\Snippet\\RequestZone;\nuse ReflectionClass;\nuse Symfony\\Component\\EventDispatcher\\EventSubscriberInterface;\nuse Symfony\\Component\\HttpFoundation\\Request;\n@@ -24,7 +24,7 @@ class ZoneSubscriber implements EventSubscriberInterface\npublic function onKernelRequest(GetResponseEvent $event): void\n{\n$request = $event->getRequest();\n- if (Zone::getFromRequest($request) !== Zone::NOWHERE) {\n+ if (RequestZone::getFromRequest($request) !== RequestZone::NOWHERE) {\nreturn;\n}\n@@ -36,12 +36,12 @@ class ZoneSubscriber implements EventSubscriberInterface\n*/\npublic function setZone(Request $request): string\n{\n- if (Zone::getFromRequest($request) !== Zone::NOWHERE) {\n- return Zone::getFromRequest($request);\n+ if (RequestZone::getFromRequest($request) !== RequestZone::NOWHERE) {\n+ return RequestZone::getFromRequest($request);\n}\n$zone = $this->determineZone($request);\n- Zone::setToRequest($request, $zone);\n+ RequestZone::setToRequest($request, $zone);\nreturn $zone;\n}\n@@ -52,7 +52,7 @@ class ZoneSubscriber implements EventSubscriberInterface\nprotected function determineZone(Request $request): string\n{\nif ($request->isXmlHttpRequest()) {\n- return Zone::ASYNC;\n+ return RequestZone::ASYNC;\n}\n$controller = explode('::', $request->attributes->get('_controller'));\n@@ -61,17 +61,17 @@ class ZoneSubscriber implements EventSubscriberInterface\n$reflection = new ReflectionClass($controller[0]);\nif ($reflection->implementsInterface(BackendZone::class)) {\n- return Zone::BACKEND;\n+ return RequestZone::BACKEND;\n} elseif ($reflection->implementsInterface(FrontendZone::class)) {\n- return Zone::FRONTEND;\n+ return RequestZone::FRONTEND;\n} elseif ($reflection->implementsInterface(AsyncZone::class)) {\n- return Zone::ASYNC;\n+ return RequestZone::ASYNC;\n}\n} catch (\\ReflectionException $e) {\n// Alas..\n}\n- return Zone::NOWHERE;\n+ return RequestZone::NOWHERE;\n}\n/**\n"
},
{
"change_type": "RENAME",
"old_path": "src/Snippet/Zone.php",
"new_path": "src/Snippet/RequestZone.php",
"diff": "@@ -10,7 +10,7 @@ use Symfony\\Component\\HttpFoundation\\Request;\n* Zone constants class to define which part of the Bolt site that a request is\n* relative to.\n*/\n-class Zone\n+class RequestZone\n{\npublic const KEY = 'zone';\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/BaseWidget.php",
"new_path": "src/Widget/BaseWidget.php",
"diff": "@@ -4,8 +4,8 @@ declare(strict_types=1);\nnamespace Bolt\\Widget;\n+use Bolt\\Snippet\\RequestZone;\nuse Bolt\\Snippet\\Target;\n-use Bolt\\Snippet\\Zone;\nuse Cocur\\Slugify\\Slugify;\nuse Symfony\\Component\\HttpFoundation\\Request;\nuse Symfony\\Component\\HttpFoundation\\Response;\n@@ -16,7 +16,7 @@ class BaseWidget implements WidgetInterface\nprotected $name = 'Nameless widget';\nprotected $type = 'widget';\nprotected $target = Target::NOWHERE;\n- protected $zone = Zone::EVERYWHERE;\n+ protected $zone = RequestZone::EVERYWHERE;\nprotected $priority = 0;\nprotected $context = [];\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/BoltHeaderWidget.php",
"new_path": "src/Widget/BoltHeaderWidget.php",
"diff": "@@ -4,15 +4,15 @@ declare(strict_types=1);\nnamespace Bolt\\Widget;\n+use Bolt\\Snippet\\RequestZone;\nuse Bolt\\Snippet\\Target;\n-use Bolt\\Snippet\\Zone;\nclass BoltHeaderWidget extends BaseWidget\n{\nprotected $name = 'Bolt Header Widget';\nprotected $type = 'snippet';\nprotected $target = Target::NOWHERE;\n- protected $zone = Zone::FRONTEND;\n+ protected $zone = RequestZone::FRONTEND;\npublic function __invoke(?string $template = null): string\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/CanonicalLinkWidget.php",
"new_path": "src/Widget/CanonicalLinkWidget.php",
"diff": "@@ -4,14 +4,14 @@ declare(strict_types=1);\nnamespace Bolt\\Widget;\n+use Bolt\\Snippet\\RequestZone;\nuse Bolt\\Snippet\\Target;\n-use Bolt\\Snippet\\Zone;\nclass CanonicalLinkWidget extends BaseWidget\n{\nprotected $name = 'Canonical Link';\nprotected $type = 'widget';\nprotected $target = Target::NOWHERE;\n- protected $zone = Zone::NOWHERE;\n+ protected $zone = RequestZone::NOWHERE;\nprotected $priority = 200;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/SnippetWidget.php",
"new_path": "src/Widget/SnippetWidget.php",
"diff": "@@ -4,15 +4,15 @@ declare(strict_types=1);\nnamespace Bolt\\Widget;\n+use Bolt\\Snippet\\RequestZone;\nuse Bolt\\Snippet\\Target;\n-use Bolt\\Snippet\\Zone;\nclass SnippetWidget extends BaseWidget\n{\nprotected $name = 'Nameless Snippet';\nprotected $type = 'snippet';\nprotected $target = Target::NOWHERE;\n- protected $zone = Zone::NOWHERE;\n+ protected $zone = RequestZone::NOWHERE;\nprotected $priority = 200;\npublic function __construct(?string $snippet = null, ?string $name = null, ?string $target = null, ?string $zone = null)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widgets.php",
"new_path": "src/Widgets.php",
"diff": "@@ -5,8 +5,8 @@ declare(strict_types=1);\nnamespace Bolt;\nuse Bolt\\Snippet\\QueueProcessor;\n+use Bolt\\Snippet\\RequestZone;\nuse Bolt\\Snippet\\Target;\n-use Bolt\\Snippet\\Zone;\nuse Bolt\\Widget\\BoltHeaderWidget;\nuse Bolt\\Widget\\CanonicalLinkWidget;\nuse Bolt\\Widget\\NewsWidget;\n@@ -84,7 +84,7 @@ class Widgets\npublic function processQueue(Response $response): Response\n{\n- $zone = Zone::getFromRequest($this->requestStack->getCurrentRequest());\n+ $zone = RequestZone::getFromRequest($this->requestStack->getCurrentRequest());\nreturn $this->queueProcessor->process($response, $this->queue, $zone);\n}\n@@ -99,7 +99,7 @@ class Widgets\n'<meta name=\"generator\" content=\"Bolt\">',\n'Meta Generator tag snippet',\nTarget::END_OF_HEAD,\n- Zone::FRONTEND\n+ RequestZone::FRONTEND\n);\n$this->registerWidget($metaTagSnippet);\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/php/Snippet/ZoneTest.php",
"new_path": "tests/php/Snippet/ZoneTest.php",
"diff": "@@ -4,7 +4,7 @@ declare(strict_types=1);\nnamespace Bolt\\Tests\\Snippet;\n-use Bolt\\Snippet\\Zone;\n+use Bolt\\Snippet\\RequestZone;\nuse PHPUnit\\Framework\\TestCase;\nuse Symfony\\Component\\HttpFoundation\\Request;\nuse Tightenco\\Collect\\Support\\Collection;\n@@ -13,7 +13,7 @@ class ZoneTest extends TestCase\n{\npublic function providerZone()\n{\n- $o = new \\ReflectionClass(Zone::class);\n+ $o = new \\ReflectionClass(RequestZone::class);\n$constants = (new Collection(array_keys($o->getConstants())))\n->filter(function ($v) {\nreturn mb_strpos($v, 'WIDGET') === false && mb_strpos($v, 'NOWHERE') === false;\n@@ -29,7 +29,7 @@ class ZoneTest extends TestCase\n{\n$request = Request::createFromGlobals();\n- $this->assertSame('nowhere', Zone::getFromRequest($request));\n+ $this->assertSame('nowhere', RequestZone::getFromRequest($request));\n}\n/**\n@@ -39,9 +39,9 @@ class ZoneTest extends TestCase\n{\n$request = Request::createFromGlobals();\n- Zone::setToRequest($request, $constant);\n+ RequestZone::setToRequest($request, $constant);\n- $this->assertSame($constant, Zone::getFromRequest($request));\n- $this->assertTrue(Zone::is($request, $constant));\n+ $this->assertSame($constant, RequestZone::getFromRequest($request));\n+ $this->assertTrue(RequestZone::is($request, $constant));\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/php/WidgetsTest.php",
"new_path": "tests/php/WidgetsTest.php",
"diff": "@@ -7,7 +7,7 @@ namespace Bolt\\Tests;\nuse Bolt\\Snippet\\HtmlInjector;\nuse Bolt\\Snippet\\QueueProcessor;\nuse Bolt\\Snippet\\Target;\n-use Bolt\\Snippet\\Zone;\n+use Bolt\\Snippet\\RequestZone;\nuse Bolt\\Widget\\BoltHeaderWidget;\nuse Bolt\\Widget\\SnippetWidget;\nuse Bolt\\Widget\\WeatherWidget;\n@@ -79,7 +79,7 @@ class WidgetsTest extends TestCase\n$response = new Response('<html><body>foo</body></html>');\n$headerWidget = new BoltHeaderWidget();\n- $headerWidget->setZone(Zone::NOWHERE);\n+ $headerWidget->setZone(RequestZone::NOWHERE);\n$widgets->registerWidget($headerWidget);\n$widgets->processQueue($response);\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Refactor `Zone` to `RequestZone`.
|
95,144 |
19.04.2019 15:58:53
| -7,200 |
7a582e861d1eafc4068b76b2fdebd6a08611c2fe
|
remove registerBoltWidgets from Widgets class
|
[
{
"change_type": "MODIFY",
"old_path": "src/Controller/TwigAwareController.php",
"new_path": "src/Controller/TwigAwareController.php",
"diff": "@@ -6,7 +6,14 @@ namespace Bolt\\Controller;\nuse Bolt\\Configuration\\Config;\nuse Bolt\\Entity\\Field\\TemplateselectField;\n+use Bolt\\Snippet\\RequestZone;\n+use Bolt\\Snippet\\Target;\nuse Bolt\\Version;\n+use Bolt\\Widget\\BoltHeaderWidget;\n+use Bolt\\Widget\\CanonicalLinkWidget;\n+use Bolt\\Widget\\NewsWidget;\n+use Bolt\\Widget\\SnippetWidget;\n+use Bolt\\Widget\\WeatherWidget;\nuse Bolt\\Widgets;\nuse Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController;\nuse Symfony\\Component\\HttpFoundation\\Response;\n@@ -33,7 +40,7 @@ class TwigAwareController extends AbstractController\n$this->twig = $twig;\n$this->widgets = $widgets;\n- $this->widgets->registerBoltWidgets();\n+ $this->registerBoltWidgets();\n}\n/**\n@@ -80,4 +87,21 @@ class TwigAwareController extends AbstractController\n// Process the snippet Queue on the Response\nreturn $this->widgets->processQueue($response);\n}\n+\n+ public function registerBoltWidgets(): void\n+ {\n+ $this->widgets->registerWidget(new WeatherWidget());\n+ $this->widgets->registerWidget(new NewsWidget());\n+ $this->widgets->registerWidget(new CanonicalLinkWidget());\n+ $this->widgets->registerWidget(new BoltHeaderWidget());\n+\n+ $metaTagSnippet = new SnippetWidget(\n+ '<meta name=\"generator\" content=\"Bolt\">',\n+ 'Meta Generator tag snippet',\n+ Target::END_OF_HEAD,\n+ RequestZone::FRONTEND\n+ );\n+\n+ $this->widgets->registerWidget($metaTagSnippet);\n+ }\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widgets.php",
"new_path": "src/Widgets.php",
"diff": "@@ -6,20 +6,17 @@ namespace Bolt;\nuse Bolt\\Snippet\\QueueProcessor;\nuse Bolt\\Snippet\\RequestZone;\n-use Bolt\\Snippet\\Target;\n-use Bolt\\Widget\\BoltHeaderWidget;\n-use Bolt\\Widget\\CanonicalLinkWidget;\n-use Bolt\\Widget\\NewsWidget;\nuse Bolt\\Widget\\RequestAware;\n-use Bolt\\Widget\\SnippetWidget;\nuse Bolt\\Widget\\TwigAware;\n-use Bolt\\Widget\\WeatherWidget;\nuse Bolt\\Widget\\WidgetInterface;\nuse Symfony\\Component\\HttpFoundation\\RequestStack;\nuse Symfony\\Component\\HttpFoundation\\Response;\nuse Tightenco\\Collect\\Support\\Collection;\nuse Twig\\Environment;\n+/**\n+ * @todo Determine if we should split this up into smaller classes\n+ */\nclass Widgets\n{\n/** @var Collection */\n@@ -87,21 +84,4 @@ class Widgets\n$zone = RequestZone::getFromRequest($this->requestStack->getCurrentRequest());\nreturn $this->queueProcessor->process($response, $this->queue, $zone);\n}\n-\n- public function registerBoltWidgets(): void\n- {\n- $this->registerWidget(new WeatherWidget());\n- $this->registerWidget(new NewsWidget());\n- $this->registerWidget(new CanonicalLinkWidget());\n- $this->registerWidget(new BoltHeaderWidget());\n-\n- $metaTagSnippet = new SnippetWidget(\n- '<meta name=\"generator\" content=\"Bolt\">',\n- 'Meta Generator tag snippet',\n- Target::END_OF_HEAD,\n- RequestZone::FRONTEND\n- );\n-\n- $this->registerWidget($metaTagSnippet);\n- }\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
remove registerBoltWidgets from Widgets class
|
95,144 |
19.04.2019 16:01:49
| -7,200 |
89037e0a3f009378516a3e7e2881e9491535347a
|
Refactor `isFrontend` to `isForFrontend`, etc.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Snippet/RequestZone.php",
"new_path": "src/Snippet/RequestZone.php",
"diff": "@@ -24,7 +24,7 @@ class RequestZone\n/**\n* Check if request is for frontend routes.\n*/\n- public static function isFrontend(Request $request): bool\n+ public static function isForFrontend(Request $request): bool\n{\nreturn static::is($request, static::FRONTEND);\n}\n@@ -32,7 +32,7 @@ class RequestZone\n/**\n* Check if request is for backend routes.\n*/\n- public static function isBackend(Request $request): bool\n+ public static function isForBackend(Request $request): bool\n{\nreturn static::is($request, static::BACKEND);\n}\n@@ -40,7 +40,7 @@ class RequestZone\n/**\n* Check if request is for asynchronous/AJAX routes.\n*/\n- public static function isAsync(Request $request): bool\n+ public static function isForAsync(Request $request): bool\n{\nreturn static::is($request, static::ASYNC);\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Refactor `isFrontend` to `isForFrontend`, etc.
|
95,144 |
19.04.2019 18:35:29
| -7,200 |
053069868d6c176a8ffac9d3739efe92433d858d
|
Move Response to its own interface
|
[
{
"change_type": "MODIFY",
"old_path": "src/Snippet/HtmlInjector.php",
"new_path": "src/Snippet/HtmlInjector.php",
"diff": "@@ -5,6 +5,7 @@ declare(strict_types=1);\nnamespace Bolt\\Snippet;\nuse Bolt\\Common\\Str;\n+use Bolt\\Widget\\ResponseAware;\nuse Bolt\\Widget\\WidgetInterface;\nuse Symfony\\Component\\HttpFoundation\\Response;\n@@ -58,7 +59,9 @@ class HtmlInjector\n$functionMap = $this->getMap();\n$target = $widget->getTarget();\n+ if ($widget instanceof ResponseAware) {\n$widget->setResponse($response);\n+ }\n$output = $widget();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/BoltHeaderWidget.php",
"new_path": "src/Widget/BoltHeaderWidget.php",
"diff": "@@ -7,7 +7,7 @@ namespace Bolt\\Widget;\nuse Bolt\\Snippet\\RequestZone;\nuse Bolt\\Snippet\\Target;\n-class BoltHeaderWidget extends BaseWidget\n+class BoltHeaderWidget extends BaseWidget implements ResponseAware\n{\nprotected $name = 'Bolt Header Widget';\nprotected $type = 'snippet';\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Widget/ResponseAware.php",
"diff": "+<?php\n+\n+declare(strict_types=1);\n+\n+namespace Bolt\\Widget;\n+\n+use Symfony\\Component\\HttpFoundation\\Response;\n+\n+/**\n+ * Interface ResponseAware - Widgets that make use of the Response to provide\n+ * their functionality need to implement this interface.\n+ */\n+interface ResponseAware\n+{\n+ public function setResponse(?Response $response = null): WidgetInterface;\n+\n+ public function getResponse(): ?Response;\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/WidgetInterface.php",
"new_path": "src/Widget/WidgetInterface.php",
"diff": "@@ -4,8 +4,6 @@ declare(strict_types=1);\nnamespace Bolt\\Widget;\n-use Symfony\\Component\\HttpFoundation\\Response;\n-\ninterface WidgetInterface\n{\npublic function getName(): string;\n@@ -18,10 +16,6 @@ interface WidgetInterface\npublic function getTemplate(): string;\n- public function setResponse(?Response $response = null): self;\n-\n- public function getResponse(): ?Response;\n-\npublic function getZone(): string;\npublic function getSlug(): string;\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Move Response to its own interface
|
95,144 |
19.04.2019 18:37:32
| -7,200 |
bb51dfccfa2c610516571f6bb776f4099f3e9cf9
|
Have widgets 'get' the Request just before being invoked.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Widgets.php",
"new_path": "src/Widgets.php",
"diff": "@@ -41,9 +41,6 @@ class Widgets\npublic function registerWidget(WidgetInterface $widget): void\n{\n- if ($widget instanceof RequestAware) {\n- $widget->setRequest($this->requestStack->getCurrentRequest());\n- }\nif ($widget instanceof TwigAware) {\n$widget->setTwig($this->twig);\n}\n@@ -58,6 +55,10 @@ class Widgets\n})->first();\nif ($widget) {\n+ if ($widget instanceof RequestAware) {\n+ $widget->setRequest($this->requestStack->getCurrentRequest());\n+ }\n+\nreturn $widget();\n}\n}\n@@ -73,6 +74,10 @@ class Widgets\n$output = '';\nforeach ($widgets as $widget) {\n+ if ($widget instanceof RequestAware) {\n+ $widget->setRequest($this->requestStack->getCurrentRequest());\n+ }\n+\n$output .= $widget();\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Have widgets 'get' the Request just before being invoked.
|
95,144 |
19.04.2019 18:53:00
| -7,200 |
4bc744eb24bb4bc3798a00469244ae17fb3983a4
|
Move `registerBoltWidgets` to a subscriber.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Controller/TwigAwareController.php",
"new_path": "src/Controller/TwigAwareController.php",
"diff": "@@ -6,14 +6,7 @@ namespace Bolt\\Controller;\nuse Bolt\\Configuration\\Config;\nuse Bolt\\Entity\\Field\\TemplateselectField;\n-use Bolt\\Snippet\\RequestZone;\n-use Bolt\\Snippet\\Target;\nuse Bolt\\Version;\n-use Bolt\\Widget\\BoltHeaderWidget;\n-use Bolt\\Widget\\CanonicalLinkWidget;\n-use Bolt\\Widget\\NewsWidget;\n-use Bolt\\Widget\\SnippetWidget;\n-use Bolt\\Widget\\WeatherWidget;\nuse Bolt\\Widgets;\nuse Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController;\nuse Symfony\\Component\\HttpFoundation\\Response;\n@@ -39,8 +32,6 @@ class TwigAwareController extends AbstractController\n$this->config = $config;\n$this->twig = $twig;\n$this->widgets = $widgets;\n-\n- $this->registerBoltWidgets();\n}\n/**\n@@ -87,21 +78,4 @@ class TwigAwareController extends AbstractController\n// Process the snippet Queue on the Response\nreturn $this->widgets->processQueue($response);\n}\n-\n- public function registerBoltWidgets(): void\n- {\n- $this->widgets->registerWidget(new WeatherWidget());\n- $this->widgets->registerWidget(new NewsWidget());\n- $this->widgets->registerWidget(new CanonicalLinkWidget());\n- $this->widgets->registerWidget(new BoltHeaderWidget());\n-\n- $metaTagSnippet = new SnippetWidget(\n- '<meta name=\"generator\" content=\"Bolt\">',\n- 'Meta Generator tag snippet',\n- Target::END_OF_HEAD,\n- RequestZone::FRONTEND\n- );\n-\n- $this->widgets->registerWidget($metaTagSnippet);\n- }\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/EventSubscriber/WidgetsSubscriber.php",
"diff": "+<?php\n+\n+declare(strict_types=1);\n+\n+namespace Bolt\\EventSubscriber;\n+\n+use Bolt\\Snippet\\RequestZone;\n+use Bolt\\Snippet\\Target;\n+use Bolt\\Widget\\BoltHeaderWidget;\n+use Bolt\\Widget\\CanonicalLinkWidget;\n+use Bolt\\Widget\\NewsWidget;\n+use Bolt\\Widget\\SnippetWidget;\n+use Bolt\\Widget\\WeatherWidget;\n+use Bolt\\Widgets;\n+use Symfony\\Component\\EventDispatcher\\EventSubscriberInterface;\n+use Symfony\\Component\\HttpFoundation\\Request;\n+use Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent;\n+use Symfony\\Component\\HttpKernel\\KernelEvents;\n+\n+class WidgetsSubscriber implements EventSubscriberInterface\n+{\n+ public const PRIORITY = 100;\n+\n+ /** @var Widgets */\n+ private $widgets;\n+\n+ public function __construct(Widgets $widgets)\n+ {\n+ $this->widgets = $widgets;\n+ }\n+\n+ /**\n+ * Kernel request listener callback.\n+ */\n+ public function onKernelRequest(GetResponseEvent $event): void\n+ {\n+ $this->widgets->registerWidget(new WeatherWidget());\n+ $this->widgets->registerWidget(new NewsWidget());\n+ $this->widgets->registerWidget(new CanonicalLinkWidget());\n+ $this->widgets->registerWidget(new BoltHeaderWidget());\n+\n+ $metaTagSnippet = new SnippetWidget(\n+ '<meta name=\"generator\" content=\"Bolt\">',\n+ 'Meta Generator tag snippet',\n+ Target::END_OF_HEAD,\n+ RequestZone::FRONTEND\n+ );\n+\n+ $this->widgets->registerWidget($metaTagSnippet);\n+ }\n+\n+ /**\n+ * Return the events to subscribe to.\n+ */\n+ public static function getSubscribedEvents(): array\n+ {\n+ return [\n+ KernelEvents::REQUEST => [['onKernelRequest', self::PRIORITY]],\n+ ];\n+ }\n+}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Move `registerBoltWidgets` to a subscriber.
|
95,144 |
19.04.2019 21:27:16
| -7,200 |
0a837a0760bd94ac3a06a5b4dc456f338dfc92f6
|
Periodical NPM cleanup
|
[
{
"change_type": "MODIFY",
"old_path": ".gitignore",
"new_path": ".gitignore",
"diff": "@@ -12,6 +12,7 @@ assets/vendor/\nnode_modules/\nnpm-debug.log\nyarn-error.log\n+webpack_stats.json\n### File-system cruft and temporary files\n__*\n@@ -65,6 +66,7 @@ appveyor.yml\n/public/bundles/\n/vendor/\n###< symfony/framework-bundle ###\n+\n###> symfony/web-server-bundle ###\n/.web-server-pid\n###< symfony/web-server-bundle ###\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"url\": \"git://github.com/bolt/four.git\"\n},\n\"dependencies\": {\n- \"@babel/polyfill\": \"^7.4.0\",\n- \"@vue/cli-service\": \"^3.5.3\",\n+ \"@babel/polyfill\": \"^7.4.3\",\n+ \"@vue/cli-service\": \"^3.6.0\",\n\"axios\": \"^0.18.0\",\n\"baguettebox.js\": \"^1.11.0\",\n\"bootstrap\": \"^4.3.1\",\n\"codemirror\": \"^5.45.0\",\n\"flagpack\": \"^1.0.3\",\n- \"jquery\": \"^3.3.1\",\n+ \"jquery\": \"^3.4.0\",\n\"moment\": \"^2.24.0\",\n\"no-scroll\": \"^2.1.1\",\n- \"popper.js\": \"^1.14.7\",\n+ \"popper.js\": \"^1.15.0\",\n\"register-service-worker\": \"^1.6.2\",\n\"simplemde\": \"^1.11.2\",\n- \"stylelint-config-recommended-scss\": \"^3.2.0\",\n- \"stylelint-scss\": \"^3.5.4\",\n+ \"stylelint-config-recommended-scss\": \"^3.3.0\",\n+ \"stylelint-scss\": \"^3.6.0\",\n\"terser\": \"^3.17.0\",\n\"tinycolor2\": \"^1.4.1\",\n\"vue\": \"^2.6.10\",\n\"vuex\": \"^3.1.0\"\n},\n\"devDependencies\": {\n- \"@babel/core\": \"^7.4.0\",\n- \"@babel/plugin-transform-regenerator\": \"^7.4.0\",\n- \"@babel/plugin-transform-runtime\": \"^7.4.0\",\n- \"@babel/polyfill\": \"^7.4.0\",\n- \"@babel/preset-env\": \"^7.4.2\",\n- \"@symfony/webpack-encore\": \"^0.26.0\",\n+ \"@babel/core\": \"^7.4.3\",\n+ \"@babel/plugin-transform-regenerator\": \"^7.4.3\",\n+ \"@babel/plugin-transform-runtime\": \"^7.4.3\",\n+ \"@babel/polyfill\": \"^7.4.3\",\n+ \"@babel/preset-env\": \"^7.4.3\",\n+ \"@symfony/webpack-encore\": \"^0.27.0\",\n\"@vue/test-utils\": \"^1.0.0-beta.29\",\n\"ajv-keywords\": \"^3.4.0\",\n- \"autoprefixer\": \"^9.5.0\",\n+ \"autoprefixer\": \"^9.5.1\",\n\"babel-core\": \"^7.0.0-bridge.0\",\n\"babel-eslint\": \"^10.0.1\",\n- \"babel-jest\": \"^24.5.0\",\n- \"eslint\": \"^5.15.3\",\n+ \"babel-jest\": \"^24.7.1\",\n+ \"eslint\": \"^5.16.0\",\n\"eslint-config-prettier\": \"^4.1.0\",\n\"eslint-plugin-prettier\": \"^3.0.1\",\n\"eslint-plugin-standard\": \"^4.0.0\",\n\"eslint-plugin-vue\": \"^5.2.2\",\n- \"jest\": \"^24.5.0\",\n+ \"jest\": \"^24.7.1\",\n\"jest-serializer-vue\": \"^2.0.2\",\n\"node-sass\": \"^4.11.0\",\n\"postcss-loader\": \"^3.0.0\",\n\"postcss-preset-env\": \"^6.6.0\",\n- \"prettier\": \"^1.16.4\",\n+ \"prettier\": \"^1.17.0\",\n\"regenerator-runtime\": \"^0.13.2\",\n\"sass-loader\": \"^7.1.0\",\n- \"stylelint\": \"^9.10.1\",\n- \"stylelint-config-standard\": \"^18.2.0\",\n+ \"stylelint\": \"^10.0.1\",\n+ \"stylelint-config-standard\": \"^18.3.0\",\n\"vue-jest\": \"^3.0.4\",\n\"vue-loader\": \"^15.7.0\",\n- \"vue-router\": \"^3.0.2\",\n+ \"vue-router\": \"^3.0.6\",\n\"vue-template-compiler\": \"^2.6.10\",\n- \"webpackbar\": \"^3.1.5\",\n- \"workbox-webpack-plugin\": \"^4.1.1\"\n+ \"webpackbar\": \"^3.2.0\",\n+ \"workbox-webpack-plugin\": \"^4.3.0\"\n},\n\"scripts\": {\n\"start\": \"encore dev-server --port=8234 --progress --disable-host-check --verbose\",\n\"build\": \"encore production --progress\",\n+ \"build:stats\": \"encore production --progress --json > webpack_stats.json\",\n\"serve\": \"encore dev --watch\",\n\"lint\": \"eslint --ext .js,.vue, assets\",\n\"lint-fix\": \"eslint --ext .js,.vue, assets --fix\",\n"
},
{
"change_type": "MODIFY",
"old_path": "webpack.config.js",
"new_path": "webpack.config.js",
"diff": "@@ -15,16 +15,11 @@ Encore.addPlugin(\n.copyFiles({\nfrom: './assets/static',\n})\n- .copyFiles({\n- from: './node_modules/flagpack/flags',\n- to: 'icons/flags/[name].[ext]',\n- pattern: /\\.(svg)$/,\n- })\n.cleanupOutputBeforeBuild()\n.disableSingleRuntimeChunk()\n.enableSourceMaps(!Encore.isProduction())\n- .enableVersioning(Encore.isProduction())\n+ .enableVersioning(false)\n.addEntry('bolt', './assets/js/bolt.js')\n.addStyleEntry('theme-default', './assets/scss/themes/default.scss')\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Periodical NPM cleanup
|
95,144 |
20.04.2019 10:33:02
| -7,200 |
db9c9aab63d33791cb78f5e550e3a9783555c9c3
|
Add `ProcessWidgetsQueueSubscriber` for Response
|
[
{
"change_type": "MODIFY",
"old_path": "src/Controller/TwigAwareController.php",
"new_path": "src/Controller/TwigAwareController.php",
"diff": "@@ -7,7 +7,6 @@ namespace Bolt\\Controller;\nuse Bolt\\Configuration\\Config;\nuse Bolt\\Entity\\Field\\TemplateselectField;\nuse Bolt\\Version;\n-use Bolt\\Widgets;\nuse Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController;\nuse Symfony\\Component\\HttpFoundation\\Response;\nuse Tightenco\\Collect\\Support\\Collection;\n@@ -21,17 +20,13 @@ class TwigAwareController extends AbstractController\n/** @var Environment */\nprotected $twig;\n- /** @var Widgets */\n- private $widgets;\n-\n/**\n* @required\n*/\n- public function setAutowire(Config $config, Environment $twig, Widgets $widgets): void\n+ public function setAutowire(Config $config, Environment $twig): void\n{\n$this->config = $config;\n$this->twig = $twig;\n- $this->widgets = $widgets;\n}\n/**\n@@ -75,7 +70,6 @@ class TwigAwareController extends AbstractController\n}\n$response->setContent($content);\n- // Process the snippet Queue on the Response\n- return $this->widgets->processQueue($response);\n+ return $response;\n}\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/EventSubscriber/ProcessWidgetsQueueSubscriber.php",
"diff": "+<?php\n+\n+declare(strict_types=1);\n+\n+namespace Bolt\\EventSubscriber;\n+\n+use Bolt\\Widgets;\n+use Symfony\\Component\\EventDispatcher\\EventSubscriberInterface;\n+use Symfony\\Component\\HttpFoundation\\Request;\n+use Symfony\\Component\\HttpKernel\\Event\\FilterResponseEvent;\n+use Symfony\\Component\\HttpKernel\\KernelEvents;\n+\n+class ProcessWidgetsQueueSubscriber implements EventSubscriberInterface\n+{\n+ public const PRIORITY = 0;\n+\n+ /** @var Widgets */\n+ private $widgets;\n+\n+ public function __construct(Widgets $widgets)\n+ {\n+ $this->widgets = $widgets;\n+ }\n+\n+ /**\n+ * Kernel response listener callback.\n+ */\n+ public function onKernelResponse(FilterResponseEvent $event): void\n+ {\n+ $response = $event->getResponse();\n+\n+ $this->widgets->processQueue($response);\n+ }\n+\n+ /**\n+ * Return the events to subscribe to.\n+ */\n+ public static function getSubscribedEvents(): array\n+ {\n+ return [\n+ KernelEvents::RESPONSE => [['onKernelResponse', self::PRIORITY]],\n+ ];\n+ }\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/ResponseAware.php",
"new_path": "src/Widget/ResponseAware.php",
"diff": "@@ -12,7 +12,7 @@ use Symfony\\Component\\HttpFoundation\\Response;\n*/\ninterface ResponseAware\n{\n- public function setResponse(?Response $response = null): WidgetInterface;\n+ public function setResponse(Response $response): WidgetInterface;\npublic function getResponse(): ?Response;\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Add `ProcessWidgetsQueueSubscriber` for Response
|
95,144 |
21.04.2019 09:53:57
| -7,200 |
5ba52998d263239ba697355c9abed6d7f0c462aa
|
Make widgets pass along extra parameters
|
[
{
"change_type": "MODIFY",
"old_path": "src/EventSubscriber/ProcessWidgetsQueueSubscriber.php",
"new_path": "src/EventSubscriber/ProcessWidgetsQueueSubscriber.php",
"diff": "@@ -6,7 +6,6 @@ namespace Bolt\\EventSubscriber;\nuse Bolt\\Widgets;\nuse Symfony\\Component\\EventDispatcher\\EventSubscriberInterface;\n-use Symfony\\Component\\HttpFoundation\\Request;\nuse Symfony\\Component\\HttpKernel\\Event\\FilterResponseEvent;\nuse Symfony\\Component\\HttpKernel\\KernelEvents;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Twig/WidgetExtension.php",
"new_path": "src/Twig/WidgetExtension.php",
"diff": "@@ -38,12 +38,12 @@ class WidgetExtension extends AbstractExtension\npublic function renderWidgetByName(string $name): string\n{\n- return $this->widgetRenderer->renderWidgetByName($name);\n+ return $this->widgetRenderer->renderWidgetByName($name, func_get_args());\n}\npublic function renderWidgetsForTarget(string $target): string\n{\n- return $this->widgetRenderer->renderWidgetsForTarget($target);\n+ return $this->widgetRenderer->renderWidgetsForTarget($target, func_get_args());\n}\npublic function dummy($input = null): string\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/BaseWidget.php",
"new_path": "src/Widget/BaseWidget.php",
"diff": "@@ -18,7 +18,6 @@ class BaseWidget implements WidgetInterface\nprotected $target = Target::NOWHERE;\nprotected $zone = RequestZone::EVERYWHERE;\nprotected $priority = 0;\n- protected $context = [];\n/** @var string */\nprotected $template;\n@@ -84,16 +83,16 @@ class BaseWidget implements WidgetInterface\nreturn $this->priority;\n}\n- public function __invoke(?string $template = null): string\n+ public function __invoke(array $params = []): string\n{\n- if ($template === null) {\n- $template = $this->template;\n+ if (array_key_exists('template', $params)) {\n+ $this->template = $params['template'];\n}\nif ($this instanceof TwigAware) {\n- $output = $this->twig->render($template, $this->context);\n+ $output = $this->twig->render($this->template, $params);\n} else {\n- $output = $template;\n+ $output = $this->template;\n}\nreturn sprintf(\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/BoltHeaderWidget.php",
"new_path": "src/Widget/BoltHeaderWidget.php",
"diff": "@@ -14,7 +14,7 @@ class BoltHeaderWidget extends BaseWidget implements ResponseAware\nprotected $target = Target::NOWHERE;\nprotected $zone = RequestZone::FRONTEND;\n- public function __invoke(?string $template = null): string\n+ public function __invoke(array $params = []): string\n{\n$this->getResponse()->headers->set('X-Powered-By', 'Bolt', false);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/NewsWidget.php",
"new_path": "src/Widget/NewsWidget.php",
"diff": "@@ -19,13 +19,13 @@ class NewsWidget extends BaseWidget implements TwigAware, RequestAware\nprotected $priority = 150;\nprotected $template = '@bolt/widgets/news.twig';\n- public function __invoke(?string $template = null): string\n+ public function __invoke(array $params = []): string\n{\n$news = $this->getNews();\n$currentItem = $news['information'];\n- $this->context = [\n+ $context = [\n'title' => $currentItem['title'],\n'news' => $currentItem['teaser'],\n'link' => $currentItem['link'],\n@@ -33,7 +33,7 @@ class NewsWidget extends BaseWidget implements TwigAware, RequestAware\n'datefetched' => '2019-04-04 07:25:00',\n];\n- return parent::__invoke($template);\n+ return parent::__invoke($context);\n}\n/**\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/SnippetWidget.php",
"new_path": "src/Widget/SnippetWidget.php",
"diff": "@@ -27,7 +27,7 @@ class SnippetWidget extends BaseWidget\n$this->zone = $zone;\n}\n- public function __invoke(?string $template = null): string\n+ public function __invoke(array $params = []): string\n{\nreturn $this->getTemplate();\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widget/WidgetInterface.php",
"new_path": "src/Widget/WidgetInterface.php",
"diff": "@@ -26,5 +26,5 @@ interface WidgetInterface\npublic function getSlug(): string;\n- public function __invoke(?string $template = null): string;\n+ public function __invoke(array $params = []): string;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Widgets.php",
"new_path": "src/Widgets.php",
"diff": "@@ -48,7 +48,7 @@ class Widgets\n$this->queue->push($widget);\n}\n- public function renderWidgetByName(string $name): string\n+ public function renderWidgetByName(string $name, array $params = []): string\n{\n$widget = $this->queue->filter(function (WidgetInterface $widget) use ($name) {\nreturn $widget->getName() === $name;\n@@ -59,11 +59,11 @@ class Widgets\n$widget->setRequest($this->requestStack->getCurrentRequest());\n}\n- return $widget();\n+ return $widget($params);\n}\n}\n- public function renderWidgetsForTarget(string $target): string\n+ public function renderWidgetsForTarget(string $target, array $params = []): string\n{\n$widgets = $this->queue->filter(function (WidgetInterface $widget) use ($target) {\nreturn $widget->getTarget() === $target;\n@@ -78,7 +78,7 @@ class Widgets\n$widget->setRequest($this->requestStack->getCurrentRequest());\n}\n- $output .= $widget();\n+ $output .= $widget($params);\n}\nreturn $output;\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/php/WidgetsTest.php",
"new_path": "tests/php/WidgetsTest.php",
"diff": "@@ -65,6 +65,29 @@ class WidgetsTest extends TestCase\n);\n}\n+\n+ public function testRenderWidgetWithExtraParameters(): void\n+ {\n+ $queueprocessor = new QueueProcessor(new HtmlInjector());\n+ $requestStack = new RequestStack();\n+ $requestStack->push(Request::createFromGlobals());\n+\n+ $loader = new ArrayLoader(['weather.twig' => '[Hello, {{ foo }}!]']);\n+ $twig = new Environment($loader);\n+\n+ $widgets = new Widgets($requestStack, $queueprocessor, $twig);\n+\n+ $weatherWidget = new WeatherWidget();\n+ $weatherWidget->setTemplate('weather.twig');\n+\n+ $widgets->registerWidget($weatherWidget);\n+\n+ $this->assertSame(\n+ '<div id=\"widget-weather-widget\" name=\"Weather Widget\">[Hello, Bar!]</div>',\n+ $widgets->renderWidgetByName('Weather Widget', ['foo' => 'Bar'])\n+ );\n+ }\n+\npublic function testProcessHeaderWidget(): void\n{\n$queueprocessor = new QueueProcessor(new HtmlInjector());\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Make widgets pass along extra parameters
|
95,144 |
21.04.2019 09:58:21
| -7,200 |
2a3605891b36f3280fd72878ec8cb228c5f9e816
|
Correctly pass $params
|
[
{
"change_type": "MODIFY",
"old_path": "src/Twig/WidgetExtension.php",
"new_path": "src/Twig/WidgetExtension.php",
"diff": "@@ -36,14 +36,14 @@ class WidgetExtension extends AbstractExtension\n];\n}\n- public function renderWidgetByName(string $name): string\n+ public function renderWidgetByName(string $name, array $params = []): string\n{\n- return $this->widgetRenderer->renderWidgetByName($name, func_get_args());\n+ return $this->widgetRenderer->renderWidgetByName($name, $params);\n}\n- public function renderWidgetsForTarget(string $target): string\n+ public function renderWidgetsForTarget(string $target, array $params = []): string\n{\n- return $this->widgetRenderer->renderWidgetsForTarget($target, func_get_args());\n+ return $this->widgetRenderer->renderWidgetsForTarget($target, $params);\n}\npublic function dummy($input = null): string\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Correctly pass $params
|
95,144 |
21.04.2019 10:45:54
| -7,200 |
5793bf49af2862c0f380310a5bf3f7a0fb3103f5
|
Don't modify StreamedResponse
|
[
{
"change_type": "MODIFY",
"old_path": "src/Snippet/HtmlInjector.php",
"new_path": "src/Snippet/HtmlInjector.php",
"diff": "@@ -8,6 +8,7 @@ use Bolt\\Common\\Str;\nuse Bolt\\Widget\\ResponseAware;\nuse Bolt\\Widget\\WidgetInterface;\nuse Symfony\\Component\\HttpFoundation\\Response;\n+use Symfony\\Component\\HttpFoundation\\StreamedResponse;\n/**\n* Class for matching HTML elements and injecting text.\n@@ -59,6 +60,11 @@ class HtmlInjector\n$functionMap = $this->getMap();\n$target = $widget->getTarget();\n+ // Don't try to modify the response body for streamed responses. Stuff will break, if we do.\n+ if ($response instanceof StreamedResponse) {\n+ return;\n+ }\n+\nif ($widget instanceof ResponseAware) {\n$widget->setResponse($response);\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Don't modify StreamedResponse
|
95,144 |
21.04.2019 13:33:01
| -7,200 |
bf62708f663f0891da9a552cf6e4bdebb6549ab3
|
Only use config if set
|
[
{
"change_type": "MODIFY",
"old_path": "templates/_base/layout.html.twig",
"new_path": "templates/_base/layout.html.twig",
"diff": "}|json_encode %}\n<admin-toolbar\n- site-name=\"{{ config.get('general/sitename') }}\"\n+ site-name=\"{% if config is defined %}{{ config.get('general/sitename') }}{% endif %}\"\n:menu=\"{{ admin_menu_json }}\"\nuser=\"{{ user|default }}\"\n:labels=\"{{ labels }}\"\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Only use config if set
|
95,144 |
21.04.2019 13:51:05
| -7,200 |
1e86cc00eb37ba9a71f642be27089c5d517d4a7f
|
Add e2e test for API and Translations
|
[
{
"change_type": "ADD",
"old_path": null,
"new_path": "tests/e2e/features/backend_api.feature",
"diff": "+Feature: Visiting Dashboard\n+\n+ Scenario: As an admin I want to see API page\n+ Given I am logged in as \"admin\"\n+ When I visit the \"backend_api\" page\n+ Then there is element \"header\" with text \"Bolt API\"\n+\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "tests/e2e/features/backend_translations.feature",
"diff": "+Feature: Visiting Translations page\n+\n+ Scenario: As an admin I want to see API page\n+ Given I am logged in as \"admin\"\n+ When I visit the \"backend_translations\" page\n+ Then there is element \"header\" with text \"Edit Translations\"\n+\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/e2e/features/frontend_menu.feature",
"new_path": "tests/e2e/features/frontend_menu.feature",
"diff": "@@ -6,7 +6,6 @@ Feature: Frontend menu\nAnd there is element \"menu_last\" with text \"The Bolt site\"\nAnd there are \"eq 4\" \"menu_sub\" elements\n- @wip\nScenario: As a user I want to see the multi-level in the frontend\nWhen I visit the \"single_test\" page with parameters:\n| slug | title-of-the-test |\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "tests/e2e/pages/backend_api.js",
"diff": "+const { BasePage } = require('kakunin');\n+\n+class BackendApiPage extends BasePage {\n+ constructor() {\n+ super();\n+\n+ this.url = '/bolt/api';\n+\n+ this.header = $('.admin__header--title strong');\n+ }\n+}\n+\n+module.exports = BackendApiPage;\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "tests/e2e/pages/backend_translations.js",
"diff": "+const { BasePage } = require('kakunin');\n+\n+class BackendTranslationsPage extends BasePage {\n+ constructor() {\n+ super();\n+\n+ this.url = '/bolt/_trans';\n+\n+ this.header = $('.admin__header--title');\n+ }\n+}\n+\n+module.exports = BackendTranslationsPage;\n\\ No newline at end of file\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Add e2e test for API and Translations
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.