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

[AdminListBundle] added getViewUrl to adminlist config. interface #2338

Merged
merged 1 commit into from
Feb 6, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -227,20 +227,27 @@ public function getExportUrl()
);
}

/**
* Get the view url for the given $item
*
* @param object|array $item
*
* @return array
*/
public function getViewUrlFor($item)
{
if (is_object($item)) {
$id = $item->getid();
} else {
$id = $item['id'];
}
$params = array('id' => $id);
$params = ['id' => $id];
$params = array_merge($params, $this->getExtraParameters());

return array(
return [
'path' => $this->getPathByConvention($this::SUFFIX_VIEW),
'params' => $params,
);
];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ public function getIndexUrl();
*/
public function getExportUrl();

/**
* Get the view url for the given $item
*
* @param object|array $item
*
* @return array
*/
public function getViewUrlFor($item);

/**
* @param object $entity
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

/**
* Class AdminListTest
*
* @todo add the getViewUrlFor test after fixing the issue that this function currently does not exist in the AdminListConfiguratorInterface
*/
class AdminListTest extends Unit
{
Expand Down Expand Up @@ -42,6 +40,7 @@ public function _before()
'getDeleteUrlFor' => [],
'getAddUrlFor' => [],
'getExportUrl' => [],
'getViewUrlFor' => [],
'getValue' => 'test',
'getStringValue' => 'stringtest',
'getOrderBy' => 'name',
Expand Down Expand Up @@ -155,6 +154,12 @@ public function testGetExportUrl()
$this->assertTrue(is_array($this->adminList->getExportUrl()));
}

public function testGetViewUrl()
{
$item = new \stdClass();
$this->assertTrue(is_array($this->adminList->getViewUrlFor($item)));
}

public function testGetValue()
{
$object = new \stdClass();
Expand Down