{"action":"created","comment":{"url":"https://api.github.com/repos/fago/rules/pulls/comments/28313847","id":28313847,"diff_hunk":"@@ -0,0 +1,128 @@\n+<?php\n+\n+/**\n+ * @file\n+ * Contains \\Drupal\\rules\\Plugin\\Action\\EntityPropertyFetch.\n+ */\n+\n+namespace Drupal\\rules\\Plugin\\Action;\n+\n+use Drupal\\Core\\Entity\\EntityManagerInterface;\n+use Drupal\\Core\\Plugin\\ContainerFactoryPluginInterface;\n+use Drupal\\rules\\Core\\RulesActionBase;\n+use Symfony\\Component\\DependencyInjection\\ContainerInterface;\n+\n+/**\n+ * Provides a 'Fetch entities by property' action.\n+ *\n+ * @Action(\n+ *   id = \"rules_entity_property_fetch\",\n+ *   label = @Translation(\"Fetch entities by property\"),\n+ *   category = @Translation(\"Entity\"),\n+ *   context = {\n+ *     \"type\" = @ContextDefinition(\"string\",\n+ *       label = @Translation(\"Entity type\"),\n+ *       description = @Translation(\"Specifies the type of the entity that should be fetched.\"),\n+ *     ),\n+ *     \"property\" = @ContextDefinition(\"string\",\n+ *       label = @Translation(\"Property\"),\n+ *       description = @Translation(\"The property by which the entity is to be selected..\"),\n+ *     ),\n+ *     \"value\" = @ContextDefinition(\"any\",\n+ *       label = @Translation(\"Value\"),\n+ *       description = @Translation(\"The property value of the entity to be fetched.\"),\n+ *     ),\n+ *     \"limit\" = @ContextDefinition(\"integer\",\n+ *       label = @Translation(\"Limit\"),\n+ *       description = @Translation(\"Limit the maximum number of fetched entities.\"),\n+ *       required = FALSE,\n+ *     ),\n+ *   },\n+ *   provides = {\n+ *      \"entity_fetched\" = @ContextDefinition(\"entity\",\n+ *        label = @Translation(\"Fetched entity\"),\n+ *        multiple = TRUE,\n+ *      )\n+ *   }\n+ * )\n+ *\n+ * @todo: Add access callback information from Drupal 7.\n+ */\n+class EntityPropertyFetch extends RulesActionBase implements ContainerFactoryPluginInterface {\n+\n+  /**\n+   * The entity manager.\n+   *\n+   * @var \\Drupal\\Core\\Entity\\EntityManagerInterface\n+   */\n+  protected $entityManager;\n+\n+  /**\n+   * Constructs a EntityPropertyFetch 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 \\Drupal\\Core\\Entity\\EntityManagerInterface $entity_manager\n+   *   The entity manager service.\n+   */\n+  public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager) {\n+    parent::__construct($configuration, $plugin_id, $plugin_definition);\n+    $this->entityManager = $entity_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('entity.manager')\n+    );\n+  }\n+\n+  /**\n+   * {@inheritdoc}\n+   */\n+  public function summary() {\n+    return $this->t('Fetch entities by property');\n+  }\n+\n+  /**\n+   * {@inheritdoc}\n+   */\n+  public function execute() {\n+    // Retrieve context values for action.\n+    $entity_type = $this->getContextValue('type');\n+    $entity_property = $this->getContextValue('property');\n+    $property_value = $this->getContextValue('value');\n+    $limit = $this->getContextValue('limit');\n+\n+    $storage = $this->entityManager->getStorage($entity_type);\n+\n+    // When retrieving entities, if $limit is not set there is no need to use query object directly.","path":"src/Plugin/Action/EntityPropertyFetch.php","position":108,"original_position":108,"commit_id":"fa5bb63f90968e1bccbb0948b70fd324e63199d2","original_commit_id":"fa5bb63f90968e1bccbb0948b70fd324e63199d2","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":"should be \"... to use the query object ...\"","created_at":"2015-04-14T09:53:32Z","updated_at":"2015-04-14T09:53:32Z","html_url":"https://github.com/fago/rules/pull/157#discussion_r28313847","pull_request_url":"https://api.github.com/repos/fago/rules/pulls/157","_links":{"self":{"href":"https://api.github.com/repos/fago/rules/pulls/comments/28313847"},"html":{"href":"https://github.com/fago/rules/pull/157#discussion_r28313847"},"pull_request":{"href":"https://api.github.com/repos/fago/rules/pulls/157"}}},"pull_request":{"url":"https://api.github.com/repos/fago/rules/pulls/157","id":33241342,"html_url":"https://github.com/fago/rules/pull/157","diff_url":"https://github.com/fago/rules/pull/157.diff","patch_url":"https://github.com/fago/rules/pull/157.patch","issue_url":"https://api.github.com/repos/fago/rules/issues/157","number":157,"state":"open","locked":false,"title":"Entity fetch action.","user":{"login":"mikl","id":10263,"avatar_url":"https://avatars.githubusercontent.com/u/10263?v=3","gravatar_id":"","url":"https://api.github.com/users/mikl","html_url":"https://github.com/mikl","followers_url":"https://api.github.com/users/mikl/followers","following_url":"https://api.github.com/users/mikl/following{/other_user}","gists_url":"https://api.github.com/users/mikl/gists{/gist_id}","starred_url":"https://api.github.com/users/mikl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikl/subscriptions","organizations_url":"https://api.github.com/users/mikl/orgs","repos_url":"https://api.github.com/users/mikl/repos","events_url":"https://api.github.com/users/mikl/events{/privacy}","received_events_url":"https://api.github.com/users/mikl/received_events","type":"User","site_admin":false},"body":"Entity fetch by property action - see https://www.drupal.org/node/2317233\n\nBased on https://github.com/fago/rules/pull/131 by @diarmy","created_at":"2015-04-14T09:44:42Z","updated_at":"2015-04-14T09:53:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"30c0b8b5643c520243dc5554ccfd2252b92268a8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/fago/rules/pulls/157/commits","review_comments_url":"https://api.github.com/repos/fago/rules/pulls/157/comments","review_comment_url":"https://api.github.com/repos/fago/rules/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fago/rules/issues/157/comments","statuses_url":"https://api.github.com/repos/fago/rules/statuses/fa5bb63f90968e1bccbb0948b70fd324e63199d2","head":{"label":"mikl:action-entity-fetch-9547355","ref":"action-entity-fetch-9547355","sha":"fa5bb63f90968e1bccbb0948b70fd324e63199d2","user":{"login":"mikl","id":10263,"avatar_url":"https://avatars.githubusercontent.com/u/10263?v=3","gravatar_id":"","url":"https://api.github.com/users/mikl","html_url":"https://github.com/mikl","followers_url":"https://api.github.com/users/mikl/followers","following_url":"https://api.github.com/users/mikl/following{/other_user}","gists_url":"https://api.github.com/users/mikl/gists{/gist_id}","starred_url":"https://api.github.com/users/mikl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikl/subscriptions","organizations_url":"https://api.github.com/users/mikl/orgs","repos_url":"https://api.github.com/users/mikl/repos","events_url":"https://api.github.com/users/mikl/events{/privacy}","received_events_url":"https://api.github.com/users/mikl/received_events","type":"User","site_admin":false},"repo":{"id":32627892,"name":"rules","full_name":"mikl/rules","owner":{"login":"mikl","id":10263,"avatar_url":"https://avatars.githubusercontent.com/u/10263?v=3","gravatar_id":"","url":"https://api.github.com/users/mikl","html_url":"https://github.com/mikl","followers_url":"https://api.github.com/users/mikl/followers","following_url":"https://api.github.com/users/mikl/following{/other_user}","gists_url":"https://api.github.com/users/mikl/gists{/gist_id}","starred_url":"https://api.github.com/users/mikl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikl/subscriptions","organizations_url":"https://api.github.com/users/mikl/orgs","repos_url":"https://api.github.com/users/mikl/repos","events_url":"https://api.github.com/users/mikl/events{/privacy}","received_events_url":"https://api.github.com/users/mikl/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mikl/rules","description":"Rules 8.x-3.x development","fork":true,"url":"https://api.github.com/repos/mikl/rules","forks_url":"https://api.github.com/repos/mikl/rules/forks","keys_url":"https://api.github.com/repos/mikl/rules/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mikl/rules/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mikl/rules/teams","hooks_url":"https://api.github.com/repos/mikl/rules/hooks","issue_events_url":"https://api.github.com/repos/mikl/rules/issues/events{/number}","events_url":"https://api.github.com/repos/mikl/rules/events","assignees_url":"https://api.github.com/repos/mikl/rules/assignees{/user}","branches_url":"https://api.github.com/repos/mikl/rules/branches{/branch}","tags_url":"https://api.github.com/repos/mikl/rules/tags","blobs_url":"https://api.github.com/repos/mikl/rules/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mikl/rules/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mikl/rules/git/refs{/sha}","trees_url":"https://api.github.com/repos/mikl/rules/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mikl/rules/statuses/{sha}","languages_url":"https://api.github.com/repos/mikl/rules/languages","stargazers_url":"https://api.github.com/repos/mikl/rules/stargazers","contributors_url":"https://api.github.com/repos/mikl/rules/contributors","subscribers_url":"https://api.github.com/repos/mikl/rules/subscribers","subscription_url":"https://api.github.com/repos/mikl/rules/subscription","commits_url":"https://api.github.com/repos/mikl/rules/commits{/sha}","git_commits_url":"https://api.github.com/repos/mikl/rules/git/commits{/sha}","comments_url":"https://api.github.com/repos/mikl/rules/comments{/number}","issue_comment_url":"https://api.github.com/repos/mikl/rules/issues/comments{/number}","contents_url":"https://api.github.com/repos/mikl/rules/contents/{+path}","compare_url":"https://api.github.com/repos/mikl/rules/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mikl/rules/merges","archive_url":"https://api.github.com/repos/mikl/rules/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mikl/rules/downloads","issues_url":"https://api.github.com/repos/mikl/rules/issues{/number}","pulls_url":"https://api.github.com/repos/mikl/rules/pulls{/number}","milestones_url":"https://api.github.com/repos/mikl/rules/milestones{/number}","notifications_url":"https://api.github.com/repos/mikl/rules/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mikl/rules/labels{/name}","releases_url":"https://api.github.com/repos/mikl/rules/releases{/id}","created_at":"2015-03-21T10:13:16Z","updated_at":"2015-03-21T10:13:17Z","pushed_at":"2015-04-14T09:43:32Z","git_url":"git://github.com/mikl/rules.git","ssh_url":"git@github.com:mikl/rules.git","clone_url":"https://github.com/mikl/rules.git","svn_url":"https://github.com/mikl/rules","homepage":null,"size":2813,"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":"5746d4382002e58a74c49bb1526f9e2866a18ec8","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-14T09:10:18Z","pushed_at":"2015-04-14T09:44:42Z","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":63,"mirror_url":null,"open_issues_count":13,"forks":63,"open_issues":13,"watchers":21,"default_branch":"8.x-3.x"}},"_links":{"self":{"href":"https://api.github.com/repos/fago/rules/pulls/157"},"html":{"href":"https://github.com/fago/rules/pull/157"},"issue":{"href":"https://api.github.com/repos/fago/rules/issues/157"},"comments":{"href":"https://api.github.com/repos/fago/rules/issues/157/comments"},"review_comments":{"href":"https://api.github.com/repos/fago/rules/pulls/157/comments"},"review_comment":{"href":"https://api.github.com/repos/fago/rules/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fago/rules/pulls/157/commits"},"statuses":{"href":"https://api.github.com/repos/fago/rules/statuses/fa5bb63f90968e1bccbb0948b70fd324e63199d2"}}}}