Completed
Push — master ( e259e3...f37a30 )
by Pavel
02:33
created

ActionCallback::createLink()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
/**
4
 * @copyright   Copyright (c) 2015 ublaboo <[email protected]>
5
 * @author      Pavel Janda <[email protected]>
6
 * @package     Ublaboo
7
 */
8
9
namespace Ublaboo\DataGrid\Column;
10
11
use Nette\Utils\Html;
12
use Ublaboo\DataGrid\DataGrid;
13
use Ublaboo\DataGrid\Row;
14
15
class ActionCallback extends Action
16
{
17
18
	/**
19
	 * @var callable
20
	 */
21
	public $onClick = [];
22
23
	/**
24
	 * @var string
25
	 */
26
	protected $key;
27
28
29
	/**
30
	 * @param DataGrid $grid
31
	 * @param string   $key
32
	 * @param string   $name
33
	 * @param array    $params
34
	 */
35 View Code Duplication
	public function __construct(DataGrid $grid, $key, $name, $params)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
36
	{
37
		$this->grid = $grid;
38
		$this->key = $key;
39
		$this->name = $name;
40
		$this->params = $params;
41
42
		$this->class = 'btn btn-xs btn-default';
43
	}
44
45
46
	/**
47
	 * Create link to datagrid::handleActionCallback() to fire custom callback
48
	 * @param  Row    $row
49
	 * @return string
50
	 * @throws DataGridHasToBeAttachedToPresenterComponentException
51
	 */
52
	protected function createLink(Row $row)
53
	{
54
		$params = $this->getItemParams($row) + ['__key' => $this->key];
55
56
		return $this->grid->link('actionCallback!', $params);
57
	}
58
59
}
60