Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from creative-commoners/issue/32
FIX continue browsing button not working correctly
- Loading branch information
Showing
7 changed files
with
109 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
class DMSCartAbstractController extends ContentController | ||
{ | ||
/** | ||
* Ensure that links for this controller use the customised route. | ||
* Searches through the rules set up for the class and returns the first route. | ||
* | ||
* @param string $action | ||
* @return string | ||
*/ | ||
public function Link($action = null) | ||
{ | ||
if ($url = array_search(get_called_class(), (array)Config::inst()->get('Director', 'rules'))) { | ||
// Check for slashes and drop them | ||
if ($indexOf = stripos($url, '/')) { | ||
$url = substr($url, 0, $indexOf); | ||
} | ||
return $this->join_links($url, $action); | ||
} | ||
} | ||
|
||
/** | ||
* Retrieves a {@link DMSDocumentCart} instance | ||
* | ||
* @return DMSDocumentCart | ||
*/ | ||
public function getCart() | ||
{ | ||
return DMSDocumentCart::singleton(); | ||
} | ||
|
||
/** | ||
* Controls the `Continue browsing` link found in DMSCartNavigation.ss. Defaults all requests back to home. | ||
* @return string | ||
*/ | ||
public function getContinueBrowsingLink() | ||
{ | ||
return Director::absoluteBaseURL(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<div> | ||
<a id='continueBrowsing' class='button alt' href='$Controller.getCart.BackUrl()'> | ||
<a id='continueBrowsing' class='button alt' href='$Controller.ContinueBrowsingLink()'> | ||
<%t DMSDocumentCart.CONTINUE_BROWSING "Continue browsing" %></a> | ||
<h4><%t DMSDocumentCart.REQUEST_FORM_HEADING "Your request in summary" %></h4> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
/** | ||
* Class DMSDocumentCartControllerTest contains all the tests for {@link DMSDocumentCartController} | ||
*/ | ||
class DMSCartAbstractControllerTest extends FunctionalTest | ||
{ | ||
protected static $fixture_file = 'dms-cart/tests/DMSDocumentCartTest.yml'; | ||
|
||
/** | ||
* @var DMSCartAbstractController | ||
*/ | ||
protected $controller; | ||
|
||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
$this->controller = DMSCartAbstractController::create(); | ||
} | ||
|
||
/** | ||
* Ensure the link is "friendly", not a class name | ||
*/ | ||
public function testLink() | ||
{ | ||
$this->assertNull($this->controller->Link()); | ||
} | ||
|
||
/** | ||
* Tests if a Cart is received | ||
*/ | ||
public function testGetCart() | ||
{ | ||
// Callable from base class | ||
$this->assertInstanceOf('DMSDocumentCart', $this->controller->getCart()); | ||
} | ||
|
||
/** | ||
* Controls the `Continue browsing` link found in DMSCartNavigation.ss. Defaults all requests back to home. | ||
* @return string | ||
*/ | ||
public function testGetContinueBrowsingLink() | ||
{ | ||
// Base instance returns something | ||
$this->assertSame(Director::absoluteBaseURL(), $this->controller->getContinueBrowsingLink()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters