本文整理汇总了PHP中Object类的典型用法代码示例。如果您正苦于以下问题:PHP Object类的具体用法?PHP Object怎么用?PHP Object使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Object类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testEmptyTemperature
public function testEmptyTemperature()
{
$A = new Object(array(Object::TEMPERATURE => NULL));
$B = new Object(array(Object::TEMPERATURE => ''));
$this->assertTrue($A->weather()->temperature()->isUnknown());
$this->assertTrue($B->weather()->temperature()->isUnknown());
}
示例2: objetVersEnregistrement
/**
* Prépare une liste de paramètres pour une requête SQL UPDATE ou INSERT
* @param Object $objetMetier
* @return array : tableau ordonné de valeurs
*/
public function objetVersEnregistrement($objetMetier)
{
// construire un tableau des paramètres d'insertion ou de modification
// l'ordre des valeurs est important : il correspond à celui des paramètres de la requête SQL
$retour = array(':idSpecialite' => $objetMetier->getIdSpecialite(), ':libelleCourt' => $objetMetier->getLibelleCourt(), ':libelleLong' => $objetMetier->getLibelleLong());
return $retour;
}
示例3: sendTo
/**
* @param Object $user
*
* @param string $subject
*
* @param string $view
*
* @param array $data
*
*/
public function sendTo($user, $subject, $view, $data = [])
{
$this->mail->queue($view, $data, function ($message) use($user, $subject) {
$message->to($user->email)->subject($subject);
});
return true;
}
示例4: Load
public function Load()
{
parent::$PAGE_TITLE = __(ERROR_USER_BANNED) . " - " . __(SITE_NAME);
parent::$PAGE_META_ROBOTS = "noindex, nofollow";
$can_use_captacha = true;
if (WspBannedVisitors::isBannedIp($this->getRemoteIP())) {
$last_access = new DateTime(WspBannedVisitors::getBannedIpLastAccess($this->getRemoteIP()));
$duration = WspBannedVisitors::getBannedIpDuration($this->getRemoteIP());
$dte_ban = $last_access->modify("+" . $duration . " seconds");
if ($dte_ban > new DateTime()) {
$can_use_captacha = false;
}
}
$obj_error_msg = new Object(new Picture("wsp/img/warning.png", 48, 48, 0, "absmidlle"), "<br/><br/>");
$obj_error_msg->add(new Label(__(ERROR_USER_BANNED_MSG_1), true), "<br/>");
if ($can_use_captacha) {
$obj_error_msg->add(new Label(__(ERROR_USER_BANNED_MSG_2), true), "<br/><br/>");
$this->captcha_error_obj = new Object();
$form = new Form($this);
$this->captcha = new Captcha($form);
$this->captcha->setFocus();
$unblock_btn = new Button($form);
$unblock_btn->setValue(__(ERROR_USER_BUTTON))->onClick("onClickUnblock");
$form->setContent(new Object($this->captcha, "<br/>", $unblock_btn));
$obj_error_msg->add($this->captcha_error_obj, "<br/>", $form);
}
$obj_error_msg->add("<br/><br/>", __(MAIN_PAGE_GO_BACK), new Link(BASE_URL, Link::TARGET_NONE, __(SITE_NAME)));
$this->render = new ErrorTemplate($obj_error_msg, __(ERROR_USER_BANNED));
}
示例5: duplicateLayout
/**
* Duplicate given object and copy files needed.
* @param Object $origLayout
*/
public function duplicateLayout($origLayout)
{
// Convert the orig layout to an array
$origData = $origLayout->toArray();
// Store this for later use
$origType = $origData['layout_type'];
// Unset pieces not needed and reset some pieces
unset($origData['layout_id']);
$origData['layout_type'] = Layouts_Model_Layout::CUSTOM;
$layoutPath = $this->fetchLayoutPath($origType, $origData['layout_module']);
// Set our source file
$sourceFile = $layoutPath . $origLayout->createFilename($origData['layout_title_orig']);
// New Path
$newPath = $this->fetchLayoutPath(Layouts_Model_Layout::CUSTOM, $origData['layout_module']);
// Make sure we don't have the same filename
while (is_file($newPath . $origData['layout_filename'])) {
$origData['layout_title'] .= ' copy';
$origData['layout_filename'] = $origLayout->createFilename($origData['layout_title']);
}
$newFile = $newPath . $origData['layout_filename'];
// Do the copy
$copyResult = copy($sourceFile, $newFile);
if (!$copyResult) {
throw new FFR_Model_Exception('There was a problem copying the file.');
}
// Save the new DB record
$newLayout = $this->create($origData);
$newLayout->save();
return true;
}
示例6: transform
/**
* Transforms an object to an id.
*
* @param Object|null $entity
* @return string
*/
public function transform($entity)
{
if (null === $entity) {
return "";
}
return $entity->getId();
}
示例7: sendMail
/**
* send mail
*
* array or object of type you set while initialize service
* @param Object|array $mail
*
* @throws \Exception $ex
*
* @return Mail
*/
public function sendMail($mail)
{
if (!is_array($mail)) {
try {
$arrayMail = $mail->toArray();
} catch (\Exception $ex) {
throw new \Exception('impossible to convert ' . get_class($mail) . ' to mail array');
}
} else {
$arrayMail = $mail;
}
$this->openTransport();
$header = $arrayMail['header'];
$sendingMail = $this->convertor->convertToSendFormat($arrayMail);
// prn($sendingMail->toString());
try {
$this->transport->send($sendingMail);
} catch (\Exception $ex) {
//create checking exception to output normal view, that describes problem to user
throw new \Exception('Mail format exception. Asc administrator to fix the problem');
// throw $ex;
}
$headers = $sendingMail->getHeaders()->toArray();
if (isset($headers['Message-ID'])) {
$header['message-id'] = $headers['Message-ID'];
}
if (is_array($mail)) {
$mail['header'] = $header;
} else {
$mail->header = $header;
}
$this->closeTransport();
return $mail;
}
示例8: classteachersToClassAdd
/**
* Adds the classteachers given in the array to the ORM-Object $class
* @param Object $class The Object representing the class
* @param array $classteachersArray The array containing the information
* about the classteachers to be added
* to $class
*/
private function classteachersToClassAdd($class, $classteachersArray)
{
foreach ($classteachersArray as $ct) {
$ctId = $ct['ID'];
if ($ctId == 'CREATE_NEW') {
//Create a new classteacher
$classteacher = new \Babesk\ORM\Classteacher();
$ct['name'] = trim($ct['name']);
$names = explode(' ', $ct['name'], 2);
//If there was no space in the Classteachername, only add
//surname
$forename = count($names) == 2 ? $names[0] : '';
$surname = end($names);
$classteacher->setName($surname)->setForename($forename)->setAddress('')->setTelephone('')->setEmail('');
$class->addClassteacher($classteacher);
$this->_em->persist($classteacher);
} else {
if ($ctId !== 0) {
//Classteacher already exists, add him
$classteacher = $this->_em->find('DM:Classteacher', $ctId);
$class->addClassteacher($classteacher);
} else {
//No classteacher assigned to class
}
}
}
}
示例9: get
public function get(Object $oObject, $aParams = array())
{
if (isset($this->aParams['ToModuleAlias'])) {
Core::import('Modules.' . $this->aParams['ToModuleAlias']);
}
$oMapper = Manager::getInstance()->getMapper($this->aParams['ToMapperAlias']);
$nLimit = 0;
$nOffset = 0;
$aLocCriteria = array($this->aParams['Field'] => $oObject->getId());
$aLocOrder = array('Pos' => 'ASC');
if (count($aParams) > 0) {
if (isset($aParams['Criteria'])) {
foreach ($aParams['Criteria'] as $key => $val) {
$aLocCriteria[$key] = $val;
}
}
if (isset($aParams['Order'])) {
$aLocOrder = $aParams['Order'];
}
if (isset($aParams['Limit'])) {
$nLimit = intval($aParams['Limit']);
}
if (isset($aParams['Offset'])) {
$nOffset = intval($aParams['Offset']);
}
}
$aDefaultParams = isset($this->aParams['Params']) ? $this->aParams['Params'] : array();
return $oMapper->find(ArrayHelper::merge($aDefaultParams, array('Order' => $aLocOrder, 'Criteria' => $aLocCriteria, 'Limit' => $nLimit, 'Offset' => $nOffset)));
}
示例10: loadObject
/**
* The function loads config values from Object.
*
* @static
* @access public
* @param object $Object The object.
* @return bool TRUE on success, FALSE on failure.
*/
public static function loadObject(Object $Object)
{
foreach ($Object->findList() as $Item) {
self::set($Item->Name, @unserialize($Item->Value));
}
return true;
}
示例11: 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");
}
}
示例12: Load
public function Load()
{
parent::$PAGE_TITLE = __(CONFIGURE_BANNED_VISITORS);
if (!defined('MAX_BAD_URL_BEFORE_BANNED')) {
define("MAX_BAD_URL_BEFORE_BANNED", 4);
}
$this->array_wsp_banned_users = WspBannedVisitors::getBannedVisitors();
$this->table_ban = new Table();
$this->table_ban->setId("table_ban")->activateAdvanceTable()->activatePagination()->activateSort(2, "desc")->setWidth(500);
$this->table_ban->addRowColumns("IP", __(LAST_ACCESS), __(DURATION), __(AUTHORIZE))->setHeaderClass(0);
$ban_vistors_obj = new Object("<br/><br/>", $this->table_ban, "<br/><br/>");
$ban_ip_table = new Table();
$form = new Form($this);
$this->ip_edt = new TextBox($form);
$validation = new LiveValidation();
$validation->addValidatePresence();
$this->ip_edt->setLiveValidation($validation);
$this->duration_edt = new TextBox($form);
$this->duration_edt->setValue(0);
$validation = new LiveValidation();
$validation->addValidatePresence()->addValidateNumericality(true);
$this->duration_edt->setLiveValidation($validation);
$ip_btn = new Button($form);
$ip_btn->setValue(__(BAN_IP))->onClick("onBannedIP")->setAjaxEvent();
$ban_ip_table->addRowColumns("IP : ", $this->ip_edt);
$ban_ip_table->addRowColumns(__(DURATION) . " : ", $this->duration_edt);
$form->setContent(new Object($ban_ip_table, $ip_btn));
$ban_vistors_obj->add($form, "<br/><br/>");
$this->render = new AdminTemplateForm($this, $ban_vistors_obj);
}
示例13: invoke
/**
* Invoke a target
*
* @param xp.codegen.AbstractGenerator generator
* @param lang.reflect.Method method
* @param util.collections.HashTable targets
* @return var result
*/
protected static function invoke(AbstractGenerator $generator, Method $method, Object $targets)
{
$target = $targets->get($method);
if ($target->containsKey('result')) {
return $target['result'][0];
}
Console::writeLine('---> Target ', $method->getName(), ': ');
// Execute dependencies
if ($target->containsKey('depends')) {
foreach ($target->get('depends') as $depends) {
self::invoke($generator, $depends, $targets);
}
}
// Retrieve arguments
$arguments = array();
if ($target->containsKey('arguments')) {
foreach ($target->get('arguments') as $argument) {
$arguments[] = self::invoke($generator, $argument, $targets);
}
}
// Execute target itself
$result = $method->invoke($generator, $arguments);
$target['result'] = new ArrayList($result);
Console::writeLine(NULL === $result ? '<ok>' : xp::typeOf($result));
return $result;
}
示例14: display
function display($tpl = null)
{
$this->state = $this->get('State');
$this->form = $this->get('Form');
//check if user access level allows view
$user = JFactory::getUser();
$groups = $user->getAuthorisedViewLevels();
$access = isset($this->form->frontendaccess) && in_array($this->form->frontendaccess, $groups) ? true : false;
if ($access == false) {
JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
return;
}
// get params from menu
$this->menu_params = $this->state->get('params');
if ($this->menu_params['menu-meta_description']) {
$this->document->setDescription($this->menu_params['menu-meta_description']);
}
if ($this->menu_params['menu-meta_keywords']) {
$this->document->setMetadata('keywords', $this->menu_params['menu-meta_keywords']);
}
//get Item id d
$this->itemid = $this->state->get('itemid', '0');
//get form id
$this->id = JFactory::getApplication()->input->getInt('id', -1);
if ($this->_layout == "detail") {
// Get data from the model
$this->item = $this->get('Detail');
}
// Get data from the model
$this->form = $this->get('Form');
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->fields = $this->get('Datafields');
parent::display($tpl);
}
示例15: test_gettingSettingCollectionBag
/**
* Test the basic functions of the collection bag
*
* @return void
* @author Dan Cox
*/
public function test_gettingSettingCollectionBag()
{
$this->collection->add('foo', 'bar');
$this->assertTrue($this->collection->getMethod()->has('foo'));
$this->assertEquals('bar', $this->collection->getMethod()->get('foo'));
$this->assertEquals(array('foo' => 'bar'), $this->collection->getMethod()->all());
}