{"action":"created","comment":{"url":"https://api.github.com/repos/fago/rules/pulls/comments/28234079","id":28234079,"diff_hunk":"@@ -0,0 +1,134 @@\n+<?php\n+\n+/**\n+ * @file\n+ * Contains Drupal\\rules\\Plugin\\Action\\SendEmail.\n+ */\n+\n+namespace Drupal\\rules\\Plugin\\Action;\n+\n+use Drupal\\Core\\Plugin\\ContainerFactoryPluginInterface;\n+use Drupal\\Core\\MailManager;\n+use Drupal\\Core\\MailManagerInterface;\n+use Drupal\\rules\\Core\\RulesActionBase;\n+use Psr\\Log\\LoggerInterface;\n+use Psr\\Log\\LogLevel;\n+use Symfony\\Component\\DependencyInjection\\ContainerInterface;\n+\n+use Drupal\\Core\\Render\\Element;\n+\n+/**\n+ * Provides \"Send email\" rules action.\n+ *\n+ * @Action(\n+ *   id = \"rules_send_email\",\n+ *   label = @Translation(\"Send email\"),\n+ *   context = {\n+ *     \"send_to\" = @ContextDefinition(\"email\",\n+ *       label = @Translation(\"Send to\"),\n+ *       description = @Translation(\"Email address(es) drupal will send an email to.\"),\n+ *       multiple = TRUE,\n+ *     ),\n+ *     \"subject\" = @ContextDefinition(\"string\",\n+ *       label = @Translation(\"Subject\"),\n+ *       description = @Translation(\"The email's subject.\"),\n+ *     ),\n+ *     \"message\" = @ContextDefinition(\"string\",\n+ *       label = @Translation(\"Message\"),\n+ *       description = @Translation(\"The email's message body.\"),\n+ *     ),\n+ *     \"reply\" = @ContextDefinition(\"email\",\n+ *       label = @Translation(\"Reply to\"),\n+ *       description = @Translation(\"The mail's reply-to address. Leave it empty to use the site-wide configured address.\"),\n+ *       required = FALSE,\n+ *     ),\n+ *     \"language\" = @ContextDefinition(\"language\",\n+ *       label = @Translation(\"Language\"),\n+ *       description = @Translation(\"If specified, the language used for getting the mail message and subject.\"),\n+ *       required = FALSE,\n+ *     ),\n+ *   }\n+ * )\n+ *\n+ * @todo: Define that message Context should be textarea comparing with textfield Subject\n+ * @todo: Add access callback information from Drupal 7.\n+ * @todo: Add group information from Drupal 7.\n+ */\n+class SendEmail extends RulesActionBase implements ContainerFactoryPluginInterface {\n+\n+  /**\n+   * @var LoggerInterface $logger\n+   */\n+  protected $logger;\n+\n+  /**\n+   * @var MailManagerInterface $mailManager\n+   */\n+  protected $mailManager;\n+\n+  /**\n+   * Constructs a SendEmail object.\n+   *\n+   * @param array $configuration\n+   *   A configuration array containing information about the plugin instance.\n+   * @param string $plugin_id\n+   *   The plugin ID for the plugin instance.\n+   * @param mixed $plugin_definition\n+   *   The plugin implementation definition.\n+   * @param LoggerInterface $logger\n+   *   The alias storage service.\n+   * @param $mail_manager\n+   *   The alias mail manager service.\n+   */\n+  public function __construct(array $configuration, $plugin_id, $plugin_definition, LoggerInterface $logger, $mail_manager) {\n+    parent::__construct($configuration, $plugin_id, $plugin_definition);\n+    $this->logger = $logger;\n+    $this->mailManager = $mail_manager;\n+  }\n+\n+  /**\n+   * {@inheritdoc}\n+   */\n+  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {\n+    return new static(\n+      $configuration,\n+      $plugin_id,\n+      $plugin_definition,\n+      $container->get('logger.factory'),\n+      $container->get('plugin.manager.mail')\n+    );\n+  }\n+\n+  /**\n+   * {@inheritdoc}\n+   */\n+  public function summary() {\n+    return $this->t('Send email');\n+  }\n+\n+  /**\n+   * {@inheritdoc}\n+   */\n+  public function execute() {\n+    $send_to = $this->getContextValue('send_to');\n+    // @todo: Implement hook_mail_alter() in order to modify the FROM header according to https://www.drupal.org/node/2164905.","path":"src/Plugin/Action/SendEmail.php","position":114,"original_position":114,"commit_id":"d1c197f14b2acaec1da25a5265fa12c1592682d8","original_commit_id":"d1c197f14b2acaec1da25a5265fa12c1592682d8","user":{"login":"klausi","id":213229,"avatar_url":"https://avatars.githubusercontent.com/u/213229?v=3","gravatar_id":"","url":"https://api.github.com/users/klausi","html_url":"https://github.com/klausi","followers_url":"https://api.github.com/users/klausi/followers","following_url":"https://api.github.com/users/klausi/following{/other_user}","gists_url":"https://api.github.com/users/klausi/gists{/gist_id}","starred_url":"https://api.github.com/users/klausi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klausi/subscriptions","organizations_url":"https://api.github.com/users/klausi/orgs","repos_url":"https://api.github.com/users/klausi/repos","events_url":"https://api.github.com/users/klausi/events{/privacy}","received_events_url":"https://api.github.com/users/klausi/received_events","type":"User","site_admin":false},"body":"Not sure this todo is necessary. I think the default \"reply to\" approach in D8 is fine, so I Think we can remove this line.","created_at":"2015-04-13T12:37:25Z","updated_at":"2015-04-13T12:37:25Z","html_url":"https://github.com/fago/rules/pull/151#discussion_r28234079","pull_request_url":"https://api.github.com/repos/fago/rules/pulls/151","_links":{"self":{"href":"https://api.github.com/repos/fago/rules/pulls/comments/28234079"},"html":{"href":"https://github.com/fago/rules/pull/151#discussion_r28234079"},"pull_request":{"href":"https://api.github.com/repos/fago/rules/pulls/151"}}},"pull_request":{"url":"https://api.github.com/repos/fago/rules/pulls/151","id":33152684,"html_url":"https://github.com/fago/rules/pull/151","diff_url":"https://github.com/fago/rules/pull/151.diff","patch_url":"https://github.com/fago/rules/pull/151.patch","issue_url":"https://api.github.com/repos/fago/rules/issues/151","number":151,"state":"open","locked":false,"title":"#2317303 | Create 'Send email' action | Just rerun tests","user":{"login":"czigor","id":648581,"avatar_url":"https://avatars.githubusercontent.com/u/648581?v=3","gravatar_id":"","url":"https://api.github.com/users/czigor","html_url":"https://github.com/czigor","followers_url":"https://api.github.com/users/czigor/followers","following_url":"https://api.github.com/users/czigor/following{/other_user}","gists_url":"https://api.github.com/users/czigor/gists{/gist_id}","starred_url":"https://api.github.com/users/czigor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/czigor/subscriptions","organizations_url":"https://api.github.com/users/czigor/orgs","repos_url":"https://api.github.com/users/czigor/repos","events_url":"https://api.github.com/users/czigor/events{/privacy}","received_events_url":"https://api.github.com/users/czigor/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-04-13T10:44:13Z","updated_at":"2015-04-13T12:37:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"687ce01d4a46f1f0090635bbd01b130fb82d533e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/fago/rules/pulls/151/commits","review_comments_url":"https://api.github.com/repos/fago/rules/pulls/151/comments","review_comment_url":"https://api.github.com/repos/fago/rules/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fago/rules/issues/151/comments","statuses_url":"https://api.github.com/repos/fago/rules/statuses/d1c197f14b2acaec1da25a5265fa12c1592682d8","head":{"label":"czigor:email_action","ref":"email_action","sha":"d1c197f14b2acaec1da25a5265fa12c1592682d8","user":{"login":"czigor","id":648581,"avatar_url":"https://avatars.githubusercontent.com/u/648581?v=3","gravatar_id":"","url":"https://api.github.com/users/czigor","html_url":"https://github.com/czigor","followers_url":"https://api.github.com/users/czigor/followers","following_url":"https://api.github.com/users/czigor/following{/other_user}","gists_url":"https://api.github.com/users/czigor/gists{/gist_id}","starred_url":"https://api.github.com/users/czigor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/czigor/subscriptions","organizations_url":"https://api.github.com/users/czigor/orgs","repos_url":"https://api.github.com/users/czigor/repos","events_url":"https://api.github.com/users/czigor/events{/privacy}","received_events_url":"https://api.github.com/users/czigor/received_events","type":"User","site_admin":false},"repo":{"id":33860685,"name":"rules","full_name":"czigor/rules","owner":{"login":"czigor","id":648581,"avatar_url":"https://avatars.githubusercontent.com/u/648581?v=3","gravatar_id":"","url":"https://api.github.com/users/czigor","html_url":"https://github.com/czigor","followers_url":"https://api.github.com/users/czigor/followers","following_url":"https://api.github.com/users/czigor/following{/other_user}","gists_url":"https://api.github.com/users/czigor/gists{/gist_id}","starred_url":"https://api.github.com/users/czigor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/czigor/subscriptions","organizations_url":"https://api.github.com/users/czigor/orgs","repos_url":"https://api.github.com/users/czigor/repos","events_url":"https://api.github.com/users/czigor/events{/privacy}","received_events_url":"https://api.github.com/users/czigor/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/czigor/rules","description":"Rules 8.x-3.x development","fork":true,"url":"https://api.github.com/repos/czigor/rules","forks_url":"https://api.github.com/repos/czigor/rules/forks","keys_url":"https://api.github.com/repos/czigor/rules/keys{/key_id}","collaborators_url":"https://api.github.com/repos/czigor/rules/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/czigor/rules/teams","hooks_url":"https://api.github.com/repos/czigor/rules/hooks","issue_events_url":"https://api.github.com/repos/czigor/rules/issues/events{/number}","events_url":"https://api.github.com/repos/czigor/rules/events","assignees_url":"https://api.github.com/repos/czigor/rules/assignees{/user}","branches_url":"https://api.github.com/repos/czigor/rules/branches{/branch}","tags_url":"https://api.github.com/repos/czigor/rules/tags","blobs_url":"https://api.github.com/repos/czigor/rules/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/czigor/rules/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/czigor/rules/git/refs{/sha}","trees_url":"https://api.github.com/repos/czigor/rules/git/trees{/sha}","statuses_url":"https://api.github.com/repos/czigor/rules/statuses/{sha}","languages_url":"https://api.github.com/repos/czigor/rules/languages","stargazers_url":"https://api.github.com/repos/czigor/rules/stargazers","contributors_url":"https://api.github.com/repos/czigor/rules/contributors","subscribers_url":"https://api.github.com/repos/czigor/rules/subscribers","subscription_url":"https://api.github.com/repos/czigor/rules/subscription","commits_url":"https://api.github.com/repos/czigor/rules/commits{/sha}","git_commits_url":"https://api.github.com/repos/czigor/rules/git/commits{/sha}","comments_url":"https://api.github.com/repos/czigor/rules/comments{/number}","issue_comment_url":"https://api.github.com/repos/czigor/rules/issues/comments{/number}","contents_url":"https://api.github.com/repos/czigor/rules/contents/{+path}","compare_url":"https://api.github.com/repos/czigor/rules/compare/{base}...{head}","merges_url":"https://api.github.com/repos/czigor/rules/merges","archive_url":"https://api.github.com/repos/czigor/rules/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/czigor/rules/downloads","issues_url":"https://api.github.com/repos/czigor/rules/issues{/number}","pulls_url":"https://api.github.com/repos/czigor/rules/pulls{/number}","milestones_url":"https://api.github.com/repos/czigor/rules/milestones{/number}","notifications_url":"https://api.github.com/repos/czigor/rules/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/czigor/rules/labels{/name}","releases_url":"https://api.github.com/repos/czigor/rules/releases{/id}","created_at":"2015-04-13T09:51:12Z","updated_at":"2015-04-13T09:51:12Z","pushed_at":"2015-04-13T10:43:08Z","git_url":"git://github.com/czigor/rules.git","ssh_url":"git@github.com:czigor/rules.git","clone_url":"https://github.com/czigor/rules.git","svn_url":"https://github.com/czigor/rules","homepage":null,"size":4914,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"8.x-3.x"}},"base":{"label":"fago:8.x-3.x","ref":"8.x-3.x","sha":"7ccbe89c6f5b461dd1dbe1dc205d638b65c7b154","user":{"login":"fago","id":132232,"avatar_url":"https://avatars.githubusercontent.com/u/132232?v=3","gravatar_id":"","url":"https://api.github.com/users/fago","html_url":"https://github.com/fago","followers_url":"https://api.github.com/users/fago/followers","following_url":"https://api.github.com/users/fago/following{/other_user}","gists_url":"https://api.github.com/users/fago/gists{/gist_id}","starred_url":"https://api.github.com/users/fago/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fago/subscriptions","organizations_url":"https://api.github.com/users/fago/orgs","repos_url":"https://api.github.com/users/fago/repos","events_url":"https://api.github.com/users/fago/events{/privacy}","received_events_url":"https://api.github.com/users/fago/received_events","type":"User","site_admin":false},"repo":{"id":18917483,"name":"rules","full_name":"fago/rules","owner":{"login":"fago","id":132232,"avatar_url":"https://avatars.githubusercontent.com/u/132232?v=3","gravatar_id":"","url":"https://api.github.com/users/fago","html_url":"https://github.com/fago","followers_url":"https://api.github.com/users/fago/followers","following_url":"https://api.github.com/users/fago/following{/other_user}","gists_url":"https://api.github.com/users/fago/gists{/gist_id}","starred_url":"https://api.github.com/users/fago/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fago/subscriptions","organizations_url":"https://api.github.com/users/fago/orgs","repos_url":"https://api.github.com/users/fago/repos","events_url":"https://api.github.com/users/fago/events{/privacy}","received_events_url":"https://api.github.com/users/fago/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fago/rules","description":"Rules 8.x-3.x development","fork":false,"url":"https://api.github.com/repos/fago/rules","forks_url":"https://api.github.com/repos/fago/rules/forks","keys_url":"https://api.github.com/repos/fago/rules/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fago/rules/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fago/rules/teams","hooks_url":"https://api.github.com/repos/fago/rules/hooks","issue_events_url":"https://api.github.com/repos/fago/rules/issues/events{/number}","events_url":"https://api.github.com/repos/fago/rules/events","assignees_url":"https://api.github.com/repos/fago/rules/assignees{/user}","branches_url":"https://api.github.com/repos/fago/rules/branches{/branch}","tags_url":"https://api.github.com/repos/fago/rules/tags","blobs_url":"https://api.github.com/repos/fago/rules/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fago/rules/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fago/rules/git/refs{/sha}","trees_url":"https://api.github.com/repos/fago/rules/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fago/rules/statuses/{sha}","languages_url":"https://api.github.com/repos/fago/rules/languages","stargazers_url":"https://api.github.com/repos/fago/rules/stargazers","contributors_url":"https://api.github.com/repos/fago/rules/contributors","subscribers_url":"https://api.github.com/repos/fago/rules/subscribers","subscription_url":"https://api.github.com/repos/fago/rules/subscription","commits_url":"https://api.github.com/repos/fago/rules/commits{/sha}","git_commits_url":"https://api.github.com/repos/fago/rules/git/commits{/sha}","comments_url":"https://api.github.com/repos/fago/rules/comments{/number}","issue_comment_url":"https://api.github.com/repos/fago/rules/issues/comments{/number}","contents_url":"https://api.github.com/repos/fago/rules/contents/{+path}","compare_url":"https://api.github.com/repos/fago/rules/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fago/rules/merges","archive_url":"https://api.github.com/repos/fago/rules/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fago/rules/downloads","issues_url":"https://api.github.com/repos/fago/rules/issues{/number}","pulls_url":"https://api.github.com/repos/fago/rules/pulls{/number}","milestones_url":"https://api.github.com/repos/fago/rules/milestones{/number}","notifications_url":"https://api.github.com/repos/fago/rules/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fago/rules/labels{/name}","releases_url":"https://api.github.com/repos/fago/rules/releases{/id}","created_at":"2014-04-18T15:49:13Z","updated_at":"2015-04-13T08:30:27Z","pushed_at":"2015-04-13T11:44:07Z","git_url":"git://github.com/fago/rules.git","ssh_url":"git@github.com:fago/rules.git","clone_url":"https://github.com/fago/rules.git","svn_url":"https://github.com/fago/rules","homepage":null,"size":4914,"stargazers_count":21,"watchers_count":21,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":60,"mirror_url":null,"open_issues_count":14,"forks":60,"open_issues":14,"watchers":21,"default_branch":"8.x-3.x"}},"_links":{"self":{"href":"https://api.github.com/repos/fago/rules/pulls/151"},"html":{"href":"https://github.com/fago/rules/pull/151"},"issue":{"href":"https://api.github.com/repos/fago/rules/issues/151"},"comments":{"href":"https://api.github.com/repos/fago/rules/issues/151/comments"},"review_comments":{"href":"https://api.github.com/repos/fago/rules/pulls/151/comments"},"review_comment":{"href":"https://api.github.com/repos/fago/rules/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fago/rules/pulls/151/commits"},"statuses":{"href":"https://api.github.com/repos/fago/rules/statuses/d1c197f14b2acaec1da25a5265fa12c1592682d8"}}}}