本文整理汇总了PHP中Header::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Header::create方法的具体用法?PHP Header::create怎么用?PHP Header::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Header
的用法示例。
在下文中一共展示了Header::create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testHeaderWithSponsor
public function testHeaderWithSponsor()
{
$header = Header::create()->withTitle(H1::create()->appendText('Big Top Title ')->appendText(Bold::create()->appendText('in Bold')))->withSubTitle(H2::create()->appendText('Smaller SubTitle ')->appendText(Bold::create()->appendText('in Bold')))->withKicker(H3::create()->appendText('Kicker ')->appendText(Bold::create()->appendText('in Bold')))->withSponsor(Sponsor::create()->withPageUrl('http://facebook.com/my-sponsor'));
$expected = '<header>' . '<h1>Big Top Title <b>in Bold</b></h1>' . '<h2>Smaller SubTitle <b>in Bold</b></h2>' . '<h3 class="op-kicker">Kicker <b>in Bold</b></h3>' . '<ul class="op-sponsors">' . '<li>' . '<a href="http://facebook.com/my-sponsor" rel="facebook"></a>' . '</li>' . '</ul>' . '</header>';
$rendered = $header->render();
$this->assertEquals($expected, $rendered);
}
示例2: testIsRTLEnabled
public function testIsRTLEnabled()
{
$article = InstantArticle::create()->withCanonicalURL('http://wp.localtest.me/2016/04/12/stress-on-earth/')->enableAutomaticAdPlacement()->enableRTL()->withHeader(Header::create()->withTitle(H1::create()->appendText('Peace on <b>earth</b>'))->addAuthor(Author::create()->withName('bill'))->withPublishTime(Time::create(Time::PUBLISHED)->withDatetime(\DateTime::createFromFormat('j-M-Y G:i:s', '14-Aug-1984 19:30:00'))))->addChild(Paragraph::create()->appendText('Yes, peace is good for everybody!')->appendText(LineBreak::create())->appendText(' Man kind.'));
$result = $article->render();
$expected = '<!doctype html>' . '<html dir="rtl">' . '<head>' . '<link rel="canonical" href="http://wp.localtest.me/2016/04/12/stress-on-earth/"/>' . '<meta charset="utf-8"/>' . '<meta property="op:generator" content="facebook-instant-articles-sdk-php"/>' . '<meta property="op:generator:version" content="1.5.2"/>' . '<meta property="op:markup_version" content="v1.0"/>' . '</head>' . '<body>' . '<article>' . '<header>' . '<h1>Peace on <b>earth</b></h1>' . '<time class="op-published" datetime="1984-08-14T19:30:00+00:00">August 14th, 7:30pm</time>' . '<address>' . '<a>bill</a>' . '</address>' . '</header>' . '<p>Yes, peace is good for everybody!<br/> Man kind.</p>' . '</article>' . '</body>' . '</html>';
$this->assertEquals($expected, $result);
}
示例3: testIsValid
public function testIsValid()
{
$ia = InstantArticle::create()->withCanonicalURL('http://wp.localtest.me/2016/04/12/stress-on-earth/')->enableAutomaticAdPlacement()->withHeader(Header::create()->withTitle(H1::create()->appendText('Peace on <b>earth</b>'))->addAuthor(Author::create()->withName('bill'))->withPublishTime(Time::create(Time::PUBLISHED)->withDatetime(\DateTime::createFromFormat('j-M-Y G:i:s', '14-Aug-1984 19:30:00'))))->addChild(Paragraph::create()->appendText('Yes, peace is good for everybody!')->appendText(LineBreak::create())->appendText(' Man kind.'));
$this->assertTrue($ia->isValid());
}