本文整理汇总了PHP中Psr\Http\Message\StreamInterface::write方法的典型用法代码示例。如果您正苦于以下问题:PHP StreamInterface::write方法的具体用法?PHP StreamInterface::write怎么用?PHP StreamInterface::write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Psr\Http\Message\StreamInterface
的用法示例。
在下文中一共展示了StreamInterface::write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: writeText
public function writeText(StreamInterface $stream)
{
$text = $this->text;
foreach ($this->themeInfos as $themeInfo) {
$stream->write(<<<HTML
<h3>{$text->e($themeInfo->getDisplayName())}</h3>
<p>
{$text->e($themeInfo->getDescription())}
{$text->tReplaced("themes.created_by", '<a href="' . $text->e($themeInfo->getAuthorWebsite()) . '">' . $text->e($themeInfo->getAuthor()) . '</a>')}.
<a href="{$text->e($themeInfo->getThemeWebsite())}" class="arrow">{$this->text->t("themes.view_more_information")}</a>
</p>
<p>
<form method="post" action="{$text->url("switch_theme")}">
<input type="hidden" name="theme" value="{$text->e($themeInfo->getDirectoryName())}" />
<input type="hidden" name="{$text->e(RequestToken::FIELD_NAME)}" value="{$text->e($this->requestToken->getTokenString())}" />
<input type="submit" class="button" value="{$text->t("themes.switch_to_this")}" />
</form>
</a>
</p>
HTML
);
}
$stream->write(<<<HTML
<p>
<a class="arrow" href="{$text->url("admin")}">{$text->t("main.admin")}</a>
</p>
HTML
);
}
示例2: writeUnauthorized
public function writeUnauthorized()
{
$this->response = $this->response->withStatus(401);
$apiResponse = new ApiResponse();
$apiResponse->setStatusFail();
$apiResponse->setData("Unauthorized");
$this->body->write($apiResponse->toJSON());
}
示例3: writeText
public function writeText(StreamInterface $stream)
{
if ($this->newUser === null) {
$stream->write($this->getErrorText());
} else {
$stream->write($this->getSuccessText());
}
}
示例4: writeText
public function writeText(StreamInterface $stream)
{
foreach ($this->comments as $comment) {
$stream->write($this->getSingleComment($comment));
}
if (count($this->comments) == 0) {
$stream->write("<p><em>" . $this->text->t("errors.nothing_found") . "</em></p>\n");
}
}
示例5: writeText
public function writeText(StreamInterface $stream, Website $website, $id, $data)
{
if (!isset($data["text"]) || !isset($data["title"])) {
return;
}
if (strLen($data["title"]) > 0) {
$stream->write("<h2>" . htmlSpecialChars($data["title"]) . "</h2>\n");
}
$stream->write($data["text"]);
}
示例6: writeText
public function writeText(StreamInterface $stream)
{
if (empty($this->documents)) {
$stream->write($this->getEmptyPage());
} else {
$stream->write($this->getDocumentIntros($this->documents));
}
if ($this->editLinks) {
$stream->write($this->getCreateNewDocumentLink());
}
}
示例7: readFile
/**
* Reads a file and write in the body.
*
* @param string $file
* @param StreamInterface $body
*/
private static function readFile($file, StreamInterface $body)
{
if (filesize($file) <= 4096) {
$body->write(file_get_contents($file));
return;
}
$stream = fopen($file, 'r');
while (!feof($stream)) {
$body->write(fread($stream, 4096));
}
fclose($stream);
}
示例8: writeText
public function writeText(StreamInterface $stream)
{
$text = $this->text;
$errorMessage = $this->errorMessage;
$formUrl = $this->destination;
$loginText = $text->t("users.please_log_in");
if (!empty($errorMessage)) {
$stream->write(<<<EOT
<div class="error">
<p>{$errorMessage}</p>
</div>
EOT
);
}
$stream->write(<<<EOT
<div id="login">
<form method="post" action="{$text->e($formUrl)}">
<h3>{$loginText}</h3>
<p>
<label for="user">{$text->t('users.username_or_email')}:</label> <br />
<input type="text" name="user" id="user" autofocus="autofocus" /> <br />
<label for="pass">{$text->t('users.password')}:</label> <br />
<input type="password" name="pass" id="pass" /> <br />
<input type="submit" value="{$text->t('main.log_in')}" class="button primary_button" />
EOT
);
// Repost all POSTed variables (GET variables will be part of the URL above)
foreach ($this->postVars as $key => $value) {
if ($key != "user" && $key != "pass") {
$stream->write('<input type="hidden" name="' . $text->e($key) . '" value="' . $text->e($value) . '" />');
}
}
// End form and return it
$stream->write(<<<EOT
</p>
</form>
EOT
);
if ($this->showCreateAccountLinks) {
$stream->write(<<<HTML
<p>
<a class="arrow" href="{$text->url("create_account")}">
{$text->t("main.create_account")}
</a>
</p>
HTML
);
}
$stream->write("</div>");
}
示例9: writeCalendars
protected function writeCalendars(StreamInterface $stream)
{
$text = $this->text;
for ($i = 1; $i <= 12; $i++) {
$month = DateTime::createFromFormat("Y n j", $this->year->format("Y") . ' ' . $i . ' 1');
$calendarTemplate = new CalendarTemplate($text, $month, $this->articlesInYear, $this->createLinks);
$monthName = ucFirst($calendarTemplate->getMonthName($month));
$yearNumber = $month->format("Y");
$stream->write('<div class="calender_month_wrapper">');
$stream->write("<h3>{$monthName} {$yearNumber}</h3>");
$calendarTemplate->writeText($stream);
$stream->write('</div>');
}
}
示例10: write
/**
* {@inheritdoc}
*/
public function write($string)
{
if ($this->tell() < 0) {
throw new RuntimeException('Invalid pointer position');
}
return $this->decoratedStream->write($string);
}
示例11: send
public function send(StreamInterface $stream)
{
if (!$stream->isWritable()) {
throw new \InvalidArgumentException('Output stream must be writable');
}
$stream->write($this->contents);
}
示例12: writeText
public function writeText(StreamInterface $stream)
{
$text = $this->text;
$editorHtml = $this->installedWidgets->getEditor($this->editWidget);
$actionUrl = $text->getUrlPage("edit_widget", $this->editWidget->getId());
$documentEditUrl = $text->getUrlPage("edit_document", $this->editWidget->getDocumentId());
$tokenNameHtml = $text->e(RequestToken::FIELD_NAME);
$tokenValueHtml = $text->e($this->requestToken->getTokenString());
$stream->write(<<<EDITOR
<p>{$this->text->t("main.fields_required")}</p>
<form method="POST" action="{$text->e($actionUrl)}">
{$editorHtml}
<p>
<input type="hidden" name="{$tokenNameHtml}" value="{$tokenValueHtml}" />
<input type="hidden" name="document_id" value="{$this->editWidget->getDocumentId()}" />
<input type="hidden" name="directory_name" value="{$this->editWidget->getDirectoryName()}" />
<input class="button primary_button"
type="submit"
name="submit"
value="{$this->text->t("editor.save")}" />
<a class="button" href="{$text->e($documentEditUrl)}">
{$this->text->t("main.cancel")}
</a>
</p>
</form>
EDITOR
);
}
示例13: writeText
public function writeText(StreamInterface $stream)
{
$text = $this->text;
$stream->write(<<<HTML
<p>
{$text->t("main.fields_required")}
</p>
<form method="post" action="{$text->url("edit_category", $this->category->getId())}">
<p>
<label for="category_name">{$text->t("categories.name")}:</label>
<span class="required">*</span>
<br />
<input type="text" id="category_name" name="category_name"
maxlength="{$text->e(CategoryRepository::NAME_MAX_LENGTH)}"
value="{$text->e($this->category->getName())}" />
</p>
<p>
<label for="category_description">{$text->t("categories.description")}:</label>
<br />
{$this->richEditor->getEditor("category_description", $this->category->getDescriptionHtml())}
</p>
<p>
<input type="hidden" name="{$text->e(RequestToken::FIELD_NAME)}"
value="{$text->e($this->requestToken->getTokenString())}" />
<input type="submit" class="button primary_button" value="{$text->t("editor.save")}" />
<a class="button" href="{$text->url("category_list")}">
{$text->t("main.cancel")}
</a>
</p>
</form>
HTML
);
}
示例14: dumpSql
/**
* @return void
*/
protected function dumpSql()
{
$connection = $this->container->get('Repository')->getConnection();
if (!$connection instanceof Connection) {
return;
}
$logger = $connection->getConfiguration()->getSQLLogger();
if (!$logger instanceof DebugStack) {
return;
}
$queries = $logger->queries;
$table = '<table class="debug"><tr><th>#</th><th>SQL</th><th>Time</th></tr>';
foreach ($queries as $index => $query) {
$sql = $query['sql'];
$params = $query['params'];
ksort($params);
$sql = preg_replace_callback('~\\?~', function () use(&$params) {
return array_shift($params);
}, $sql);
$sql = preg_replace('~(WHERE|LIMIT|INNER\\s+JOIN|LEFT\\s+JOIN)~', "\n \\1", $sql);
$sql = preg_replace('~(AND|OR)~', "\n \\1", $sql);
$time = sprintf('%.3f ms', 1000 * $query['executionMS']);
$table .= "<tr><td>{$index}</td><td><pre>{$sql}</pre></td><td>{$time}</td></tr>";
}
$table .= '</table>';
$this->output->write($table);
}
示例15: writeText
public function writeText(StreamInterface $stream)
{
$text = $this->text;
$menu = $this->menu;
$token = $this->requestToken;
$stream->write(<<<HTML
<form method="post" action="{$text->e($text->getUrlPage("rename_menu", $menu->getId()))}">
<p>
{$text->t("main.fields_required")}
</p>
<p>
<label for="menu_name">
{$text->t("links.menu.name")}: <span class="required">*</span>
</label> <br />
<input type="text" name="menu_name" id="menu_name" value="{$text->e($menu->getName())}" size="20"
maxlength="{$text->e(MenuRepository::NAME_MAX_LENGTH)}" />
</p>
<p>
<input type="hidden" name="{$text->e(RequestToken::FIELD_NAME)}" value="{$text->e($token->getTokenString())}" />
<input class="button primary_button" type="submit" value="{$text->t("editor.save")}" />
<a class="button" href="{$text->e($text->getUrlPage("edit_menu", $menu->getId()))}">
{$text->t("main.cancel")}
</a>
</p>
</form>
HTML
);
}