Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'view-append-rel' of https://github.com/bakura10/zf2 int…

…o feature/view-helper-headlink-rel
  • Loading branch information...
commit 82c601bcc09e2c6fff14309a3fea573e3de5149e 2 parents 94a0551 + f5a3c19
@weierophinney weierophinney authored
View
33 library/Zend/View/Helper/HeadLink.php
@@ -115,7 +115,7 @@ public function __invoke(array $attributes = null, $placement = Placeholder\Cont
*/
public function __call($method, $args)
{
- if (preg_match('/^(?P<action>set|(ap|pre)pend|offsetSet)(?P<type>Stylesheet|Alternate)$/', $method, $matches)) {
+ if (preg_match('/^(?P<action>set|(ap|pre)pend|offsetSet)(?P<type>Stylesheet|Alternate|Prev|Next)$/', $method, $matches)) {
$argc = count($args);
$action = $matches['action'];
$type = $matches['type'];
@@ -425,4 +425,35 @@ public function createDataAlternate(array $args)
$attributes = compact('rel', 'href', 'type', 'title', 'extras');
return $this->createData($attributes);
}
+
+ /**
+ * Create item for a prev relationship (mainly used for pagination)
+ *
+ * @param array $args
+ * @return stdClass
+ */
+ public function createDataPrev(array $args)
+ {
+ $rel = 'prev';
+ $href = (string) array_shift($args);
+
+ $attributes = compact('rel', 'href');
+ return $this->createData($attributes);
+ }
+
+ /**
+ * Create item for a prev relationship (mainly used for pagination)
+ *
+ * @param array $args
+ * @return stdClass
+ */
+ public function createDataNext(array $args)
+ {
+ $rel = 'next';
+ $href = (string) array_shift($args);
+
+ $attributes = compact('rel', 'href');
+ return $this->createData($attributes);
+ }
}
+
View
16 tests/ZendTest/View/Helper/HeadLinkTest.php
@@ -381,6 +381,22 @@ public function testSetStylesheetWithMediaAsArray()
$this->assertContains(' media="screen,print"', $test);
}
+ public function testSetPrevRelationship()
+ {
+ $this->helper->appendPrev('/foo/bar');
+ $test = $this->helper->toString();
+ $this->assertContains('href="/foo/bar"', $test);
+ $this->assertContains('rel="prev"', $test);
+ }
+
+ public function testSetNextRelationship()
+ {
+ $this->helper->appendNext('/foo/bar');
+ $test = $this->helper->toString();
+ $this->assertContains('href="/foo/bar"', $test);
+ $this->assertContains('rel="next"', $test);
+ }
+
/**
* @issue ZF-5435
*/
Please sign in to comment.
Something went wrong with that request. Please try again.