Drupal 8.0.0 beta 12. More info: https://www.drupal.org/node/2514176
This commit is contained in:
commit
9921556621
13277 changed files with 1459781 additions and 0 deletions
48
core/modules/tracker/src/Plugin/Menu/UserTrackerTab.php
Normal file
48
core/modules/tracker/src/Plugin/Menu/UserTrackerTab.php
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\tracker\Plugin\Menu\UserTrackerTab.
|
||||
*/
|
||||
|
||||
namespace Drupal\tracker\Plugin\Menu;
|
||||
|
||||
use Drupal\Core\Menu\LocalTaskDefault;
|
||||
use Drupal\Core\Routing\RouteMatchInterface;
|
||||
|
||||
/**
|
||||
* Provides route parameters needed to link to the current user tracker tab.
|
||||
*/
|
||||
class UserTrackerTab extends LocalTaskDefault {
|
||||
|
||||
/**
|
||||
* Current user object.
|
||||
*
|
||||
* @var \Drupal\Core\Session\AccountInterface
|
||||
*/
|
||||
protected $currentUser;
|
||||
|
||||
/**
|
||||
* Gets the current active user.
|
||||
*
|
||||
* @todo: https://www.drupal.org/node/2105123 put this method in
|
||||
* \Drupal\Core\Plugin\PluginBase instead.
|
||||
*
|
||||
* @return \Drupal\Core\Session\AccountInterface
|
||||
*/
|
||||
protected function currentUser() {
|
||||
if (!$this->currentUser) {
|
||||
$this->currentUser = \Drupal::currentUser();
|
||||
}
|
||||
return $this->currentUser;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRouteParameters(RouteMatchInterface $route_match) {
|
||||
return array('user' => $this->currentUser()->Id());
|
||||
}
|
||||
|
||||
}
|
||||
32
core/modules/tracker/src/Plugin/views/argument/UserUid.php
Normal file
32
core/modules/tracker/src/Plugin/views/argument/UserUid.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\tracker\Plugin\views\argument\UserUid.
|
||||
*/
|
||||
|
||||
namespace Drupal\tracker\Plugin\views\argument;
|
||||
|
||||
use Drupal\comment\Plugin\views\argument\UserUid as CommentUserUid;
|
||||
|
||||
/**
|
||||
* UID argument to check for nodes that user posted or commented on.
|
||||
*
|
||||
* @ingroup views_argument_handlers
|
||||
*
|
||||
* @ViewsArgument("tracker_user_uid")
|
||||
*/
|
||||
class UserUid extends CommentUserUid {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query($group_by = FALSE) {
|
||||
// Because this handler thinks it's an argument for a field on the {node}
|
||||
// table, we need to make sure {tracker_user} is JOINed and use its alias
|
||||
// for the WHERE clause.
|
||||
$tracker_user_alias = $this->query->ensureTable('tracker_user');
|
||||
$this->query->addWhere(0, "$tracker_user_alias.uid", $this->argument);
|
||||
}
|
||||
|
||||
}
|
||||
33
core/modules/tracker/src/Plugin/views/filter/UserUid.php
Normal file
33
core/modules/tracker/src/Plugin/views/filter/UserUid.php
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\tracker\Plugin\views\filter\UserUid.
|
||||
*/
|
||||
|
||||
namespace Drupal\tracker\Plugin\views\filter;
|
||||
|
||||
use Drupal\user\Plugin\views\filter\Name;
|
||||
|
||||
/**
|
||||
* UID filter to check for nodes that a user posted or commented on.
|
||||
*
|
||||
* @ingroup views_filter_handlers
|
||||
*
|
||||
* @ViewsFilter("tracker_user_uid")
|
||||
*/
|
||||
class UserUid extends Name {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
// Because this handler thinks it's an argument for a field on the {node}
|
||||
// table, we need to make sure {tracker_user} is JOINed and use its alias
|
||||
// for the WHERE clause.
|
||||
$tracker_user_alias = $this->query->ensureTable('tracker_user');
|
||||
// Cast scalars to array so we can consistently use an IN condition.
|
||||
$this->query->addWhere(0, "$tracker_user_alias.uid", (array) $this->value, 'IN');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in a new issue