Skip to content

Commit

Permalink
Merge pull request #252 from Gizra/251
Browse files Browse the repository at this point in the history
Adding Drupal CS fixes.
  • Loading branch information
amitaibu authored Apr 12, 2017
2 parents 1c431cb + 26124ab commit 9d81808
Show file tree
Hide file tree
Showing 39 changed files with 130 additions and 126 deletions.
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status](https://travis-ci.org/Gizra/og.svg?branch=8.x-1.x)](https://travis-ci.org/Gizra/og)
![Status](https://travis-ci.org/Gizra/og.svg?branch=8.x-1.x)

## DESCRIPTION

Expand Down Expand Up @@ -111,16 +111,17 @@ provide a quick way to get started with Organic groups.
will notice that these options have the same look and feel as Drupal core in
matters relating to management of roles and permissions.
9. You can enable your privileged users to subscribe to a group by providing a
'Subscribe' link. (Subscribing is the act of associating a user with a group.)
'Subscribe' link. (Subscribing is the act of associating a user with a
group.)
To show this subscribe link:
9.1 Make sure you have the Group UI module enabled
9.2 Go to admin/config/group/permissions and make sure that the "Subscribe user to group"
permission is given to the appropriate user-roles.
9.2 Go to admin/config/group/permissions and make sure that the "Subscribe
user to group" permission is given to the appropriate user-roles.
9.3 Navigate to the "manage display" tab of your content type
(admin/structure/types/manage/group/display)
and choose the Group subscription format for the Group type field.
9.4 Back in the group view you will now notice a 'Subscribe' link (If you are the
group administrator it will say "You are the group manager").
9.4 Back in the group view you will now notice a 'Subscribe' link (If you are
the group administrator it will say "You are the group manager").
10. In order to associate other entities with group or group content, navigate
to Organic Groups field settings", in admin/config/group/fields.
11. In order to define default permissions for groups that are newly created or
Expand Down Expand Up @@ -167,7 +168,8 @@ provide a quick way to get started with Organic groups.
\Drupal\og\Og::groupTypeManager()->addGroup('node', 'page');

// Add og audience field to "Article" node type, thus making is a group content.
\Drupal\og\Og::createField(\Drupal\og\OgGroupAudienceHelper::DEFAULT_FIELD, 'node', 'article');
$field = \Drupal\og\OgGroupAudienceHelper::DEFAULT_FIELD, 'node', 'article');
\Drupal\og\Og::createField($field);
```

## DRUPAL CONSOLE INTEGRATION
Expand Down
1 change: 0 additions & 1 deletion og.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ dependencies:
- text
- field
- user

54 changes: 27 additions & 27 deletions og.install
Original file line number Diff line number Diff line change
Expand Up @@ -17,60 +17,60 @@ function og_uninstall() {
* Implements hook_schema().
*/
function og_schema() {
$schema = array();
$schema = [];

$schema['og_users_roles'] = array(
$schema['og_users_roles'] = [
'description' => 'Maps users to roles.',
'fields' => array(
'id' => array(
'fields' => [
'id' => [
'type' => 'serial',
'description' => "The unique identifier.",
'unsigned' => TRUE,
'not null' => TRUE,
),
'uid' => array(
],
'uid' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'Primary Key: {users}.uid for user.',
),
'rid' => array(
],
'rid' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'Primary Key: {og_role}.rid for role.',
),
'gid' => array(
],
'gid' => [
'description' => "The group's unique ID.",
'type' => 'int',
'size' => 'normal',
'not null' => TRUE,
),
'group_type' => array(
],
'group_type' => [
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => "The group's entity type.",
),
),
'primary key' => array('id'),
'indexes' => array(
'rid' => array('rid'),
),
'foreign keys' => array(
'user' => array(
],
],
'primary key' => ['id'],
'indexes' => [
'rid' => ['rid'],
],
'foreign keys' => [
'user' => [
'table' => 'users',
'columns' => array('uid' => 'uid'),
),
'og_role' => array(
'columns' => ['uid' => 'uid'],
],
'og_role' => [
'table' => 'og_role',
'columns' => array('rid' => 'rid'),
),
),
);
'columns' => ['rid' => 'rid'],
],
],
];

return $schema;
}
4 changes: 2 additions & 2 deletions og.views.inc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function og_field_views_data(FieldStorageConfigInterface $field_storage) {
'@label' => $target_entity_type->getLabel(),
'@field_name' => $field_name,
];
$data[$table_name][$field_name]['relationship'] = array(
$data[$table_name][$field_name]['relationship'] = [
'title' => t('@label referenced from @field_name', $args),
'label' => t('@field_name: @label', $args),
'group' => $entity_type->getLabel(),
Expand All @@ -62,7 +62,7 @@ function og_field_views_data(FieldStorageConfigInterface $field_storage) {
'entity type' => $target_entity_type_id,
'base field' => $target_entity_type->getKey('id'),
'relationship field' => $field_name . '_target_id',
);
];
// Provide a reverse relationship for the entity type that is referenced
// by the field.
$args['@entity'] = $entity_type->getLabel();
Expand Down
6 changes: 4 additions & 2 deletions src/Access/GroupCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@ public function __construct(EntityTypeManagerInterface $entity_type_manager, OgA
* The currently logged in user.
* @param \Symfony\Component\Routing\Route $route
* The route to check against.
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The rout match object.
* @param string $entity_type_id
* (optional) The entity type ID.
* @param string $entity_id
* (optional) The entity ID. If the ID is not sent, the access method will
* try to extract it from the route matcher.
* The entity ID. If the ID is not sent, the access method will try to
* extract it from the route matcher.
*
* @return \Drupal\Core\Access\AccessResultInterface
* The access result.
Expand Down
2 changes: 1 addition & 1 deletion src/Cache/Context/OgMembershipStateCacheContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function getContext() {
OgMembershipInterface::STATE_BLOCKED,
];

/** @var OgMembershipInterface $membership */
/** @var \Drupal\og\OgMembershipInterface $membership */
$membership = $this->membershipManager->getMembership($group, $this->user, $states);
return $membership ? $membership->getState() : self::NO_CONTEXT;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/SubscriptionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public function unsubscribe(ContentEntityInterface $group) {

if ($group instanceof EntityOwnerInterface && $group->getOwnerId() == $user->id()) {
// The user is the manager of the group.
drupal_set_message($this->t('As the manager of %group, you can not leave the group.', array('%group' => $group->label())));
drupal_set_message($this->t('As the manager of %group, you can not leave the group.', ['%group' => $group->label()]));

return new RedirectResponse($group->toUrl()
->setAbsolute()
Expand Down
6 changes: 3 additions & 3 deletions src/Event/PermissionEventInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function getPermission($name);
* @param string $entity_type_id
* The group content entity type ID to which this permission applies.
* @param string $bundle_id
* The group content bundle ID to which this permission applies.
* The group content bundle ID to which this permission applies.
* @param string $operation
* The entity operation to which this permission applies.
* @param bool $owner
Expand Down Expand Up @@ -93,7 +93,7 @@ public function deletePermission($name);
* @param string $entity_type_id
* The group content entity type ID to which this permission applies.
* @param string $bundle_id
* The group content bundle ID to which this permission applies.
* The group content bundle ID to which this permission applies.
* @param string $operation
* The entity operation to which this permission applies.
* @param bool $owner
Expand All @@ -119,7 +119,7 @@ public function hasPermission($name);
* @param string $entity_type_id
* The group content entity type ID to which this permission applies.
* @param string $bundle_id
* The group content bundle ID to which this permission applies.
* The group content bundle ID to which this permission applies.
* @param string $operation
* The entity operation to which this permission applies.
* @param bool $owner
Expand Down
8 changes: 4 additions & 4 deletions src/Form/GroupSubscribeForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function getFormId() {
* The confirmation question.
*/
public function getQuestion() {
/** @var OgMembershipInterface $membership */
/** @var \Drupal\og\OgMembershipInterface $membership */
$membership = $this->entity;
/** @var EntityInterface $group */
$group = $membership->getGroup();
Expand Down Expand Up @@ -104,7 +104,7 @@ public function getCancelUrl() {
public function buildForm(array $form, FormStateInterface $form_state) {
$state = $this->isStateActive() ? OgMembershipInterface::STATE_ACTIVE : OgMembershipInterface::STATE_PENDING;

/** @var OgMembershipInterface $membership */
/** @var \Drupal\og\OgMembershipInterface $membership */
$membership = $this->entity;
$membership->setState($state);

Expand Down Expand Up @@ -167,7 +167,7 @@ protected function actions(array $form, FormStateInterface $form_state) {
* True if the state is active.
*/
public function isStateActive() {
/** @var OgMembershipInterface $membership */
/** @var \Drupal\og\OgMembershipInterface $membership */
$membership = $this->getEntity();

/** @var EntityInterface $group */
Expand Down Expand Up @@ -195,7 +195,7 @@ public function isStateActive() {
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
/** @var OgMembershipInterface $membership */
/** @var \Drupal\og\OgMembershipInterface $membership */
$membership = $this->getEntity();

/** @var EntityInterface $group */
Expand Down
2 changes: 1 addition & 1 deletion src/GroupTypeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class GroupTypeManager {
* The entity type manager.
* @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info
* The service providing information about bundles.
* @param EventDispatcherInterface $event_dispatcher
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
* The event dispatcher.
* @param \Drupal\Core\State\StateInterface $state
* The state service.
Expand Down
2 changes: 1 addition & 1 deletion src/MembershipManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function getMembership(EntityInterface $group, AccountInterface $user, ar
* {@inheritdoc}
*/
public function createMembership(EntityInterface $group, AccountInterface $user, $membership_type = OgMembershipInterface::TYPE_DEFAULT) {
/** @var OgMembershipInterface $membership */
/** @var \Drupal\og\Entity\OgMembershipInterface $membership */
$membership = OgMembership::create(['type' => $membership_type]);
$membership
->setUser($user)
Expand Down
4 changes: 2 additions & 2 deletions src/Og.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ public static function groupTypeManager() {
public static function invalidateCache() {
// @todo We should not be using drupal_static() review and remove.
// Reset static cache.
$caches = array(
$caches = [
'og_user_access',
'og_user_access_alter',
'og_role_permissions',
Expand All @@ -323,7 +323,7 @@ public static function invalidateCache() {
'og_get_membership',
'og_get_field_og_membership_properties',
'og_get_user_roles',
);
];

foreach ($caches as $cache) {
drupal_static_reset($cache);
Expand Down
4 changes: 2 additions & 2 deletions src/OgAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,11 @@ public function userAccess(EntityInterface $group, $operation, AccountInterface
// pass them along to the implementing modules.
$alterable_permissions = $this->getPermissionsCache($group, $user, TRUE);

$context = array(
$context = [
'operation' => $operation,
'group' => $group,
'user' => $user,
);
];
$this->moduleHandler->alter('og_user_access', $alterable_permissions['permissions'], $cacheable_metadata, $context);

$this->setPermissionCache($group, $user, FALSE, $alterable_permissions['permissions'], $alterable_permissions['is_admin'], $cacheable_metadata);
Expand Down
4 changes: 2 additions & 2 deletions src/OgFieldBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function setFieldName($field_name) {
/**
* {@inheritdoc}
*/
public function getFieldStorageBaseDefinition(array $values = array()) {
public function getFieldStorageBaseDefinition(array $values = []) {
$values += [
'entity_type' => $this->getEntityType(),
'field_name' => $this->getFieldName(),
Expand All @@ -106,7 +106,7 @@ public function getFieldStorageBaseDefinition(array $values = array()) {
/**
* {@inheritdoc}
*/
public function getFieldBaseDefinition(array $values = array()) {
public function getFieldBaseDefinition(array $values = []) {
$values += [
'bundle' => $this->getBundle(),
'entity_type' => $this->getEntityType(),
Expand Down
2 changes: 1 addition & 1 deletion src/OgNodePermissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class OgNodePermissions extends NodePermissions {
* @see \Drupal\user\PermissionHandlerInterface::getPermissions()
*/
public function nodeTypePermissions() {
$perms = array();
$perms = [];

// Generate node permissions for all group content node types.
foreach (NodeType::loadMultiple() as $bundle) {
Expand Down
2 changes: 1 addition & 1 deletion src/OgRoleManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class OgRoleManager implements OgRoleManagerInterface {
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param EventDispatcherInterface $event_dispatcher
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
* The event dispatcher.
* @param \Drupal\og\PermissionManagerInterface $permission_manager
* The OG permission manager.
Expand Down
4 changes: 2 additions & 2 deletions src/OgRoleManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ public function getRequiredDefaultRoles();
* Returns all the roles of a provided group.
*
* @param string $entity_type_id
* The entity type id of the group.
* The entity type id of the group.
* @param string $bundle
* The bundle of the group.
* The bundle of the group.
*
* @return \Drupal\og\OgRoleInterface[]
* An array of roles indexed by their ids.
Expand Down
6 changes: 3 additions & 3 deletions src/Plugin/Block/RecentGroupContentBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class RecentGroupContentBlock extends BlockBase implements ContainerFactoryPlugi
/**
* The bundle information service.
*
* @var EntityTypeBundleInfoInterface
* @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface
*/
protected $entityTypeBundleInfo;

Expand Down Expand Up @@ -156,12 +156,12 @@ public function blockForm($form, FormStateInterface $form_state) {
$form['entity_type']['#options'] = $entity_type_options;

$range = range(2, 20);
$form['count'] = array(
$form['count'] = [
'#type' => 'select',
'#title' => $this->t('Number of results to show'),
'#default_value' => $this->configuration['count'],
'#options' => array_combine($range, $range),
);
];

return $form;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin/EntityReferenceSelection/OgSelection.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class OgSelection extends DefaultSelection {
/**
* Get the selection handler of the field.
*
* @return DefaultSelection
* @return \Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection
* Returns the selection handler.
*/
public function getSelectionHandler() {
Expand Down
Loading

0 comments on commit 9d81808

Please sign in to comment.