本文整理汇总了PHP中Object::write方法的典型用法代码示例。如果您正苦于以下问题:PHP Object::write方法的具体用法?PHP Object::write怎么用?PHP Object::write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Object
的用法示例。
在下文中一共展示了Object::write方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_createFileFirst
/**
* Test Creating the file first
*
* @return void
* @author Dan Cox
*/
public function test_createFileFirst()
{
$this->fs->shouldReceive('exists')->andReturn(FALSE);
$this->config->shouldReceive('create')->andReturn($this->config);
$this->config->shouldReceive('params')->andReturn($this->config);
$this->config->shouldReceive('save');
$this->log->write('file.yml', 'logname', array('data' => array()));
}
示例2: execute
/**
* Executa comando
*
* @param Object $oInput
* @param Object $oOutput
* @access public
* @return void
*/
public function execute($oInput, $oOutput)
{
$oOutput->write("baixando atualizações...\r");
$oComando = $this->getApplication()->execute('cvs update -dRP');
$aRetornoComandoUpdate = $oComando->output;
$iStatusComandoUpdate = $oComando->code;
/**
* Caso CVS encontre conflito, retorna erro 1
*/
if ($iStatusComandoUpdate > 1) {
$oOutput->writeln('<error>Erro nº ' . $iStatusComandoUpdate . ' ao execurar cvs update -dR:' . "\n" . $this->getApplication()->getLastError() . '</error>');
return $iStatusComandoUpdate;
}
$oOutput->writeln(str_repeat(' ', \Shell::columns()) . "\r" . "Atualizações baixados");
$sComandoRoot = '';
/**
* Senha do root
*/
$sSenhaRoot = $this->getApplication()->getConfig('senhaRoot');
/**
* Executa comando como root
* - caso for existir senha no arquivo de configuracoes
*/
if (!empty($sSenhaRoot)) {
$sComandoRoot = "echo '{$sSenhaRoot}' | sudo -S ";
}
$oComando = $this->getApplication()->execute($sComandoRoot . 'chmod 777 -R ' . getcwd());
$aRetornoComandoPermissoes = $oComando->output;
$iStatusComandoPermissoes = $oComando->code;
if ($iStatusComandoPermissoes > 0) {
throw new Exception("Erro ao atualizar permissões dos arquivos, configura a senha do root: cvsgit config -e");
}
}
示例3: array
/**
* POST Request
*
* @return Mixed data retrieved from Request
**/
function _post(&$Model, $params = array())
{
$postHeaders = array('Host' => $this->_host, 'Connection' => 'Close', 'Content-Length' => strlen($this->_data));
$params['headers'] = array_merge($params['headers'], $postHeaders);
if (!isset($params['headers']['Content-Type'])) {
$params['headers']['Content-Type'] = 'application/x-www-form-urlencoded';
}
$this->_formatHeaders($params['headers']);
$request = "POST {$this->_path} HTTP/1.0\r\n";
$request .= $this->_headers . "\r\n";
$request .= "\r\n";
$request .= $this->_data;
$this->__setInfo('requestHeaders', $request);
$this->Socket->write($request);
$response = '';
while ($data = $this->Socket->read()) {
$response .= $data;
}
$this->_parseResponse($response);
if ($this->__settings[$Model->name]['followRedirect'] && array_key_exists('Location', $this->response['headers'])) {
$this->serviceConnect($Model, $this->response['headers']['Location'], $params);
$this->_data = null;
$this->_get($Model, $params);
}
return $this->response['body'];
}
示例4: iexec
/**
* Opens an interactive shell if not done already and transmits commands and returns output.
*
* @access public
* @param string $command Command to execute
* @param string $expect String of output to expect and remove from output.
* @param bool $expectregex Switches string expectation to regular expressions.
* @returns bool|string
*/
public function iexec($command, $expect = "", $expectregex = false)
{
trim($command, "\n");
if ($this->sshobject->write($command . "\n")) {
return $this->sshobject->read($expect, $expectregex ? NET_SSH . $this->protocol . _READ_REGEX : NET_SSH . $this->protocol . _READ_SIMPLE);
} else {
return false;
}
}
示例5: currentOrder
/**
* Gets or creates the current order.
* IMPORTANT FUNCTION!
* @todo - does this need to be public????
* @return void
*/
public function currentOrder()
{
if (!$this->order) {
$sessionVariableName = $this->sessionVariableName("OrderID");
$orderIDFromSession = intval(Session::get($sessionVariableName));
if ($orderIDFromSession > 0) {
$this->order = DataObject::get_by_id("Order", $orderIDFromSession);
}
//order has already been submitted - immediately remove it because we dont want to change it.
$member = Member::currentUser();
if ($this->order) {
//first reason to set to null: it is already submitted
if ($this->order->IsSubmitted()) {
$this->order = null;
} elseif (!$this->order->canView()) {
$this->order = null;
} elseif ($member && $member->exists()) {
if ($this->order->MemberID != $member->ID) {
$updateMember = false;
if (!$this->order->MemberID) {
$updateMember = true;
}
if (!$member->IsShopAdmin()) {
$updateMember = true;
}
if ($updateMember) {
$this->order->MemberID = $member->ID;
$this->order->write();
}
}
//current order has nothing in it AND the member already has an order: use the old one first
if ($this->order->StatusID) {
$firstStep = DataObject::get_one("OrderStep");
//we assume the first step always exists.
//TODO: what sort order?
$previousOrderFromMember = DataObject::get_one("Order", "\r\n\t\t\t\t\t\t\t\t\"MemberID\" = " . $member->ID . "\r\n\t\t\t\t\t\t\t\tAND (\"StatusID\" = " . $firstStep->ID . " OR \"StatusID\" = 0)\r\n\t\t\t\t\t\t\t\tAND \"Order\".\"ID\" <> " . $this->order->ID);
if ($previousOrderFromMember && $previousOrderFromMember->canView()) {
if ($previousOrderFromMember->StatusID) {
$this->order->delete();
$this->order = $previousOrderFromMember;
} else {
$previousOrderFromMember->delete();
}
}
}
}
}
if (!$this->order) {
if ($member) {
$firstStep = DataObject::get_one("OrderStep");
$previousOrderFromMember = DataObject::get_one("Order", "\"MemberID\" = " . $member->ID . " AND (\"StatusID\" = " . $firstStep->ID . " OR \"StatusID\" = 0)");
if ($previousOrderFromMember) {
if ($previousOrderFromMember->canView()) {
$this->order = $previousOrderFromMember;
}
}
}
if (!$this->order) {
//here we cleanup old orders, because they should be cleaned at the same rate that they are created...
$cleanUpEveryTime = EcommerceConfig::get("ShoppingCart", "cleanup_every_time");
if ($cleanUpEveryTime) {
$obj = new CartCleanupTask();
$obj->runSilently();
}
//create new order
$this->order = new Order();
if ($member) {
$this->order->MemberID = $member->ID;
}
$this->order->write();
}
Session::set($sessionVariableName, intval($this->order->ID));
}
//member just logged in and is not associated with order yet
//if you are not logged in but the order belongs to a member then clear the cart.
/***** THIS IS NOT CORRECT, BECAUSE YOU CAN CREATE AN ORDER FOR A USER AND NOT BE LOGGED IN!!! ***
elseif($this->order->MemberID && !$member) {
$this->clear();
return false;
}
*/
if ($this->order && $this->order->exists() && $this->order->StatusID) {
$this->order->calculateOrderAttributes();
}
}
return $this->order;
}
示例6: setRequestBody
/**
* bodyを設定 POST, PUTなど
*
* @param String $body // 投げるJSON
* @return void
*/
protected function setRequestBody($body)
{
$this->body->write($body);
$this->body->rewind();
}
示例7: cache
/**
* Caches the compiled container
*
* @return DI
* @author Dan Cox
*/
public function cache()
{
$dump = new PhpDumper(static::$container);
$this->cache->write($dump->dump(['class' => $this->cache_class, 'namespace' => $this->cache_namespace]), static::$container->getResources());
return $this;
}
示例8: parse
/**
* @param SplFileInfo $file
* @param string $reg_exp
* @param Object $output
*
* @return array
*/
public function parse(SplFileInfo $file, $reg_exp, $output)
{
$parsed = array();
$f = $file->openFile();
while (!$f->eof()) {
$line = $f->current();
if (preg_match($reg_exp, $line, $data)) {
$parsed[] = $data;
} elseif ($output) {
$output->write($line);
}
$f->next();
}
return $parsed;
}
示例9: currentOrder
/**
* Gets or creates the current order.
* Based on the session ONLY!
* IMPORTANT FUNCTION!
* @todo - does this need to be public????
* @return void
*/
public function currentOrder($recurseCount = 0)
{
if (!$this->order) {
$sessionVariableName = $this->sessionVariableName("OrderID");
$orderIDFromSession = intval(Session::get($sessionVariableName));
if ($orderIDFromSession > 0) {
$this->order = Order::get()->byID($orderIDFromSession);
}
$member = Member::currentUser();
if ($this->order) {
//first reason to set to null: it is already submitted
if ($this->order->IsSubmitted()) {
$this->order = null;
} elseif (!$this->order->canView()) {
$this->order = null;
} elseif ($member && $member->exists()) {
if ($this->order->MemberID != $member->ID) {
$updateMember = false;
if (!$this->order->MemberID) {
$updateMember = true;
}
if (!$member->IsShopAdmin()) {
$updateMember = true;
}
if ($updateMember) {
$this->order->MemberID = $member->ID;
$this->order->write();
}
}
//IF current order has nothing in it AND the member already has an order: use the old one first
//first, lets check if the current order is worthwhile keeping
if ($this->order->StatusID || $this->order->TotalItems()) {
//do NOTHING!
} else {
$firstStep = OrderStep::get()->First();
//we assume the first step always exists.
//TODO: what sort order?
$count = 0;
while ($firstStep && ($previousOrderFromMember = Order::get()->where("\r\n\t\t\t\t\t\t\t\t\t\"MemberID\" = " . $member->ID . "\r\n\t\t\t\t\t\t\t\t\tAND (\"StatusID\" = " . $firstStep->ID . " OR \"StatusID\" = 0)\r\n\t\t\t\t\t\t\t\t\tAND \"Order\".\"ID\" <> " . $this->order->ID)->First())) {
//arbritary 12 attempts ...
if ($count > 12) {
break;
}
$count++;
if ($previousOrderFromMember && $previousOrderFromMember->canView()) {
if ($previousOrderFromMember->StatusID || $previousOrderFromMember->TotalItems()) {
$this->order->delete();
$this->order = $previousOrderFromMember;
break;
} else {
$previousOrderFromMember->delete();
}
}
}
}
}
}
if (!$this->order) {
if ($member) {
$firstStep = OrderStep::get()->First();
if ($firstStep) {
$previousOrderFromMember = Order::get()->filter(array("MemberID" => $member->ID, "StatusID" => array($firstStep->ID, 0)))->First();
if ($previousOrderFromMember) {
if ($previousOrderFromMember->canView()) {
$this->order = $previousOrderFromMember;
}
}
}
}
if ($this->order && !$this->order->exists()) {
$this->order = null;
}
if (!$this->order) {
//here we cleanup old orders, because they should be
//cleaned at the same rate that they are created...
if (EcommerceConfig::get("ShoppingCart", "cleanup_every_time")) {
$cartCleanupTask = EcommerceTaskCartCleanup::create();
$cartCleanupTask->runSilently();
}
//create new order
$this->order = Order::create();
if ($member) {
$this->order->MemberID = $member->ID;
}
$this->order->write();
}
Session::set($sessionVariableName, intval($this->order->ID));
} elseif ($this->order->MemberID && !$member) {
$this->clear();
$this->order = null;
}
if ($this->order && $this->order->exists()) {
$this->order->calculateOrderAttributes($force = false);
//.........这里部分代码省略.........