From 2e66b4094dc80940db89e052efc14d6878e9403d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 17 Dec 2020 11:47:51 +0100 Subject: [PATCH 1/3] Various typo fixes --- docs/docs/05_Database/2_Doctrine Migrations.md | 10 +++++----- docs/docs/07_i18n/2_API.md | 2 +- docs/docs/08_Security/2_Authentication.md | 4 ++-- docs/docs/08_Security/3_Access Control.md | 4 ++-- src/api/README.md | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/docs/05_Database/2_Doctrine Migrations.md b/docs/docs/05_Database/2_Doctrine Migrations.md index 7de37b39..66886a56 100644 --- a/docs/docs/05_Database/2_Doctrine Migrations.md +++ b/docs/docs/05_Database/2_Doctrine Migrations.md @@ -35,7 +35,7 @@ public function getDescription() : string } ``` -And throw the following exception the `down` method: +And throw the following exception in the `down` method: ```php public function down(Schema $schema) : void @@ -82,7 +82,7 @@ a new migration. :::note -📣  You should **only** do that if a remote environment like your production did not already apply the migration. +📣  **Do not** edit a migration if a remote environment like your production did apply the migration. ::: @@ -110,7 +110,7 @@ php bin/console doctrine:migrations:migrate -n :::note -📣  Reminder: you should **only** do that if a remote environment like your production did not already -apply the migration. +📣  Reminder: **Do not** edit a migration if a remote environment like your production did apply the migration. -::: \ No newline at end of file + +::: diff --git a/docs/docs/07_i18n/2_API.md b/docs/docs/07_i18n/2_API.md index 15732fb6..9aa7a865 100644 --- a/docs/docs/07_i18n/2_API.md +++ b/docs/docs/07_i18n/2_API.md @@ -152,7 +152,7 @@ Let's take a look at the `CreateXLSXExport` use case: public function create(string $locale, array $headerIds, array $values): Xlsx ``` -The method `create` takes, among other arguments, a locale. It will use it to translates the spreadsheet's headers +The method `create` takes, among other arguments, a locale. It will use it to translate the spreadsheet's headers accordingly. For values, you should translate them directly in your use cases before calling the `create` method. diff --git a/docs/docs/08_Security/2_Authentication.md b/docs/docs/08_Security/2_Authentication.md index 9596ae05..20f7db2d 100644 --- a/docs/docs/08_Security/2_Authentication.md +++ b/docs/docs/08_Security/2_Authentication.md @@ -73,7 +73,7 @@ We initialize these values with empty strings or `null` for the profile picture. **Getters:** *src/webapp/store/auth/getters.js* -* `isAuthenticated`: it returns `true` if the `user`'s `email` property from the state is empty. It might return `true` +* `isAuthenticated`: it returns `true` if the `user`'s `email` property from the state is not empty. It might return `true` even if the user has no more session in the API, but we will see below how to handle such a case. * `isGranted`: it returns `true` if the user has the authorization level of the given role. @@ -124,4 +124,4 @@ there is an `nuxtServerInit` method, which Nuxt.js calls before server-rendering In this function, we: 1. Set the header `Cookie` for every server-side GraphQL requests. -2. Call the `me` action to fetch (or not) the user data (useful when the user refreshes the page). \ No newline at end of file +2. Call the `me` action to fetch (or not) the user data (useful when the user refreshes the page). diff --git a/docs/docs/08_Security/3_Access Control.md b/docs/docs/08_Security/3_Access Control.md index 80922a04..e2379af7 100644 --- a/docs/docs/08_Security/3_Access Control.md +++ b/docs/docs/08_Security/3_Access Control.md @@ -221,7 +221,7 @@ It comes in two parts: #### GraphQL -For instance, let's examine the following scenario: an administrator can delete a user, but only not if he is that user: +For instance, let's examine the following scenario: an administrator can delete a user, but cannot delete himself: ```php title="src/api/src/UseCase/Product/UpdateProduct.php" use TheCodingMachine\GraphQLite\Annotations\Logged; @@ -354,4 +354,4 @@ use the *src/webapp/middleware/redirect-if-not- authenticated.js* middleware to export default { middleware: ['redirect-if-not-authenticated'], } -``` \ No newline at end of file +``` diff --git a/src/api/README.md b/src/api/README.md index 30043135..124848b3 100644 --- a/src/api/README.md +++ b/src/api/README.md @@ -66,7 +66,7 @@ public function getDescription() : string } ``` -And throw the following exception the `down` method: +And throw the following exception in the `down` method: ```php public function down(Schema $schema) : void @@ -115,4 +115,4 @@ php bin/console app:fixtures:dev It uses the class [AppFixtures.php](src/Infrastructure/Fixtures/AppFixtures.php) for that task. -You should edit according to your needs. \ No newline at end of file +You should edit according to your needs. From 809dd9af66831bf4981078e41a71f8d9abe1fb2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 17 Dec 2020 11:50:40 +0100 Subject: [PATCH 2/3] Making sure the tmp file is removed. If an exception arise, the tmp file might not be removed. By using a finally block, we make sure we can remove this file, whatever happens. --- docs/docs/09_Files/2_Temporary Files.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/docs/docs/09_Files/2_Temporary Files.md b/docs/docs/09_Files/2_Temporary Files.md index 948c954d..62b5a5d9 100644 --- a/docs/docs/09_Files/2_Temporary Files.md +++ b/docs/docs/09_Files/2_Temporary Files.md @@ -16,14 +16,19 @@ use function Safe\unlink; protected function createResponseWithXLSXAttachment(string $filename, Xlsx $xlsx): Response { - $tmpFilename = Uuid::uuid4()->toString() . '.xlsx'; - $xlsx->save($tmpFilename); - $fileContent = file_get_contents($tmpFilename); // Get the file content. - unlink($tmpFilename); // Delete the file. - + try { + $tmpFilename = Uuid::uuid4()->toString() . '.xlsx'; + $xlsx->save($tmpFilename); + $fileContent = file_get_contents($tmpFilename); // Get the file content. + } finally { + if (file_exists($tmpFilename)) { + unlink($tmpFilename); // Delete the file. + } + } + return $this->createResponseWithAttachment( $filename, $fileContent ); } -``` \ No newline at end of file +``` From 6826d3ac56028bbcfd79d51722a11e406b7d2935 Mon Sep 17 00:00:00 2001 From: Julien Neuhart Date: Thu, 17 Dec 2020 16:21:38 +0100 Subject: [PATCH 3/3] Fix Docker image in CI/CD example --- docs/docs/16_Deployments/3_CICD.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/16_Deployments/3_CICD.md b/docs/docs/16_Deployments/3_CICD.md index 7847d972..434c901c 100644 --- a/docs/docs/16_Deployments/3_CICD.md +++ b/docs/docs/16_Deployments/3_CICD.md @@ -16,7 +16,7 @@ stages: api_tests: stage: tests - image: thecodingmachine/php:7.4-v3-apache + image: thecodingmachine/php:7.4-v3-cli services: - name: mysql:8.0 command: ["--default-authentication-plugin=mysql_native_password"] @@ -141,4 +141,4 @@ webapp_build_push_docker_image_prod: variables: NUXTJS_ENV_CONTENT: "$NUXTJS_ENV_CONTENT_PROD" # .env file content for prod (from GitLab CI/CD variables). ENV_NAME: "prod" -``` \ No newline at end of file +```