Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add types #22

Merged
merged 21 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
"symfony/security-core": "^5.2|^6.2",
"symfony/serializer": "^5.2|^6.2",
"twig/twig": "^2.4|^3.0",
"symfony/translation": "^5.2|^6.2"
"symfony/translation": "^5.2|^6.2",
"jms/translation-bundle": "^1.8",
"doctrine/annotations": "^2.0"
natewiebe13 marked this conversation as resolved.
Show resolved Hide resolved
},
"require-dev": {
"ext-intl": "*",
Expand Down
2 changes: 1 addition & 1 deletion src/APYDataGridBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

class APYDataGridBundle extends Bundle
{
public function build(ContainerBuilder $container)
public function build(ContainerBuilder $container): void
{
parent::build($container);

Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/APYDataGridExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

class APYDataGridExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container)
public function load(array $configs, ContainerBuilder $container): void
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Compiler/GridExtensionPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

class GridExtensionPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if (false === $container->hasDefinition('grid')) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Compiler/GridPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class GridPass implements CompilerPassInterface
*
* @api
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if (!$container->hasDefinition('apy_grid.registry')) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Compiler/TranslationPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class TranslationPass implements CompilerPassInterface
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if (!$container->hasDefinition('jms_translation.extractor.file_extractor')) {
return;
Expand Down
6 changes: 3 additions & 3 deletions src/Grid/AbstractType.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ abstract class AbstractType implements GridTypeInterface
/**
* {@inheritdoc}
*/
public function buildGrid(GridBuilder $builder, array $options = [])
public function buildGrid(GridBuilder $builder, array $options = []): void
{
}

/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
}

/**
* {@inheritdoc}
*/
abstract public function getName();
abstract public function getName(): string;
}
7 changes: 1 addition & 6 deletions src/Grid/Action/DeleteMassAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@

class DeleteMassAction extends MassAction
{
/**
* Default DeleteMassAction constructor.
*
* @param bool $confirm Show confirm message if true
*/
public function __construct($confirm = false)
public function __construct(bool $confirm = false)
{
parent::__construct('Delete', 'static::deleteAction', $confirm);
}
Expand Down
158 changes: 36 additions & 122 deletions src/Grid/Action/MassAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,187 +14,101 @@

class MassAction implements MassActionInterface
{
/** @var string */
protected $title;

/** @var string|null */
protected $callback;

/** @var bool */
protected $confirm;

/** @var string */
protected $confirmMessage;

/** @var array */
protected $parameters = [];

/** @var string|null */
protected $role;

/**
* Default MassAction constructor.
*
* @param string $title Title of the mass action
* @param string $callback Callback of the mass action
* @param bool $confirm Show confirm message if true
* @param array $parameters Additional parameters
* @param string $role Security role
*/
public function __construct($title, $callback = null, $confirm = false, $parameters = [], $role = null)
{
$this->title = $title;
$this->callback = $callback;
$this->confirm = $confirm;
private string $title;

private \Closure|string|null $callback;

private bool $confirm;

private string $confirmMessage;

private array $parameters = [];

private ?string $role;

public function __construct(
string $title,
?string $callback = null,
natewiebe13 marked this conversation as resolved.
Show resolved Hide resolved
bool $confirm = false,
array $parameters = [],
?string $role = null
) {
$this->title = $title;
$this->callback = $callback;
$this->confirm = $confirm;
$this->confirmMessage = 'Do you want to ' . strtolower($title) . ' the selected rows?';
$this->parameters = $parameters;
$this->role = $role;
$this->parameters = $parameters;
$this->role = $role;
}

// @todo: has this setter sense? we passed the title from constructor
/**
* Set action title.
*
* @param string $title
*
* @return self
*/
public function setTitle($title)
public function setTitle(string $title): self
{
$this->title = $title;

return $this;
}

/**
* get action title.
*
* @return string
*/
public function getTitle()
public function getTitle(): string
{
return $this->title;
}

/**
* Set action callback.
*
* @param string $callback
*
* @return self
*/
public function setCallback($callback)
public function setCallback(\Closure|string $callback): self
natewiebe13 marked this conversation as resolved.
Show resolved Hide resolved
{
$this->callback = $callback;

return $this;
}

/**
* get action callback.
*
* @return string
*/
public function getCallback()
public function getCallback(): \Closure|string|null
{
return $this->callback;
}

// @todo: we should change this to something like "enableConfirm" as "false" is the default value and has pretty much
// nosense to use setConfirm with false parameter.
/**
* Set action confirm.
*
* @param bool $confirm
*
* @return self
*/
public function setConfirm($confirm)
public function setConfirm(bool $confirm): self
{
$this->confirm = $confirm;

return $this;
}

// @todo: could we change this to neddConfirm?
/**
* Get action confirm.
*
* @return bool
*/
public function getConfirm()
public function getConfirm(): bool
{
return $this->confirm;
}

/**
* Set action confirmMessage.
*
* @param string $confirmMessage
*
* @return self
*/
public function setConfirmMessage($confirmMessage)
public function setConfirmMessage(string $confirmMessage): self
{
$this->confirmMessage = $confirmMessage;

return $this;
}

/**
* get action confirmMessage.
*
* @return string
*/
public function getConfirmMessage()
public function getConfirmMessage(): string
{
return $this->confirmMessage;
}

/**
* Set action/controller parameters.
*
* @param array $parameters
*
* @return $this
*/
public function setParameters(array $parameters)
public function setParameters(array $parameters): self
{
$this->parameters = $parameters;

return $this;
}

/**
* Get action/controller parameters.
*
* @return array
*/
public function getParameters()
public function getParameters(): array
{
return $this->parameters;
}

/**
* set role.
*
* @param string $role
*
* @return self
*/
public function setRole($role)
public function setRole(string $role): self
natewiebe13 marked this conversation as resolved.
Show resolved Hide resolved
{
$this->role = $role;

return $this;
}

/**
* Get role.
*
* @return string
*/
public function getRole()
public function getRole(): ?string
{
return $this->role;
}
Expand Down
10 changes: 5 additions & 5 deletions src/Grid/Action/MassActionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,33 @@ interface MassActionInterface
*
* @return string
*/
public function getTitle();
public function getTitle(): string;

/**
* get action callback.
*
* @return string
*/
public function getCallback();
public function getCallback(): \Closure|string|null;

/**
* get action confirm.
*
* @return bool
*/
public function getConfirm();
public function getConfirm(): bool;

/**
* get action confirmMessage.
*
* @return bool
*/
public function getConfirmMessage();
public function getConfirmMessage(): string;

/**
* get additional parameters.
*
* @return array
*/
public function getParameters();
public function getParameters(): array;
}
Loading