{"action":"created","comment":{"url":"https://api.github.com/repos/akeneo/pim-docs/pulls/comments/203286898","pull_request_review_id":138143860,"id":203286898,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMzI4Njg5OA==","diff_hunk":"@@ -67,48 +61,113 @@ Create a Notification Factory\n         }\n     }\n \n-Adding a route will redirect users to this route when the notification is clicked.\n+Let's take a look at what's important here, the ``create`` method of this factory:\n \n-For example, the route of the show export profile page is:\n+.. code-block:: php\n \n-.. code-block:: yaml\n+    public function create($object)\n+    {\n+        $notification = new Notification();\n \n-    pim_importexport_export_profile_show:\n-        path: /{id}\n-        defaults: { _controller: pim_import_export.controller.export_profile:showAction }\n-        requirements:\n-            id: \\d+\n+        $notification->setType($type);\n+        $notification->setMessage($message);\n+        $notification->setMessageParams($messageParams);\n+        $notification->setRoute($route);\n+        $notification->setRouteParams($routeParams);\n+        $notification->setContext($context);\n \n-The optional route parameter will be:\n+        return $notification;\n+    }\n \n-.. code-block:: php\n+Note that ``$object`` is ``mixed``, so feel free to give anything useful to build your notification. For instance, in our internal job notifications, we directly send the JobExecution to the ``create`` method of our Notification Factories.\n+\n+\n+1) Type (``string``)\n+    Type of the notification. Can be ``success``, ``warning`` or ``error``.\n+2) Message (``string``)\n+    The message to display in the notification. It can be a simple string, or a translation key, eg. ``pim_import_export.notification.export.success``\n+3) MessageParams (``array``)\n+    The message parameters to give to the translation key, if any. Eg. ``['%label%' => 'Product export']``\n+    If provided, it will be passed to the message when translating it.\n+4) Route (``string``)\n+    The route the user will be redirected to if the notification is clicked.\n+5) RouteParams (``array``)\n+    The parameters to that given route.\n+    For example, the route of the show export profile page is:\n+\n+    .. code-block:: yaml\n+\n+        pim_importexport_export_profile_show:\n+            path: /{id}\n+            defaults: { _controller: pim_import_export.controller.export_profile:showAction }\n+            requirements:\n+                id: \\d+\n+\n+    The optional route parameter will be:\n \n-    $route = 'pim_importexport_export_execution_show';\n-    $routeParams = ['id' => $jobExecutionId];\n+    .. code-block:: php\n \n-If the messageParams option is provided, it will be passed to the message when translating it.\n+        $route = 'pim_importexport_export_execution_show';\n+        $routeParams = ['id' => $jobExecutionId];\n \n-The context allows to store some extra data in the notification, it is not displayed in the UI by default.\n+6) Context (``array``)\n+    The context allows to store some extra data in the notification, it is not displayed in the UI by default. Some important extra data you may use:\n+        - ``actionType`` (``string``): this will be used to guess the icon to display on the notification\n+        - ``showReportButton`` (``bool``): to hide/display the \"report\" label on the notification\n \n-Now register your new factory with the proper tag:\n+.. note::\n+    You can see available notification icons on the `styleguide website <https://docs.akeneo.com/2.0/design_pim/styleguide/index.php#Templates-AknNotification>`_.\n+\n+For example, the ``create`` method of the NotificationFactory for mass edit notifications looks like that:\n+\n+.. code-block:: php\n+\n+    public function create($jobExecution)\n+    {\n+        $notification = new Notification();\n+        $type = $jobExecution->getJobInstance()->getType();\n+        $status = $this->getJobStatus($jobExecution);\n+\n+        $notification\n+            ->setType($status)\n+            ->setMessage(sprintf('pim_mass_edit.notification.%s.%s', $type, $status))\n+            ->setMessageParams(['%label%' => $jobExecution->getJobInstance()->getLabel()])\n+            ->setRoute('pim_enrich_job_tracker_show')\n+            ->setRouteParams(['id' => $jobExecution->getId()])\n+            ->setContext(['actionType' => $type]);\n+\n+        return $notification;\n+    }\n+\n+Well, now we created our very own Notification Factory, **we need to register it** with the proper tag:\n \n .. code-block:: yaml\n \n     services:\n         acme_custom.notification.factory.custom_notification_factory:\n             class: 'Acme\\CustomBundle\\Notification\\CustomNotificationFactory'\n             arguments:\n-                - ['my_custom_name']\n+                - ['my_custom_notification_name']\n             tags:\n                 - { name: pim_notification.factory.notification }\n \n-With this tag you will be able to get your new factory from the dedicated registry.\n+With this tag we will be able to get our new factory from the dedicated registry.\n \n Inject Services\n ---------------\n \n-The notifier service is called: ``@pim_notification.notifier`` and the factory registry is\n-``@pim_notification.registry.factory.notification``.\n+Now that our Notification Factory is created and registered, we can build our own notifications!\n+\n+.. warning::\n+    The Notification Factory we just created is **not responsible of sending notifications**, only to build them.","path":"technical_architecture/notification/add.rst","position":163,"original_position":163,"commit_id":"a19b4e58b8817607dbc5fcb9d775052cf7390a73","original_commit_id":"a19b4e58b8817607dbc5fcb9d775052cf7390a73","user":{"login":"SamirBoulil","id":1826473,"node_id":"MDQ6VXNlcjE4MjY0NzM=","avatar_url":"https://avatars1.githubusercontent.com/u/1826473?v=4","gravatar_id":"","url":"https://api.github.com/users/SamirBoulil","html_url":"https://github.com/SamirBoulil","followers_url":"https://api.github.com/users/SamirBoulil/followers","following_url":"https://api.github.com/users/SamirBoulil/following{/other_user}","gists_url":"https://api.github.com/users/SamirBoulil/gists{/gist_id}","starred_url":"https://api.github.com/users/SamirBoulil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SamirBoulil/subscriptions","organizations_url":"https://api.github.com/users/SamirBoulil/orgs","repos_url":"https://api.github.com/users/SamirBoulil/repos","events_url":"https://api.github.com/users/SamirBoulil/events{/privacy}","received_events_url":"https://api.github.com/users/SamirBoulil/received_events","type":"User","site_admin":false},"body":"`not responsible of sending notifications` => `not responsible for sending notifications`","created_at":"2018-07-18T08:10:52Z","updated_at":"2018-07-18T08:10:52Z","html_url":"https://github.com/akeneo/pim-docs/pull/975#discussion_r203286898","pull_request_url":"https://api.github.com/repos/akeneo/pim-docs/pulls/975","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/akeneo/pim-docs/pulls/comments/203286898"},"html":{"href":"https://github.com/akeneo/pim-docs/pull/975#discussion_r203286898"},"pull_request":{"href":"https://api.github.com/repos/akeneo/pim-docs/pulls/975"}}},"pull_request":{"url":"https://api.github.com/repos/akeneo/pim-docs/pulls/975","id":201986572,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAxOTg2NTcy","html_url":"https://github.com/akeneo/pim-docs/pull/975","diff_url":"https://github.com/akeneo/pim-docs/pull/975.diff","patch_url":"https://github.com/akeneo/pim-docs/pull/975.patch","issue_url":"https://api.github.com/repos/akeneo/pim-docs/issues/975","number":975,"state":"open","locked":false,"title":"FIX & Improve doc about custom notifications","user":{"login":"grena","id":301169,"node_id":"MDQ6VXNlcjMwMTE2OQ==","avatar_url":"https://avatars2.githubusercontent.com/u/301169?v=4","gravatar_id":"","url":"https://api.github.com/users/grena","html_url":"https://github.com/grena","followers_url":"https://api.github.com/users/grena/followers","following_url":"https://api.github.com/users/grena/following{/other_user}","gists_url":"https://api.github.com/users/grena/gists{/gist_id}","starred_url":"https://api.github.com/users/grena/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grena/subscriptions","organizations_url":"https://api.github.com/users/grena/orgs","repos_url":"https://api.github.com/users/grena/repos","events_url":"https://api.github.com/users/grena/events{/privacy}","received_events_url":"https://api.github.com/users/grena/received_events","type":"User","site_admin":false},"body":"**Description**\r\n\r\nThis PR fixes & improves documentation on how to add a custom notification factory.\r\n\r\n**Definition Of Done**\r\n\r\n| Q                                 | A\r\n| --------------------------------- | ---\r\n| Technical Review and 2 GTM        | Todo\r\n| English Review and 1 GTM          | Todo\r\n","created_at":"2018-07-17T15:45:17Z","updated_at":"2018-07-18T08:10:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cb903fb27806426afc8c16a3faf3915ba6492514","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":345591031,"node_id":"MDU6TGFiZWwzNDU1OTEwMzE=","url":"https://api.github.com/repos/akeneo/pim-docs/labels/to%20review","name":"to review","color":"5319e7","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/akeneo/pim-docs/pulls/975/commits","review_comments_url":"https://api.github.com/repos/akeneo/pim-docs/pulls/975/comments","review_comment_url":"https://api.github.com/repos/akeneo/pim-docs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/akeneo/pim-docs/issues/975/comments","statuses_url":"https://api.github.com/repos/akeneo/pim-docs/statuses/a19b4e58b8817607dbc5fcb9d775052cf7390a73","head":{"label":"akeneo:improve-notifications","ref":"improve-notifications","sha":"a19b4e58b8817607dbc5fcb9d775052cf7390a73","user":{"login":"akeneo","id":2510186,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1MTAxODY=","avatar_url":"https://avatars0.githubusercontent.com/u/2510186?v=4","gravatar_id":"","url":"https://api.github.com/users/akeneo","html_url":"https://github.com/akeneo","followers_url":"https://api.github.com/users/akeneo/followers","following_url":"https://api.github.com/users/akeneo/following{/other_user}","gists_url":"https://api.github.com/users/akeneo/gists{/gist_id}","starred_url":"https://api.github.com/users/akeneo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akeneo/subscriptions","organizations_url":"https://api.github.com/users/akeneo/orgs","repos_url":"https://api.github.com/users/akeneo/repos","events_url":"https://api.github.com/users/akeneo/events{/privacy}","received_events_url":"https://api.github.com/users/akeneo/received_events","type":"Organization","site_admin":false},"repo":{"id":12193604,"node_id":"MDEwOlJlcG9zaXRvcnkxMjE5MzYwNA==","name":"pim-docs","full_name":"akeneo/pim-docs","owner":{"login":"akeneo","id":2510186,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1MTAxODY=","avatar_url":"https://avatars0.githubusercontent.com/u/2510186?v=4","gravatar_id":"","url":"https://api.github.com/users/akeneo","html_url":"https://github.com/akeneo","followers_url":"https://api.github.com/users/akeneo/followers","following_url":"https://api.github.com/users/akeneo/following{/other_user}","gists_url":"https://api.github.com/users/akeneo/gists{/gist_id}","starred_url":"https://api.github.com/users/akeneo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akeneo/subscriptions","organizations_url":"https://api.github.com/users/akeneo/orgs","repos_url":"https://api.github.com/users/akeneo/repos","events_url":"https://api.github.com/users/akeneo/events{/privacy}","received_events_url":"https://api.github.com/users/akeneo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/akeneo/pim-docs","description":"[Community Documentation Repository] The open source Product Information Management (PIM)","fork":false,"url":"https://api.github.com/repos/akeneo/pim-docs","forks_url":"https://api.github.com/repos/akeneo/pim-docs/forks","keys_url":"https://api.github.com/repos/akeneo/pim-docs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/akeneo/pim-docs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/akeneo/pim-docs/teams","hooks_url":"https://api.github.com/repos/akeneo/pim-docs/hooks","issue_events_url":"https://api.github.com/repos/akeneo/pim-docs/issues/events{/number}","events_url":"https://api.github.com/repos/akeneo/pim-docs/events","assignees_url":"https://api.github.com/repos/akeneo/pim-docs/assignees{/user}","branches_url":"https://api.github.com/repos/akeneo/pim-docs/branches{/branch}","tags_url":"https://api.github.com/repos/akeneo/pim-docs/tags","blobs_url":"https://api.github.com/repos/akeneo/pim-docs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/akeneo/pim-docs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/akeneo/pim-docs/git/refs{/sha}","trees_url":"https://api.github.com/repos/akeneo/pim-docs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/akeneo/pim-docs/statuses/{sha}","languages_url":"https://api.github.com/repos/akeneo/pim-docs/languages","stargazers_url":"https://api.github.com/repos/akeneo/pim-docs/stargazers","contributors_url":"https://api.github.com/repos/akeneo/pim-docs/contributors","subscribers_url":"https://api.github.com/repos/akeneo/pim-docs/subscribers","subscription_url":"https://api.github.com/repos/akeneo/pim-docs/subscription","commits_url":"https://api.github.com/repos/akeneo/pim-docs/commits{/sha}","git_commits_url":"https://api.github.com/repos/akeneo/pim-docs/git/commits{/sha}","comments_url":"https://api.github.com/repos/akeneo/pim-docs/comments{/number}","issue_comment_url":"https://api.github.com/repos/akeneo/pim-docs/issues/comments{/number}","contents_url":"https://api.github.com/repos/akeneo/pim-docs/contents/{+path}","compare_url":"https://api.github.com/repos/akeneo/pim-docs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/akeneo/pim-docs/merges","archive_url":"https://api.github.com/repos/akeneo/pim-docs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/akeneo/pim-docs/downloads","issues_url":"https://api.github.com/repos/akeneo/pim-docs/issues{/number}","pulls_url":"https://api.github.com/repos/akeneo/pim-docs/pulls{/number}","milestones_url":"https://api.github.com/repos/akeneo/pim-docs/milestones{/number}","notifications_url":"https://api.github.com/repos/akeneo/pim-docs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/akeneo/pim-docs/labels{/name}","releases_url":"https://api.github.com/repos/akeneo/pim-docs/releases{/id}","deployments_url":"https://api.github.com/repos/akeneo/pim-docs/deployments","created_at":"2013-08-18T10:17:30Z","updated_at":"2018-06-25T17:36:47Z","pushed_at":"2018-07-17T15:45:17Z","git_url":"git://github.com/akeneo/pim-docs.git","ssh_url":"git@github.com:akeneo/pim-docs.git","clone_url":"https://github.com/akeneo/pim-docs.git","svn_url":"https://github.com/akeneo/pim-docs","homepage":"http://docs.akeneo.com/latest/index.html","size":6929,"stargazers_count":31,"watchers_count":31,"language":"CSS","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":103,"mirror_url":null,"archived":false,"open_issues_count":33,"license":null,"forks":103,"open_issues":33,"watchers":31,"default_branch":"2.3"}},"base":{"label":"akeneo:2.0","ref":"2.0","sha":"659bfbf4b41772025c507518686063e992437f7e","user":{"login":"akeneo","id":2510186,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1MTAxODY=","avatar_url":"https://avatars0.githubusercontent.com/u/2510186?v=4","gravatar_id":"","url":"https://api.github.com/users/akeneo","html_url":"https://github.com/akeneo","followers_url":"https://api.github.com/users/akeneo/followers","following_url":"https://api.github.com/users/akeneo/following{/other_user}","gists_url":"https://api.github.com/users/akeneo/gists{/gist_id}","starred_url":"https://api.github.com/users/akeneo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akeneo/subscriptions","organizations_url":"https://api.github.com/users/akeneo/orgs","repos_url":"https://api.github.com/users/akeneo/repos","events_url":"https://api.github.com/users/akeneo/events{/privacy}","received_events_url":"https://api.github.com/users/akeneo/received_events","type":"Organization","site_admin":false},"repo":{"id":12193604,"node_id":"MDEwOlJlcG9zaXRvcnkxMjE5MzYwNA==","name":"pim-docs","full_name":"akeneo/pim-docs","owner":{"login":"akeneo","id":2510186,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1MTAxODY=","avatar_url":"https://avatars0.githubusercontent.com/u/2510186?v=4","gravatar_id":"","url":"https://api.github.com/users/akeneo","html_url":"https://github.com/akeneo","followers_url":"https://api.github.com/users/akeneo/followers","following_url":"https://api.github.com/users/akeneo/following{/other_user}","gists_url":"https://api.github.com/users/akeneo/gists{/gist_id}","starred_url":"https://api.github.com/users/akeneo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akeneo/subscriptions","organizations_url":"https://api.github.com/users/akeneo/orgs","repos_url":"https://api.github.com/users/akeneo/repos","events_url":"https://api.github.com/users/akeneo/events{/privacy}","received_events_url":"https://api.github.com/users/akeneo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/akeneo/pim-docs","description":"[Community Documentation Repository] The open source Product Information Management (PIM)","fork":false,"url":"https://api.github.com/repos/akeneo/pim-docs","forks_url":"https://api.github.com/repos/akeneo/pim-docs/forks","keys_url":"https://api.github.com/repos/akeneo/pim-docs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/akeneo/pim-docs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/akeneo/pim-docs/teams","hooks_url":"https://api.github.com/repos/akeneo/pim-docs/hooks","issue_events_url":"https://api.github.com/repos/akeneo/pim-docs/issues/events{/number}","events_url":"https://api.github.com/repos/akeneo/pim-docs/events","assignees_url":"https://api.github.com/repos/akeneo/pim-docs/assignees{/user}","branches_url":"https://api.github.com/repos/akeneo/pim-docs/branches{/branch}","tags_url":"https://api.github.com/repos/akeneo/pim-docs/tags","blobs_url":"https://api.github.com/repos/akeneo/pim-docs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/akeneo/pim-docs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/akeneo/pim-docs/git/refs{/sha}","trees_url":"https://api.github.com/repos/akeneo/pim-docs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/akeneo/pim-docs/statuses/{sha}","languages_url":"https://api.github.com/repos/akeneo/pim-docs/languages","stargazers_url":"https://api.github.com/repos/akeneo/pim-docs/stargazers","contributors_url":"https://api.github.com/repos/akeneo/pim-docs/contributors","subscribers_url":"https://api.github.com/repos/akeneo/pim-docs/subscribers","subscription_url":"https://api.github.com/repos/akeneo/pim-docs/subscription","commits_url":"https://api.github.com/repos/akeneo/pim-docs/commits{/sha}","git_commits_url":"https://api.github.com/repos/akeneo/pim-docs/git/commits{/sha}","comments_url":"https://api.github.com/repos/akeneo/pim-docs/comments{/number}","issue_comment_url":"https://api.github.com/repos/akeneo/pim-docs/issues/comments{/number}","contents_url":"https://api.github.com/repos/akeneo/pim-docs/contents/{+path}","compare_url":"https://api.github.com/repos/akeneo/pim-docs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/akeneo/pim-docs/merges","archive_url":"https://api.github.com/repos/akeneo/pim-docs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/akeneo/pim-docs/downloads","issues_url":"https://api.github.com/repos/akeneo/pim-docs/issues{/number}","pulls_url":"https://api.github.com/repos/akeneo/pim-docs/pulls{/number}","milestones_url":"https://api.github.com/repos/akeneo/pim-docs/milestones{/number}","notifications_url":"https://api.github.com/repos/akeneo/pim-docs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/akeneo/pim-docs/labels{/name}","releases_url":"https://api.github.com/repos/akeneo/pim-docs/releases{/id}","deployments_url":"https://api.github.com/repos/akeneo/pim-docs/deployments","created_at":"2013-08-18T10:17:30Z","updated_at":"2018-06-25T17:36:47Z","pushed_at":"2018-07-17T15:45:17Z","git_url":"git://github.com/akeneo/pim-docs.git","ssh_url":"git@github.com:akeneo/pim-docs.git","clone_url":"https://github.com/akeneo/pim-docs.git","svn_url":"https://github.com/akeneo/pim-docs","homepage":"http://docs.akeneo.com/latest/index.html","size":6929,"stargazers_count":31,"watchers_count":31,"language":"CSS","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":103,"mirror_url":null,"archived":false,"open_issues_count":33,"license":null,"forks":103,"open_issues":33,"watchers":31,"default_branch":"2.3"}},"_links":{"self":{"href":"https://api.github.com/repos/akeneo/pim-docs/pulls/975"},"html":{"href":"https://github.com/akeneo/pim-docs/pull/975"},"issue":{"href":"https://api.github.com/repos/akeneo/pim-docs/issues/975"},"comments":{"href":"https://api.github.com/repos/akeneo/pim-docs/issues/975/comments"},"review_comments":{"href":"https://api.github.com/repos/akeneo/pim-docs/pulls/975/comments"},"review_comment":{"href":"https://api.github.com/repos/akeneo/pim-docs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/akeneo/pim-docs/pulls/975/commits"},"statuses":{"href":"https://api.github.com/repos/akeneo/pim-docs/statuses/a19b4e58b8817607dbc5fcb9d775052cf7390a73"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"SamirBoulil"}}