本文整理汇总了PHP中self::setBody方法的典型用法代码示例。如果您正苦于以下问题:PHP self::setBody方法的具体用法?PHP self::setBody怎么用?PHP self::setBody使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类self
的用法示例。
在下文中一共展示了self::setBody方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* Creates constraint object from tokens.
* <p>
* If parameter $constraintName is not passed then current position should point to the name of the constraint.
*
* @param Tokenizer $tokenizer Tokens collection.
* @param string $constraintName Optional name of the constraint.
*
* @return Constraint
*/
public static function create(Tokenizer $tokenizer, $constraintName = '')
{
if ($constraintName === false) {
$constraintName = '';
} elseif (!$constraintName) {
$constraintName = $tokenizer->getCurrentToken()->text;
$tokenizer->nextToken();
$tokenizer->skipWhiteSpace();
}
$constraint = new self($constraintName);
$token = $tokenizer->getCurrentToken();
$level = $token->level;
$constraintDefinition = '';
do {
if ($token->level == $level && $token->text == ',') {
break;
}
if ($token->level < $level && $token->text == ')') {
break;
}
$constraintDefinition .= $token->text;
$token = $tokenizer->nextToken();
} while (!$tokenizer->endOfInput());
$constraint->setBody($constraintDefinition);
return $constraint;
}
示例2: fromReflection
public static function fromReflection(Zend_Reflection_Method $reflectionMethod)
{
$method = new self();
$method->setSourceContent($reflectionMethod->getContents(false));
$method->setSourceDirty(false);
if ($reflectionMethod->getDocComment() != '') {
$method->setDocblock(Zend_CodeGenerator_Php_Docblock::fromReflection($reflectionMethod->getDocblock()));
}
$method->setFinal($reflectionMethod->isFinal());
if ($reflectionMethod->isPrivate()) {
$method->setVisibility(self::VISIBILITY_PRIVATE);
} elseif ($reflectionMethod->isProtected()) {
$method->setVisibility(self::VISIBILITY_PROTECTED);
} else {
$method->setVisibility(self::VISIBILITY_PUBLIC);
}
$method->setStatic($reflectionMethod->isStatic());
$method->setName($reflectionMethod->getName());
foreach ($reflectionMethod->getParameters() as $reflectionParameter) {
$method->setParameter(Zend_CodeGenerator_Php_Parameter::fromReflection($reflectionParameter));
}
$body = $reflectionMethod->getBody();
$body2 = str_replace("\n\n", "\n", $body);
$body2 = preg_replace("|^\n\\s{4}|muU", "\n", $body2);
$body2 = preg_replace("|^\\s{4}|muU", "", $body2);
// $body2 = str_replace(' ', '.', $body2);
//dmDebug::kill($body, "\n".$body2);
$method->setBody($body2);
return $method;
}
示例3: fromRaw
public static function fromRaw($body, $headers)
{
$out = new self();
$out->setBody($body);
$out->setHeaders($headers);
$out->parseData();
return $out;
}
示例4: post
/**
* @param string $url
* @param array $post
* @param wfWAFHTTP $request
* @return wfWAFHTTPResponse|bool
* @throws wfWAFHTTPTransportException
*/
public static function post($url, $post = array(), $request = null)
{
if (!$request) {
$request = new self();
}
$request->setUrl($url);
$request->setMethod('POST');
$request->setBody($post);
$request->setTransport(wfWAFHTTPTransport::getInstance());
return $request->send();
}
示例5: create
/**
* Creates trigger object from tokens.
* <p>
* Current position should point to the name of the trigger.
*
* @param Tokenizer $tokenizer Tokens collection.
*
* @return Trigger
*/
public static function create(Tokenizer $tokenizer)
{
$name = $tokenizer->getCurrentToken()->text;
$trigger = new self($name);
$tokenizer->resetState();
$definition = '';
while (!$tokenizer->endOfInput()) {
$definition .= $tokenizer->getCurrentToken()->text;
$tokenizer->nextToken();
}
$trigger->setBody($definition);
return $trigger;
}
示例6: fromReflection
/**
* Enter description here...
*
* @param ZendL_Reflection_File $reflectionFile
* @return ZendL_Tool_CodeGenerator_Php_File
*/
public static function fromReflection(ZendL_Reflection_File $reflectionFile)
{
$file = new self();
$file->setSourceContent($reflectionFile->getContents());
$file->setSourceDirty(false);
$body = $reflectionFile->getContents();
// @todo this whole area needs to be reworked with respect to how body lines are processed
foreach ($reflectionFile->getClasses() as $class) {
$file->setClass(ZendL_Tool_CodeGenerator_Php_Class::fromReflection($class));
$classStartLine = $class->getStartLine(true);
$classEndLine = $class->getEndLine();
$bodyLines = explode("\n", $body);
$bodyReturn = array();
for ($lineNum = 1; $lineNum <= count($bodyLines); $lineNum++) {
if ($lineNum == $classStartLine) {
$bodyReturn[] = str_replace('?', $class->getName(), self::$_markerClass);
//'/* ZendL_Tool_CodeGenerator_Php_File-ClassMarker: {' . $class->getName() . '} */';
$lineNum = $classEndLine;
} else {
$bodyReturn[] = $bodyLines[$lineNum - 1];
// adjust for index -> line conversion
}
}
$body = implode("\n", $bodyReturn);
unset($bodyLines, $bodyReturn, $classStartLine, $classEndLine);
}
if ($docblock = $reflectionFile->getDocblock()) {
$file->setDocblock(ZendL_Tool_CodeGenerator_Php_Docblock::fromReflection($docblock));
$bodyLines = explode("\n", $body);
$bodyReturn = array();
for ($lineNum = 1; $lineNum <= count($bodyLines); $lineNum++) {
if ($lineNum == $docblock->getStartLine()) {
$bodyReturn[] = str_replace('?', $class->getName(), self::$_markerDocblock);
//'/* ZendL_Tool_CodeGenerator_Php_File-ClassMarker: {' . $class->getName() . '} */';
$lineNum = $docblock->getEndLine();
} else {
$bodyReturn[] = $bodyLines[$lineNum - 1];
// adjust for index -> line conversion
}
}
$body = implode("\n", $bodyReturn);
unset($bodyLines, $bodyReturn, $classStartLine, $classEndLine);
}
$file->setBody($body);
return $file;
}
示例7: SpSendMail
/**
* @param array $recipient Recipient e-mail address
* @param string $subject E-mail subject
* @param string $body Message body
* @param bool $html - HTML mail or plain text
* @param array $replyto Reply to email address
* @param array $cc CC e-mail address
* @param array $bcc BCC e-mail address
* @param string $attachment Attachment file name
* @param array $cert - pem certificate
* @param array $from - array( from, fromname )
* @internal param array $replytoname Reply to name
* @return boolean True on success
*/
public static function SpSendMail($recipient, $subject, $body, $html = false, $replyto = null, $cc = null, $bcc = null, $attachment = null, $cert = null, $from = null)
{
$from = is_array($from) ? $from : array(Sobi::Cfg('mail.from'), Sobi::Cfg('mail.fromname'));
$mail = new self();
$mail->setSender($from);
$mail->setSubject($subject);
$mail->setBody($body);
if ($html) {
$mail->IsHTML(true);
}
if ($cert) {
$mail->Sign($cert['certificate'], $cert['key'], $cert['password']);
}
$mail->addRecipient($recipient);
$mail->addCC($cc);
$mail->addBCC($bcc);
$mail->addAttachment($attachment);
$mail->addReplyTo($replyto);
return $mail->Send();
}
示例8: create
/**
* Creates stored procedure object from tokens.
* <p>
* Current position should point to the type of the stored procedure (PROCEDURE, FUNCTION or TYPE).
* <p>
* Name may consist of two parts divided by '.'.
*
* @param Tokenizer $tokenizer Tokens collection.
*
* @return Procedure
*/
public static function create(Tokenizer $tokenizer)
{
$type = $tokenizer->getCurrentToken()->text;
$tokenizer->nextToken();
$tokenizer->skipWhiteSpace();
$name = $tokenizer->getCurrentToken()->text;
$token = $tokenizer->nextToken();
if ($token->text === '.') {
$token = $tokenizer->nextToken();
$name .= '.' . $token->text;
}
$procedure = new self($name, $type);
$tokenizer->resetState();
$definition = '';
while (!$tokenizer->endOfInput()) {
$definition .= $tokenizer->getCurrentToken()->text;
$tokenizer->nextToken();
}
$procedure->setBody($definition);
return $procedure;
}
示例9: fromInput
/**
* @return Request
*/
public static function fromInput()
{
global $module;
$model = new self();
$model->setMethod(self::getMethodFromInput());
if (isset($module)) {
$model->setPath($module);
$input = explode('/', $module);
$model->setSegments($input);
}
$model->setBody(InputStream::getInput());
$model->setHeaders(self::getHeadersFromInput());
$model->setParameters($_GET);
$model->setCookies($_COOKIE);
$model->setPost($_POST);
$model->setEnvironment($_SERVER);
$model->setStatus(http_response_code());
$model->setUrl(self::getCurrentUri());
$model->parseData();
return $model;
}
示例10: createFromRawResponse
/**
*/
public static function createFromRawResponse($rawResponse)
{
$response = new self($rawResponse);
$lines = preg_split('/(\\r?\\n)/', $rawResponse);
for ($i = 0; $i < count($lines); $i++) {
if (0 == $i) {
preg_match('/^HTTP\\/(\\d\\.\\d)\\s(\\d+)\\s(.+)/', $lines[$i], $statusLine);
$response->setStatusCode($statusCode = $statusLine[2]);
continue;
}
if (empty($lines[$i])) {
$body = array_slice($lines, $i + 1);
$response->setBody(implode("\n", $body));
break;
}
if (strpos($lines[$i], ':')) {
$headerParts = explode(':', $lines[$i]);
$response->setHeader($headerParts[0], $headerParts[1]);
}
}
return $response;
}
示例11: fromReflection
/**
* fromReflection()
*
* @param Zend_Reflection_Method $reflectionMethod
* @return Zend_CodeGenerator_Php_Method
*/
public static function fromReflection(Zend_Reflection_Method $reflectionMethod)
{
$method = new self();
$method->setSourceContent($reflectionMethod->getContents(false));
$method->setSourceDirty(false);
if ($reflectionMethod->getDocComment() != '') {
$method->setDocblock(Zend_CodeGenerator_Php_Docblock::fromReflection($reflectionMethod->getDocblock()));
}
$method->setFinal($reflectionMethod->isFinal());
if ($reflectionMethod->isPrivate()) {
$method->setVisibility(self::VISIBILITY_PRIVATE);
} elseif ($reflectionMethod->isProtected()) {
$method->setVisibility(self::VISIBILITY_PROTECTED);
} else {
$method->setVisibility(self::VISIBILITY_PUBLIC);
}
$method->setStatic($reflectionMethod->isStatic());
$method->setName($reflectionMethod->getName());
foreach ($reflectionMethod->getParameters() as $reflectionParameter) {
$method->setParameter(Zend_CodeGenerator_Php_Parameter::fromReflection($reflectionParameter));
}
$method->setBody($reflectionMethod->getBody());
return $method;
}
示例12: sendMailS
public static function sendMailS($sender, $receiver, $subject, $body, $html = false, $resendCheck = false)
{
$mail = new self();
$mail->setSender($sender);
$mail->setReceiver($receiver);
$mail->setSubject($subject);
$mail->setBody($body);
$mail->setResendCheck($resendCheck);
return false === $html ? $mail->sendAsText() : $mail->sendAsHTML();
}
示例13: fromString
/**
* Create an instance from an input string.
* @param string $str the stringified response
* @return \vakata\http\Response the response instance
* @codeCoverageIgnore
*/
public static function fromString($str)
{
$res = new self();
$break = strpos($str, "\r\n\r\n") === false ? "\n" : "\r\n";
// just in case someone breaks RFC 2616
list($headers, $message) = explode($break . $break, (string) $str, 2);
$headers = explode($break, preg_replace("(" . $break . "\\s+)", " ", $headers));
if (isset($headers[0]) && substr($headers[0], 0, 5) === 'HTTP/') {
$temp = explode(' ', substr($headers[0], 5));
$res->setProtocolVersion($temp[0]);
$res->setStatusCode((int) $temp[1]);
unset($headers[0]);
$headers = array_values($headers);
}
foreach (array_filter($headers) as $v) {
$v = explode(':', $v, 2);
$res->setHeader(trim($v[0]), trim($v[1]));
}
$res->setBody($message);
$res->removeHeader('Content-Length');
$res->removeHeader('Transfer-Encoding');
return $res;
}
示例14: fromString
/**
* Create an instance from a stringified request.
* @param string $str the stringified request
* @return \vakata\http\Request the request instance
* @codeCoverageIgnore
*/
public static function fromString($str)
{
$req = new self();
$break = strpos($str, "\r\n\r\n") === false ? "\n" : "\r\n";
// just in case someone breaks RFC 2616
list($headers, $message) = explode($break . $break, $str, 2);
$headers = explode($break, preg_replace("(" . $break . "\\s+)", " ", $headers));
if (isset($headers[0]) && strlen($headers[0])) {
$temp = explode(' ', $headers[0]);
if (in_array($temp[0], ['GET', 'POST', 'HEAD', 'PATCH', 'PUT', 'OPTIONS', 'TRACE', 'DELETE'])) {
$req->setMethod($temp[0]);
$req->setUrl($temp[1]);
if (isset($temp[2])) {
$req->setProtocolVersion(substr($temp[2], 5));
}
unset($headers[0]);
$headers = array_values($headers);
}
}
foreach (array_filter($headers) as $v) {
$v = explode(':', $v, 2);
$req->setHeader(trim($v[0]), trim($v[1]));
}
if ($req->hasHeader('Host')) {
$host = explode(':', $req->getHeader('Host'), 2);
$req->getUrl()->setHost($host[0]);
if (isset($host[1]) && (int) $host[1]) {
$req->getUrl()->setPort($host[1]);
}
}
if (strpos($req->getHeader('Content-Type'), 'multipart') !== false) {
$bndr = trim(explode(' boundary=', $req->getHeader('Content-Type'))[1], '"');
$parts = explode($break . '--' . $bndr, $break . $message);
array_pop($parts);
array_shift($parts);
$post = [];
foreach ($parts as $item) {
list($head, $body) = explode($break . $break, $item, 2);
$head = explode($break, preg_replace("(" . $break . "\\s+)", " ", $head));
foreach ($head as $h) {
if (strpos(strtolower($h), 'content-disposition') === 0) {
$cd = explode(';', $h);
$name = '';
$file = '';
foreach ($cd as $p) {
if (strpos(trim($p), 'name=') === 0) {
$name = trim(explode('name=', $p)[1], ' "');
}
if (strpos(trim($p), 'filename=') === 0) {
$file = trim(explode('filename=', $p)[1], ' "');
}
}
if ($file) {
$req->addUpload($name, $body, $file);
} else {
$post[$name] = $body;
}
}
}
}
$req->setBody(http_build_query($post));
} elseif (strlen($message)) {
$req->setBody($message);
}
$req->removeHeader('Content-Length');
$req->removeHeader('Transfer-Encoding');
return $req;
}
示例15: send
static function send($to, $subject, $msg, $attach = '', $attachFilename = '')
{
$e = new self();
$e->setFrom(ini::get('email-address'), ini::get('email-name'));
$e->setTo($to);
$e->setSubject($subject);
$e->setBody($msg);
if (strlen($attach)) {
$e->attach($attach, strlen($attachFilename) ? $attachFilename : 'attachment-1');
}
return $e->mail();
}