This is postponed on actually getting profile2 into core: #1668292: Move simplified Profile2 module into core But I have most of the patch ready, I will post soon.

Files: 
CommentFileSizeAuthor
#2 1894770.patch6.16 KBdamiankloip

Comments

Title:Add view integration for profile2 moduleAdd views integration for profile2 module

StatusFileSize
new6.16 KB

Here is an initial patch for this, I have had this laying around for a little while but forgot to post it. This is still dependent on the linked issue in the summary, just posting some work.

Great, just posting some general points.

+++ b/core/modules/profile2/lib/Drupal/profile2/Plugin/views/argument/Pid.phpundefined
@@ -0,0 +1,37 @@
+/**
+ * Argument handler to accept a profile pid.
+ *
+ * @Plugin(
+ *   id = "profile2_pid",
+ *   module = "profile2"
+ * )
+ */
+class Pid extends Numeric {
+
+  /**
+   * Overrides \Drupal\views\Plugin\views\argument\Numeric::title_query().
+   */
+  public function title_query() {
+    $titles = array();
+
+    $profiles = entity_load_multiple('profile', $this->value);
+    foreach ($profiles as $profile) {
+      $titles[] = check_plain($profile->label());
+    }
+
+    return $titles;

I think we should instead write a entity generic one, which get's the entity type from outside.

+++ b/core/modules/profile2/lib/Drupal/profile2/Plugin/views/filter/Type.phpundefined
@@ -0,0 +1,49 @@
+class Type extends InOperator {

Can't we use an optional callback and the generic InOperator?

+++ b/core/modules/profile2/profile2.views.incundefined
@@ -0,0 +1,169 @@
+    // @todo wizard id/integration.

Well, we don't have to provide a wizard, unless we have an idea what a profile one should provide.

+++ b/core/modules/profile2/profile2.views.incundefined
@@ -0,0 +1,169 @@
+  // pid

Just for reference: we should remove that.

+++ b/core/modules/profile2/profile2.views.incundefined
@@ -0,0 +1,169 @@
+        'id' => 'string',

Any reason not to use the language field handler as well?