Skip to content

Commit

Permalink
Merge pull request #93 from Gizra/92-keep-up-w-flag
Browse files Browse the repository at this point in the history
#92 - Keeping up with Flag API changes.
  • Loading branch information
jhedstrom authored May 24, 2017
2 parents 681bb85 + 72b97ae commit fc938e3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
1 change: 0 additions & 1 deletion config/optional/flag.flag.subscribe_node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ flagTypeConfig:
show_as_field: true
show_on_form: false
show_contextual_link: false
i18n: null
extra_permissions:
owner: '0'
linkTypeConfig: { }
1 change: 0 additions & 1 deletion config/optional/flag.flag.subscribe_og.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,5 @@ flagTypeConfig:
show_as_field: true
show_on_form: false
show_contextual_link: false
i18n: null
extra_permissions: { }
linkTypeConfig: { }
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ flagTypeConfig:
show_as_field: true
show_on_form: false
show_contextual_link: false
i18n: null
extra_permissions:
owner: '0'
linkTypeConfig: { }
13 changes: 9 additions & 4 deletions src/Subscribers.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,16 @@ protected function isEntityOwner(EntityInterface $entity, $uid) {
* {@inheritdoc}
*/
public function getFlags($entity_type = NULL, $bundle = NULL, AccountInterface $account = NULL) {
$flags = $this->flagService->getAllFlags($entity_type, $bundle);
if ($account) {
$flags = $this->flagService->getUsersFlags($account, $entity_type, $bundle);
}
else {
$flags = $this->flagService->getAllFlags($entity_type, $bundle);
// Filter flags down to ones the account has action access for.
// @see https://www.drupal.org/node/2870375
foreach ($flags as $flag_id => $flag) {
if (!$flag->actionAccess('flag', $account)->isAllowed()
&& !$flag->actionAccess('unflag', $account)->isAllowed()) {
unset($flags[$flag_id]);
}
}
}
$ms_flags = [];
$prefix = $this->config->get('flag_prefix') . '_';
Expand Down

0 comments on commit fc938e3

Please sign in to comment.