diff --git a/src/Entity/Profile.php b/src/Entity/Profile.php index 6902ec4..c14b284 100644 --- a/src/Entity/Profile.php +++ b/src/Entity/Profile.php @@ -10,7 +10,6 @@ use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\Entity\ContentEntityBase; use Drupal\user\UserInterface; - /** * Defines the profile entity class. * diff --git a/src/Entity/ProfileType.php b/src/Entity/ProfileType.php index db8dc04..af6148a 100644 --- a/src/Entity/ProfileType.php +++ b/src/Entity/ProfileType.php @@ -170,5 +170,4 @@ class ProfileType extends ConfigEntityBundleBase implements ProfileTypeInterface \Drupal::service('router.builder')->rebuild(); } - } diff --git a/src/Form/ProfileTypeForm.php b/src/Form/ProfileTypeForm.php index 840f166..e9e066e 100644 --- a/src/Form/ProfileTypeForm.php +++ b/src/Form/ProfileTypeForm.php @@ -8,7 +8,6 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\field_ui\FieldUI; use Drupal\user\Entity\Role; - /** * Form controller for profile type forms. */ diff --git a/src/Plugin/EntityReferenceSelection/ProfileSelection.php b/src/Plugin/EntityReferenceSelection/ProfileSelection.php index 55c5b64..a3e4bca 100644 --- a/src/Plugin/EntityReferenceSelection/ProfileSelection.php +++ b/src/Plugin/EntityReferenceSelection/ProfileSelection.php @@ -26,4 +26,5 @@ class ProfileSelection extends DefaultSelection { $form['target_bundles']['#title'] = $this->t('Profile types'); return $form; } + } diff --git a/src/ProfileAccessControlHandler.php b/src/ProfileAccessControlHandler.php index e3d7a51..9d6f8f2 100644 --- a/src/ProfileAccessControlHandler.php +++ b/src/ProfileAccessControlHandler.php @@ -6,7 +6,6 @@ use Drupal\Core\Access\AccessResult; use Drupal\Core\Entity\EntityAccessControlHandler; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Session\AccountInterface; -use Drupal\user\Entity\User; use Drupal\profile\Entity\ProfileType; /** diff --git a/src/ProfileHtmlRouteProvider.php b/src/ProfileHtmlRouteProvider.php index 8f1960d..dd10ea7 100644 --- a/src/ProfileHtmlRouteProvider.php +++ b/src/ProfileHtmlRouteProvider.php @@ -22,8 +22,9 @@ class ProfileHtmlRouteProvider extends DefaultHtmlRouteProvider { foreach (ProfileType::loadMultiple() as $profile_type) { $route = (new Route( "/user/{user}/{profile_type}", - ['_controller' => '\Drupal\profile\Controller\ProfileController::userProfileForm', - '_title_callback' => '\Drupal\profile\Controller\ProfileController::addPageTitle' + [ + '_controller' => '\Drupal\profile\Controller\ProfileController::userProfileForm', + '_title_callback' => '\Drupal\profile\Controller\ProfileController::addPageTitle', ], ['_profile_access_check' => 'add'], [ diff --git a/src/ProfileStorage.php b/src/ProfileStorage.php index b98694b..5afeafe 100644 --- a/src/ProfileStorage.php +++ b/src/ProfileStorage.php @@ -28,10 +28,10 @@ class ProfileStorage extends SqlContentEntityStorage implements ProfileStorageIn */ public function loadMultipleByUser(AccountInterface $account, $profile_type, $active = PROFILE_ACTIVE) { return $this->loadByProperties([ - 'uid' => $account->id(), - 'type' => $profile_type, - 'status' => $active, - ]); + 'uid' => $account->id(), + 'type' => $profile_type, + 'status' => $active, + ]); } /** diff --git a/tests/src/Functional/ProfileFieldAccessTest.php b/tests/src/Functional/ProfileFieldAccessTest.php index bc5844b..5b66a8d 100644 --- a/tests/src/Functional/ProfileFieldAccessTest.php +++ b/tests/src/Functional/ProfileFieldAccessTest.php @@ -10,11 +10,15 @@ namespace Drupal\Tests\profile\Functional; class ProfileFieldAccessTest extends ProfileTestBase { /** + * Access the field for webuser. + * * @var \Drupal\user\Entity\User */ protected $webUser; /** + * Access the field for otheruser. + * * @var \Drupal\user\Entity\User */ protected $otherUser; diff --git a/tests/src/Functional/ProfileTestBase.php b/tests/src/Functional/ProfileTestBase.php index 8707043..7ab6c25 100644 --- a/tests/src/Functional/ProfileTestBase.php +++ b/tests/src/Functional/ProfileTestBase.php @@ -8,7 +8,6 @@ use Drupal\Core\Session\AccountInterface; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; use Drupal\profile\ProfileTestTrait; -use Drupal\simpletest\WebTestBase; use Drupal\Tests\BrowserTestBase; /** diff --git a/tests/src/Kernel/ProfileAccessTest.php b/tests/src/Kernel/ProfileAccessTest.php index cd570a6..efca0b0 100644 --- a/tests/src/Kernel/ProfileAccessTest.php +++ b/tests/src/Kernel/ProfileAccessTest.php @@ -20,7 +20,13 @@ class ProfileAccessTest extends EntityKernelTestBase { * * @var array */ - public static $modules = ['user', 'system', 'field', 'text', 'profile', 'views']; + public static $modules = ['user', + 'system', + 'field', + 'text', + 'profile', + 'views', + ]; /** * The access control handler. @@ -76,7 +82,6 @@ class ProfileAccessTest extends EntityKernelTestBase { $web_user1 )); - // Test user with permission to only add own profile. $web_user2 = $this->createUser([], ["add own {$this->type->id()} profile"]); $web_user1->addRole($web_user2->get('roles')->first()->target_id); diff --git a/tests/src/Kernel/ProfileRoleAccessTest.php b/tests/src/Kernel/ProfileRoleAccessTest.php index 6c5e46c..7966ad2 100644 --- a/tests/src/Kernel/ProfileRoleAccessTest.php +++ b/tests/src/Kernel/ProfileRoleAccessTest.php @@ -21,7 +21,13 @@ class ProfileRoleAccessTest extends EntityKernelTestBase { * * @var array */ - public static $modules = ['user', 'system', 'field', 'text', 'profile', 'views']; + public static $modules = ['user', + 'system', + 'field', + 'text', + 'profile', + 'views', + ]; /** * Randomly generated profile type entity. @@ -65,6 +71,8 @@ class ProfileRoleAccessTest extends EntityKernelTestBase { protected $role2; /** + * Profile access controller handler. + * * @var \Drupal\profile\ProfileAccessControlHandler */ protected $accessHandler; @@ -96,8 +104,9 @@ class ProfileRoleAccessTest extends EntityKernelTestBase { } /** - * Tests add profile form access for a profile type that does not require - * users to have a role. + * Tests add profile form access for a profile type. + * + * That does not require users to have a role. */ public function testProfileWithNoRoles() { // Create user with add own profile permissions. @@ -105,6 +114,11 @@ class ProfileRoleAccessTest extends EntityKernelTestBase { $this->assertTrue($this->accessHandler->createAccess($this->type1->id(), $web_user1)); } + /** + * Tests add profile from access for a profile type. + * + * That have a loked role. + */ public function testLockedRoles() { $locked_role_type = $this->createProfileType(NULL, NULL, FALSE, [AccountInterface::AUTHENTICATED_ROLE]); // Create user with add own profile permissions. @@ -113,8 +127,9 @@ class ProfileRoleAccessTest extends EntityKernelTestBase { } /** - * Tests add profile form access for a profile type that requires users to - * have a single role. + * Tests add profile form access for a profile type. + * + * That requires users to have a single role. */ public function testProfileWithSingleRole() { // Create user with add own profile permissions. @@ -145,8 +160,9 @@ class ProfileRoleAccessTest extends EntityKernelTestBase { } /** - * Tests add profile form access for a profile type that requires users to - * have one of multiple roles. + * Tests add profile form access for a profile type. + * + * That requires users to have one of multiple roles. */ public function testProfileWithAllRoles() { // Create user with add own profile permissions. diff --git a/tests/src/Kernel/ProfileTest.php b/tests/src/Kernel/ProfileTest.php index f09db2d..30c6e9b 100644 --- a/tests/src/Kernel/ProfileTest.php +++ b/tests/src/Kernel/ProfileTest.php @@ -6,7 +6,6 @@ use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\KernelTests\Core\Entity\EntityKernelTestBase; use Drupal\profile\Entity\Profile; use Drupal\profile\Entity\ProfileType; -use Drupal\profile\ProfileTestTrait; /** * Tests basic functionality of profiles. @@ -81,7 +80,6 @@ class ProfileTest extends EntityKernelTestBase { $types[$id]->save(); } - // Create a new profile. /** @var \Drupal\profile\Entity\ProfileInterface $profile */ $profile = $this->profileStorage->create($expected = [ diff --git a/tests/src/Kernel/ProfileViewTest.php b/tests/src/Kernel/ProfileViewTest.php index e820b08..6324242 100644 --- a/tests/src/Kernel/ProfileViewTest.php +++ b/tests/src/Kernel/ProfileViewTest.php @@ -29,6 +29,9 @@ class ProfileViewTest extends ViewsKernelTestBase { 'users', ]; + /** + * {@inheritdoc} + */ protected function setUp($import_test_views = TRUE) { parent::setUp($import_test_views);