本文整理匯總了PHP中type::write方法的典型用法代碼示例。如果您正苦於以下問題:PHP type::write方法的具體用法?PHP type::write怎麽用?PHP type::write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類type
的用法示例。
在下文中一共展示了type::write方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: init
/**
* init
*
* @param type $io
*/
private static function init($io)
{
if (!file_exists($file_path = rtrim(APPPATH, '/') . '/config/config.php')) {
$io->write('<error>The configuration file config.php does not exist.</error>');
}
include $file_path;
if ("" == $config['log_path']) {
self::$log_path = sprintf('%s/logs', rtrim(APPPATH, '/'));
} else {
self::$log_path = $config['log_path'];
}
}
示例2: responseHandshakeAnswer
/**
* Generate and send respors after succes handshake
*
* @param type $service
* @param type $info
*/
private function responseHandshakeAnswer($service, $key, $connectionId)
{
echo 'handshake response \\n';
//отправляем заголовок согласно протоколу вебсокета
$SecWebSocketAccept = base64_encode(pack('H*', sha1($key . '258EAFA5-E914-47DA-95CA-C5AB0DC85B11')));
$upgrade = "HTTP/1.1 101 Web Socket Protocol Handshake\r\n" . "Upgrade: websocket\r\n" . "Connection: Upgrade\r\n" . "Sec-WebSocket-Accept:{$SecWebSocketAccept}\r\n\r\n";
$service->write($connectionId, $upgrade, '', true);
unset($this->_handshakes[$connectionId]);
}
示例3: drop_tables
/**
* Drop tables in old_schema no longer defined in new_schema
*
* @param type $ofs
* @param type $old_schema
* @param type $new_schema
* @param type $old_table
* @param type $new_table
*/
public static function drop_tables($ofs, $old_schema, $new_schema, $old_table = null, $new_table = null)
{
if ($old_schema != null) {
if ($old_table != null) {
$tables = array($old_table);
} else {
$tables = dbx::get_tables($old_schema);
}
foreach ($tables as $table) {
// does the new schema contain the old table?
if (!mysql5_schema::contains_table($new_schema, $table['name'])) {
// if the table was renamed, don't drop it
if (!dbsteward::$ignore_oldnames && mysql5_schema::table_formerly_known_as(dbsteward::$new_database, $old_schema, $table, $reformed_schema, $reformed_table)) {
$old_table_name = mysql5::get_fully_qualified_table_name($old_schema['name'], $table['name']);
$reformed_table_name = mysql5::get_fully_qualified_table_name($reformed_schema['name'], $reformed_table['name']);
$ofs->write("-- DROP TABLE {$old_table_name} omitted: new table {$reformed_table_name} indicates it is her replacement\n");
} else {
$ofs->write(mysql5_table::get_drop_sql($old_schema, $table) . "\n");
}
}
}
}
}
示例4: execute
/**
* This function sends file to server.
*
* @param type $fs_adapter
*/
public function execute($fs_adapter, $directory, array $callable = [])
{
$this->setStatus(SubtaskStatus::QUEUE);
try {
if (key_exists('subtaskExecutePre', $callable)) {
$callable['subtaskExecutePre']($this);
}
$this->setStatus(SubtaskStatus::TRANSFER);
$fs_adapter->write($directory, $this->task->file);
$this->task->error = null;
$this->setStatus(SubtaskStatus::COMPLETE);
if (key_exists('subtaskExecutePost', $callable)) {
$callable['subtaskExecutePost']($this);
}
return true;
} catch (Exceptions\RemoteException $e) {
$this->task->error = $e->getMessage();
$this->setStatus(SubtaskStatus::ERROR);
} catch (Exceptions\ConnectionReset $e) {
$this->task->error = $e->getMessage();
$this->setStatus(SubtaskStatus::ERROR);
} catch (\Exception $exception) {
if (key_exists('subtaskOnException', $callable)) {
$callable['subtaskOnException']($this, $exception);
}
return false;
}
}
示例5: unsyncroRelationship
/**
* Un syncronise relationship data for a given object
*
* @param type $item
* @param type $object
*/
public function unsyncroRelationship($item, $object)
{
if (isset($object->has_one)) {
foreach ($object->has_one as $name => $contentProp) {
$existing = DataObject::get_one($contentProp->Type, '"ContentID" = \'' . Convert::raw2sql($contentProp->ContentID) . '\'');
if ($existing && $existing->exists()) {
$propName = $name . 'ID';
$item->{$propName} = $existing->ID;
}
}
$item->write();
}
if (isset($object->many_many)) {
foreach ($object->many_many as $name => $relItems) {
$item->{$name}()->removeAll();
foreach ($relItems as $type => $contentProp) {
$existing = DataObject::get_one($contentProp->Type, '"ContentID" = \'' . Convert::raw2sql($contentProp->ContentID) . '\'');
if ($existing && $existing->exists()) {
$item->{$name}()->add($existing);
}
}
}
}
}
示例6: git_ignore
/**
* git_ignore
*
* @param string $file_path
* @param type $io
*/
private static function git_ignore($file_path, $io)
{
$gitignore_file = sprintf('%s/.gitignore', dirname(dirname(dirname(__FILE__))));
$prefix = dirname(dirname(dirname(__FILE__)));
$file_relative_path = $file_path;
if (substr($file_relative_path, 0, strlen($prefix)) == $prefix) {
$file_relative_path = substr($file_relative_path, strlen($prefix));
}
if (strpos(file_get_contents($gitignore_file), $file_relative_path) === false && strpos(file_get_contents($gitignore_file), trim($file_relative_path, '/')) === false) {
file_put_contents($gitignore_file, PHP_EOL . $file_relative_path, FILE_APPEND);
$io->write(sprintf('The file "%s" has been added to the gitignore.', $file_relative_path));
}
}
示例7: drop_tables
/**
* Drop tables in old_schema no longer defined in new_schema
*
* @param type $ofs
* @param type $old_schema
* @param type $new_schema
* @param type $old_table
* @param type $new_table
*/
public static function drop_tables($ofs, $old_schema, $new_schema, $old_table = null, $new_table = null)
{
if ($old_schema != null && $new_schema != null) {
foreach (dbx::get_tables($old_schema) as $table) {
// if old table was defined
if ($old_table != null) {
// is this the right old table?
if (strcasecmp($table['name'], $old_table['name']) != 0) {
continue;
}
}
// does the new schema contain the old table?
if (!pgsql8_schema::contains_table($new_schema, $table['name'])) {
// if the table was renamed, don't drop it
if (!dbsteward::$ignore_oldnames && pgsql8_schema::table_formerly_known_as(dbsteward::$new_database, $new_schema, $table, $reformed_schema, $reformed_table)) {
$old_table_name = pgsql8::get_quoted_schema_name($new_schema['name']) . '.' . pgsql8::get_quoted_table_name($table['name']);
$reformed_table_name = pgsql8::get_quoted_schema_name($reformed_schema['name']) . '.' . pgsql8::get_quoted_table_name($reformed_table['name']);
$ofs->write("-- DROP TABLE {$old_table_name} omitted: new table {$reformed_table_name} indicates it is her replacement\n");
} else {
$ofs->write(pgsql8_table::get_drop_sql($old_schema, $table) . "\n");
}
}
}
}
}
示例8: checkPayment
/**
* Check whether payment for the given registration succeeded. Returns true if so
*
* @param type $registration
*/
public function checkPayment($registration, $payment = null)
{
if (!$payment) {
$paymentID = Session::get('PaymentID');
if ($paymentID) {
$payment = Payment::get()->byID($paymentID);
}
}
$paid = false;
if ($payment) {
$payment->PaidForClass = 'EventRegistration';
$payment->PaidForID = $registration->ID;
$payment->PaidBy = Member::currentUserID();
$payment->write();
$registration->PaymentID = $payment->ID;
if ($payment->Status == PaymentGateway_Result::SUCCESS) {
$registration->Status = 'Valid';
$paid = true;
$registration->extend('onPaymentConfirmed', $payment->Status);
Session::clear('PaymentID');
}
$registration->write();
}
return $paid;
}
開發者ID:helpfulrobot,項目名稱:ajshort-silverstripe-eventmanagement,代碼行數:30,代碼來源:EventRegisterPaymentStep.php
示例9: macroMeta
/**
* {meta ...}
*
* Examples:
* {meta title 'Something'}
* {meta !title 'Something'}
* {meta og:type 'article'}
* {meta og:image[] 'http://www.myweb.tld/images/image.png'}
*
* @param MacroNode $node
* @param type $writer
* @return string
*/
function macroMeta(MacroNode $node, $writer)
{
$key = '';
$value = '';
// Operator (= or [])
$operator = '=';
// True if key starts with ! (forcing ovewrite of existing value)
$force = false;
// 0: No symbol yet
// 1: Symbol found, wating for whitespace
// 2: Whitespace found -> everything else is a value
$state = 0;
$prev = NULL;
foreach ($node->tokenizer->tokens as $token) {
// Getting value (don't care about anything)
if ($state > 1) {
$value .= $token[Tokenizer::VALUE];
} elseif ($token[Tokenizer::TYPE] == MacroTokens::T_CHAR) {
// : in a symbol
if ($token[Tokenizer::VALUE] == ':' && $state > 0) {
$key .= $token[Tokenizer::VALUE];
} elseif ($token[Tokenizer::VALUE] == '[' && $state > 0) {
} elseif ($token[Tokenizer::VALUE] == ']' && $state > 0 && $prev[Tokenizer::VALUE] == '[') {
$operator = '[]';
} elseif ($token[Tokenizer::VALUE] == '!' && $state == 0) {
$force = true;
} else {
throw new Nette\InvalidStateException("Invalid meta declaration: " . $node->name . " " . $node->args . $node->modifiers);
}
} elseif ($token[Tokenizer::TYPE] == MacroTokens::T_SYMBOL) {
$key .= $token[Tokenizer::VALUE];
// We have found first symbol
if ($state == 0) {
$state++;
}
}
// Checking for whitespace after symbol
if ($token[Tokenizer::TYPE] == MacroTokens::T_WHITESPACE && $state > 0) {
$state++;
}
$prev = $token;
}
// Building method name
$keyTokens = explode(':', $key);
$setMethod = ($operator == '=' ? 'set' : 'add') . ucfirst($keyTokens[count($keyTokens) - 1]);
$getMethod = 'get' . ucfirst($keyTokens[count($keyTokens) - 1]);
for ($i = 0; $i < count($keyTokens) - 1; $i++) {
$setMethod = $keyTokens[$i] . '->' . $setMethod;
$getMethod = $keyTokens[$i] . '->' . $getMethod;
}
$setMethod = '$context->metadata->' . $setMethod;
$getMethod = '$context->metadata->' . $getMethod;
$cmd = $setMethod . '(' . $value . ');';
if (!$force && $operator == '=') {
$cmd = "{ if(!{$getMethod}() && {$getMethod}() !== FALSE) {$cmd} }";
}
// ---------
// Pokud se macro vyskytuje bez nejakeho parent bloku musime ho zapsat v prologu,
// protoze jinak by se nemuselo vubec zavolat kvuli dedicnosti sablon
if ($node->parentNode == NULL) {
$this->_prolog[$this->compiler->templateId][] = $cmd;
} else {
return $writer->write($cmd);
}
}