Skip to content

Commit

Permalink
Changed some PHPDoc return types to real typehings in nested gridfield.
Browse files Browse the repository at this point in the history
  • Loading branch information
forsdahl committed Apr 24, 2024
1 parent bc1180b commit 46e5ccc
Showing 1 changed file with 12 additions and 29 deletions.
41 changes: 12 additions & 29 deletions src/GridFieldNestedForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,66 +104,59 @@ public function __construct($name = 'NestedForm')

/**
* Get the grid field that this component is attached to
* @return GridField
*/
public function getGridField()
public function getGridField(): GridField
{
return $this->gridField;
}

/**
* Get the relation name to use for the nested grid fields
* @return string
*/
public function getRelationName()
public function getRelationName(): string
{
return $this->relationName;
}

/**
* Set the relation name to use for the nested grid fields
* @param string $relationName
*/
public function setRelationName($relationName)
public function setRelationName(string $relationName)
{
$this->relationName = $relationName;
return $this;
}

/**
* Get whether the nested grid fields should be inline editable
* @return boolean
*/
public function getInlineEditable()
public function getInlineEditable(): bool
{
return $this->inlineEditable;
}

/**
* Set whether the nested grid fields should be inline editable
* @param boolean $editable
*/
public function setInlineEditable($editable)
public function setInlineEditable(bool $editable)
{
$this->inlineEditable = $editable;
return $this;
}

/**
* Set whether the nested grid fields should be expanded by default
* @param boolean $expandNested
*/
public function setExpandNested($expandNested)
public function setExpandNested(bool $expandNested)
{
$this->expandNested = $expandNested;
return $this;
}

/**
* Set whether the nested grid fields should be forced closed on load
* @param boolean $forceClosed
*/
public function setForceClosedNested($forceClosed)
public function setForceClosedNested(bool $forceClosed)
{
$this->forceCloseNested = $forceClosed;
return $this;
Expand All @@ -173,36 +166,32 @@ public function setForceClosedNested($forceClosed)
* Set a callback function to check which items in this grid that should show the expand link
* for nested gridfields. The callback should return a boolean value.
* You can either pass a callable or a method name as a string.
* @param callable|string $callback
*/
public function setCanExpandCheck($callback)
public function setCanExpandCheck(callable|string $callback)
{
$this->canExpandCheck = $callback;
return $this;
}

/**
* Set the maximum nesting level allowed for nested grid fields
* @param int $level
*/
public function setMaxNestingLevel($level)
public function setMaxNestingLevel(int $level)
{
$this->maxNestingLevel = $level;
return $this;
}

/**
* Get the max nesting level allowed for this grid field.
* @return int
*/
public function getMaxNestingLevel()
public function getMaxNestingLevel(): int
{
return $this->maxNestingLevel ?: static::config()->get('default_max_nesting_level');
}

/**
* Check if we are currently at the max nesting level allowed.
* @return bool
*/
protected function atMaxNestingLevel(GridField $gridField): bool
{
Expand Down Expand Up @@ -466,11 +455,8 @@ public function toggleNestedItem(GridField $gridField, $request = null, $record

/**
* Get the link for the nested grid field
*
* @param string $action
* @return string
*/
public function Link($action = null)
public function Link($action = null): string
{
$link = Director::absoluteURL(Controller::join_links($this->gridField->Link('nested'), $action));
$manager = $this->getStateManager();
Expand All @@ -479,11 +465,8 @@ public function Link($action = null)

/**
* Get the link for the toggle action
*
* @param string $action
* @return string
*/
public function ToggleLink($action = null)
public function ToggleLink($action = null): string
{
$link = Director::absoluteURL(Controller::join_links($this->gridField->Link('toggle'), $action, '?toggle='));
$manager = $this->getStateManager();
Expand Down

0 comments on commit 46e5ccc

Please sign in to comment.