Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/bundle/Controller/ContentEditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@

class ContentEditController extends Controller
{
/** @var \Ibexa\Contracts\Core\Repository\ContentTypeService */
private $contentTypeService;
private ContentTypeService $contentTypeService;

/** @var \Ibexa\Contracts\Core\Repository\ContentService */
private $contentService;
private ContentService $contentService;

/** @var \Ibexa\ContentForms\Form\ActionDispatcher\ActionDispatcherInterface */
private $contentActionDispatcher;
private ActionDispatcherInterface $contentActionDispatcher;

public function __construct(
ContentTypeService $contentTypeService,
Expand Down
24 changes: 8 additions & 16 deletions src/bundle/Controller/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,21 @@

class UserController extends Controller
{
/** @var \Ibexa\Contracts\Core\Repository\ContentTypeService */
private $contentTypeService;
private ContentTypeService $contentTypeService;

/** @var \Ibexa\Contracts\Core\Repository\UserService */
private $userService;
private UserService $userService;

/** @var \Ibexa\Contracts\Core\Repository\LocationService */
private $locationService;
private LocationService $locationService;

/** @var \Ibexa\Contracts\Core\Repository\LanguageService */
private $languageService;
private LanguageService $languageService;

/** @var \Ibexa\ContentForms\Form\ActionDispatcher\ActionDispatcherInterface */
private $userActionDispatcher;
private ActionDispatcherInterface $userActionDispatcher;

/** @var \Ibexa\Contracts\Core\Repository\PermissionResolver */
private $permissionResolver;
private PermissionResolver $permissionResolver;

/** @var \Ibexa\Core\MVC\Symfony\Locale\UserLanguagePreferenceProviderInterface */
private $userLanguagePreferenceProvider;
private UserLanguagePreferenceProviderInterface $userLanguagePreferenceProvider;

/** @var \Ibexa\Contracts\ContentForms\Content\Form\Provider\GroupedContentFormFieldsProviderInterface */
private $groupedContentFormFieldsProvider;
private GroupedContentFormFieldsProviderInterface $groupedContentFormFieldsProvider;

private ContentService $contentService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ContentEdit extends AbstractParser
*
* @param \Symfony\Component\Config\Definition\Builder\NodeBuilder $nodeBuilder Node just under ezpublish.system.<siteaccess>
*/
public function addSemanticConfig(NodeBuilder $nodeBuilder)
public function addSemanticConfig(NodeBuilder $nodeBuilder): void
{
$nodeBuilder
->arrayNode('content_edit')
Expand Down Expand Up @@ -48,7 +48,7 @@ public function addSemanticConfig(NodeBuilder $nodeBuilder)
->end();
}

public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer)
public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer): void
{
if (empty($scopeSettings['content_edit'])) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class UserEdit extends AbstractParser
*
* @param \Symfony\Component\Config\Definition\Builder\NodeBuilder $nodeBuilder Node just under ezpublish.system.<siteaccess>
*/
public function addSemanticConfig(NodeBuilder $nodeBuilder)
public function addSemanticConfig(NodeBuilder $nodeBuilder): void
{
$nodeBuilder
->arrayNode('user_edit')
Expand All @@ -40,7 +40,7 @@ public function addSemanticConfig(NodeBuilder $nodeBuilder)
->end();
}

public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer)
public function mapConfig(array &$scopeSettings, $currentScope, ContextualizerInterface $contextualizer): void
{
if (empty($scopeSettings['user_edit'])) {
return;
Expand Down
32 changes: 14 additions & 18 deletions src/lib/Behat/Context/ContentEditContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ final class ContentEditContext extends MinkContext implements Context, SnippetAc
{
/**
* Name of the content that was created using the edit form. Used to validate that the content was created.
*
* @var string
*/
private $createdContentName;
private ?string $createdContentName = null;

/**
* @var \Ibexa\ContentForms\Behat\Context\ContentTypeContext
Expand All @@ -30,13 +28,11 @@ final class ContentEditContext extends MinkContext implements Context, SnippetAc

/**
* Identifier of the FieldDefinition used to cover validation.
*
* @var string
*/
private static $constrainedFieldIdentifier = 'constrained_field';
private static string $constrainedFieldIdentifier = 'constrained_field';

/** @BeforeScenario */
public function gatherContexts(BeforeScenarioScope $scope)
public function gatherContexts(BeforeScenarioScope $scope): void
{
$environment = $scope->getEnvironment();

Expand All @@ -47,15 +43,15 @@ public function gatherContexts(BeforeScenarioScope $scope)
* @Then /^I should see a folder content edit form$/
* @Then /^I should see a content edit form$/
*/
public function iShouldSeeAContentEditForm()
public function iShouldSeeAContentEditForm(): void
{
$this->assertSession()->elementExists('css', 'form[name=ezplatform_content_forms_content_edit]');
}

/**
* @Then /^I am on the View of the Content that was published$/
*/
public function iAmOnTheViewOfTheContentThatWasPublished()
public function iAmOnTheViewOfTheContentThatWasPublished(): void
{
if (!isset($this->createdContentName)) {
throw new \Exception('No created content name set');
Expand All @@ -68,7 +64,7 @@ public function iAmOnTheViewOfTheContentThatWasPublished()
/**
* @When /^I fill in the folder edit form$/
*/
public function iFillInTheFolderEditForm()
public function iFillInTheFolderEditForm(): void
{
// will only work for single value fields
$this->createdContentName = 'Behat content edit @' . microtime(true);
Expand All @@ -78,7 +74,7 @@ public function iFillInTheFolderEditForm()
/**
* @Given /^that I have permission to create folders$/
*/
public function thatIHavePermissionToCreateFolders()
public function thatIHavePermissionToCreateFolders(): void
{
$this->visit('/login');
$this->fillField('_username', 'admin');
Expand All @@ -89,15 +85,15 @@ public function thatIHavePermissionToCreateFolders()
/**
* @Given /^that I have permission to create content of this type$/
*/
public function thatIHavePermissionToCreateContentOfThisType()
public function thatIHavePermissionToCreateContentOfThisType(): void
{
$this->thatIHavePermissionToCreateFolders();
}

/**
* @When /^I go to the content creation page for this type$/
*/
public function iGoToTheContentCreationPageForThisType()
public function iGoToTheContentCreationPageForThisType(): void
{
$uri = sprintf(
'/content/create/nodraft/%s/eng-GB/2',
Expand All @@ -110,7 +106,7 @@ public function iGoToTheContentCreationPageForThisType()
/**
* @Given /^I fill in the constrained field with an invalid value$/
*/
public function iFillInTheConstrainedFieldWithAnInvalidValue()
public function iFillInTheConstrainedFieldWithAnInvalidValue(): void
{
$this->fillField(
sprintf(
Expand All @@ -132,7 +128,7 @@ public function iFillInTheConstrainedFieldWithAnInvalidValue()
/**
* @Then /^I am shown the content creation form$/
*/
public function iAmShownTheContentCreationForm()
public function iAmShownTheContentCreationForm(): void
{
$uri = sprintf(
'/content/create/nodraft/%s/eng-GB/2',
Expand All @@ -151,7 +147,7 @@ public function iAmShownTheContentCreationForm()
/**
* @Given /^there is a relevant error message linked to the invalid field$/
*/
public function thereIsARelevantErrorMessageLinkedToTheInvalidField()
public function thereIsARelevantErrorMessageLinkedToTheInvalidField(): void
{
$selector = sprintf(
'#ezplatform_content_forms_content_edit_fieldsData_%s div ul li',
Expand All @@ -165,7 +161,7 @@ public function thereIsARelevantErrorMessageLinkedToTheInvalidField()
/**
* @Given /^that there is a content type with any kind of constraints on a Field Definition$/
*/
public function thereIsAContentTypeWithAnyKindOfConstraintsOnAFieldDefinition()
public function thereIsAContentTypeWithAnyKindOfConstraintsOnAFieldDefinition(): void
{
$contentTypeCreateStruct = $this->contentTypeContext->newContentTypeCreateStruct();

Expand All @@ -188,7 +184,7 @@ public function thereIsAContentTypeWithAnyKindOfConstraintsOnAFieldDefinition()
/**
* @When /^a content creation form is displayed$/
*/
public function aContentCreationFormIsDisplayed()
public function aContentCreationFormIsDisplayed(): void
{
$this->visit('/content/create/nodraft/folder/eng-GB/2');
}
Expand Down
20 changes: 9 additions & 11 deletions src/lib/Behat/Context/ContentTypeContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

final class ContentTypeContext extends RawMinkContext implements Context, SnippetAcceptingContext
{
/** @var \Ibexa\Contracts\Core\Repository\ContentTypeService */
private $contentTypeService;
private ContentTypeService $contentTypeService;

/**
* Current content type within this context.
Expand All @@ -32,13 +31,12 @@ final class ContentTypeContext extends RawMinkContext implements Context, Snippe
*/
private $currentContentType;

/** @var \Ibexa\Contracts\Core\Repository\PermissionResolver */
private $permissionResolver;
private PermissionResolver $permissionResolver;

/**
* Default Administrator user id.
*/
private $adminUserId = 14;
private int $adminUserId = 14;

public function __construct(PermissionResolver $permissionResolver, ContentTypeService $contentTypeService)
{
Expand All @@ -50,7 +48,7 @@ public function __construct(PermissionResolver $permissionResolver, ContentTypeS
/**
* @Given /^there is a content type "([^"]*)" with the id "([^"]*)"$/
*/
public function thereIsAContentTypeWithId($contentTypeIdentifier, $id)
public function thereIsAContentTypeWithId(string $contentTypeIdentifier, $id): void
{
try {
$contentType = $this->contentTypeService->loadContentTypeByIdentifier($contentTypeIdentifier);
Expand All @@ -63,7 +61,7 @@ public function thereIsAContentTypeWithId($contentTypeIdentifier, $id)
/**
* @Given I remove :fieldIdentifier field from :contentTypeIdentifier content type
*/
public function iRemoveFieldFromContentType($fieldIdentifier, $contentTypeIdentifier)
public function iRemoveFieldFromContentType($fieldIdentifier, string $contentTypeIdentifier): void
{
$contentType = $this->contentTypeService->loadContentTypeByIdentifier($contentTypeIdentifier);
$contentTypeDraft = $this->contentTypeService->createContentTypeDraft($contentType);
Expand All @@ -74,7 +72,7 @@ public function iRemoveFieldFromContentType($fieldIdentifier, $contentTypeIdenti
$this->contentTypeService->publishContentTypeDraft($contentTypeDraft);
}

public function addFieldsTo($contentTypeIdentifier, array $fieldDefinitions)
public function addFieldsTo(string $contentTypeIdentifier, array $fieldDefinitions): void
{
$contentType = $this->contentTypeService->loadContentTypeByIdentifier($contentTypeIdentifier);
$contentTypeDraft = $this->contentTypeService->createContentTypeDraft($contentType);
Expand All @@ -100,7 +98,7 @@ public function getCurrentContentType()
return $this->currentContentType;
}

public function createContentType(ContentTypeCreateStruct $struct)
public function createContentType(ContentTypeCreateStruct $struct): void
{
if (!isset($struct->mainLanguageCode)) {
$struct->mainLanguageCode = 'eng-GB';
Expand All @@ -125,14 +123,14 @@ public function createContentType(ContentTypeCreateStruct $struct)
*
* @return \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeCreateStruct
*/
public function newContentTypeCreateStruct($identifier = null)
public function newContentTypeCreateStruct($identifier = null): ContentTypeCreateStruct
{
return $this->contentTypeService->newContentTypeCreateStruct(
$identifier ?: $identifier = str_replace('.', '', uniqid('content_type_', true))
);
}

public function updateFieldDefinition($identifier, FieldDefinitionUpdateStruct $fieldDefinitionUpdateStruct)
public function updateFieldDefinition($identifier, FieldDefinitionUpdateStruct $fieldDefinitionUpdateStruct): void
{
$contentTypeDraft = $this->contentTypeService->createContentTypeDraft($this->currentContentType);

Expand Down
24 changes: 12 additions & 12 deletions src/lib/Behat/Context/FieldTypeFormContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

final class FieldTypeFormContext extends RawMinkContext implements SnippetAcceptingContext
{
private static $fieldIdentifier = 'field';
private static string $fieldIdentifier = 'field';

private static $fieldTypeIdentifierMap = [
private static array $fieldTypeIdentifierMap = [
'user' => 'ezuser',
'textline' => 'ezstring',
'selection' => 'ezselection',
Expand All @@ -30,7 +30,7 @@ final class FieldTypeFormContext extends RawMinkContext implements SnippetAccept
private $contentTypeContext;

/** @BeforeScenario */
public function gatherContexts(BeforeScenarioScope $scope)
public function gatherContexts(BeforeScenarioScope $scope): void
{
$environment = $scope->getEnvironment();
$this->contentTypeContext = $environment->getContext(ContentTypeContext::class);
Expand All @@ -40,7 +40,7 @@ public function gatherContexts(BeforeScenarioScope $scope)
* @Given a content type with a(n) :fieldTypeIdentifier field definition
* @Given a content type :contentTypeName with a(n) :fieldTypeIdentifier field definition
*/
public function aContentTypeWithAGivenFieldDefinition($fieldTypeIdentifier, $contentTypeName = null)
public function aContentTypeWithAGivenFieldDefinition($fieldTypeIdentifier, $contentTypeName = null): void
{
if (isset(self::$fieldTypeIdentifierMap[$fieldTypeIdentifier])) {
$fieldTypeIdentifier = self::$fieldTypeIdentifierMap[$fieldTypeIdentifier];
Expand Down Expand Up @@ -80,7 +80,7 @@ public function aContentTypeWithAGivenFieldDefinition($fieldTypeIdentifier, $con
/**
* @When /^I view the edit form for this field$/
*/
public function iEditOrCreateContentOfThisType()
public function iEditOrCreateContentOfThisType(): void
{
$this->visitPath(
sprintf(
Expand All @@ -93,7 +93,7 @@ public function iEditOrCreateContentOfThisType()
/**
* @When /^I view the edit user form for this field$/
*/
public function iEditOrCreateContentOfUserType()
public function iEditOrCreateContentOfUserType(): void
{
$this->visitPath(
sprintf(
Expand All @@ -106,7 +106,7 @@ public function iEditOrCreateContentOfUserType()
/**
* @Then the edit form should contain an identifiable widget for :fieldTypeIdentifier field definition
*/
public function theEditFormShouldContainAFieldsetNamedAfterTheFieldDefinition($fieldTypeIdentifier)
public function theEditFormShouldContainAFieldsetNamedAfterTheFieldDefinition(string $fieldTypeIdentifier): void
{
$this->assertSession()->elementTextContains(
'css',
Expand All @@ -118,7 +118,7 @@ public function theEditFormShouldContainAFieldsetNamedAfterTheFieldDefinition($f
/**
* @Given it should contain a :type input field
*/
public function itShouldContainAGivenTypeInputField($inputType)
public function itShouldContainAGivenTypeInputField($inputType): void
{
$this->assertSession()->elementExists(
'css',
Expand All @@ -134,7 +134,7 @@ public function itShouldContainAGivenTypeInputField($inputType)
/**
* @Given /^it should contain the following set of labels, and input fields of the following types:$/
*/
public function itShouldContainTheFollowingSetOfLabelsAndInputFieldsTypes(TableNode $table)
public function itShouldContainTheFollowingSetOfLabelsAndInputFieldsTypes(TableNode $table): void
{
$inputNodeElements = $this->getSession()->getPage()->findAll(
'css',
Expand Down Expand Up @@ -162,7 +162,7 @@ public function itShouldContainTheFollowingSetOfLabelsAndInputFieldsTypes(TableN
* @Given /^the field definition is required$/
* @Given /^the field definition is marked as required$/
*/
public function theFieldDefinitionIsMarkedAsRequired()
public function theFieldDefinitionIsMarkedAsRequired(): void
{
$this->contentTypeContext->updateFieldDefinition(
self::$fieldIdentifier,
Expand All @@ -173,7 +173,7 @@ public function theFieldDefinitionIsMarkedAsRequired()
/**
* @Then the value input fields for :fieldIdentifier field should be flagged as required
*/
public function theInputFieldsShouldBeFlaggedAsRequired(string $fieldTypeIdentifier)
public function theInputFieldsShouldBeFlaggedAsRequired(string $fieldTypeIdentifier): void
{
$inputNodeElements = $this->getSession()->getPage()->findAll(
'css',
Expand Down Expand Up @@ -212,7 +212,7 @@ public function theInputFieldsShouldBeFlaggedAsRequired(string $fieldTypeIdentif
* @param $option string The field definition option
* @param $value mixed The option value
*/
public function setFieldDefinitionOption($option, $value)
public function setFieldDefinitionOption($option, $value): void
{
$this->contentTypeContext->updateFieldDefinition(
self::$fieldIdentifier,
Expand Down
Loading
Loading