当前位置: 首页>>代码示例>>PHP>>正文


PHP ArrayObject类代码示例

本文整理汇总了PHP中ArrayObject的典型用法代码示例。如果您正苦于以下问题:PHP ArrayObject类的具体用法?PHP ArrayObject怎么用?PHP ArrayObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ArrayObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getPresentationModel

 /**
  * Returns the topics table as a presentation model (array of arrays containing
  * information about each topic, suitable for use by a view) by mirroring
  * the domain model into a presentation model.  The presentation model can be modified
  * to support the needs of a view, without mangling the raw, real underlying table data.
  * STAGE 4: Apply business logic to create a presentation model for the view.
  * @return array of ArrayObjects (containing topic info) indexed by topic id
  */
 public static function getPresentationModel()
 {
     if (self::$_presentationModel === null) {
         foreach (self::getDomainModel() as $row) {
             $row = new ArrayObject($row->toArray(), ArrayObject::ARRAY_AS_PROPS);
             $row->user = ZFDemoModel_Users::getById($row->user_id);
             self::$_presentationModel[$row->topic_id] = $row;
             /////////////////////////////
             // ==> SECTION: l10n <==
             // create a Locale object for the owner of this post (not the user of this request)
             $postLocale = new Zend_Locale($row->user->locale);
             $row->country = ZFModule_Forum::getCountry($postLocale->getRegion());
             $userLocale = ZFModule_Forum::getUserLocale();
             // locale of the user of this request
             $userLocale = Zend_Registry::get('userLocale');
             $offset = ZFModule_Forum::getTimeOffset();
             if ($row->modification_time != $row->creation_time) {
                 $row->modification_time = new Zend_Date($row->modification_time, $userLocale);
                 $row->modification_time->addTimestamp($offset);
                 // express date/time in user's local timezone
             } else {
                 $row->modification_time = '';
             }
             $row->creation_time = new Zend_Date($row->creation_time, $userLocale);
             $row->creation_time->addTimestamp($offset);
             // express date/time in user's local timezone
         }
     }
     return self::$_presentationModel;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:38,代码来源:Topics.php

示例2: parseData

 /**
  * Parse stream and return array object of parsed payments
  *
  * @param string $stream Stream of data to parse to payments
  * @return \ArrayObject
  * @throws \Exception when format is unrecognized
  */
 public function parseData($stream)
 {
     $amountPadding = 6;
     $paymentNoPadding = 2;
     $descriptionPadding = 9;
     $payerNamePadding = 7;
     $result = new \ArrayObject();
     $rows = explode(PHP_EOL, $stream);
     $trimmedRows = $rows;
     for ($i = 0; $i < count($trimmedRows); $i++) {
         if ($trimmedRows[$i] == '#7') {
             $amount = (int) substr($trimmedRows[$i + $amountPadding], 0, 11) . ',' . substr($trimmedRows[$i + $amountPadding], 11, 2);
             $paymentNo = trim($trimmedRows[$i + $paymentNoPadding]);
             $description = trim($trimmedRows[$i + $descriptionPadding]);
             $payerName = trim($trimmedRows[$i + $payerNamePadding]);
             $referenceNo = "";
             //TODO: in what location is reference no?
             //multiple invoices paid
             if ($matches = $this->_getMatches($description)) {
                 foreach ($matches as $match) {
                     $result->append(new Payment($amount, $paymentNo, $match, $payerName, $referenceNo));
                 }
             }
             //skip the entry
             $i = $i + $trimmedRows[$i + 1];
         }
     }
     return $result;
 }
开发者ID:Shmarkus,项目名称:PIM,代码行数:36,代码来源:SEBTransactionImportParser.php

示例3: elementAtOf

 /**
  * シーケンス内の指定されたインデックス位置にある要素を返します。
  *
  * @param \ArrayObject $source 返される要素が含まれるシーケンス
  * @param int $index 取得する要素の 0 から始まるインデックス
  *
  * @return mixed シーケンス内の指定された位置にある要素
  */
 public function elementAtOf(\ArrayObject $source, int $index)
 {
     if ($index < 0 || $index >= $source->count()) {
         throw new \OutOfRangeException();
     }
     return $source->offsetGet($index);
 }
开发者ID:yukar-php,项目名称:linq,代码行数:15,代码来源:TSearch.php

示例4: testSearch

 /**
  * Tests getting key of a needle from a list
  * @covers \Copycat\Structure\ArrayObject::search()
  */
 public function testSearch()
 {
     $arrayObject = new ArrayObject(array(1, 'foo', 'bar' => 'baz'));
     $this->assertEquals(1, $arrayObject->search('foo'));
     $this->assertEquals('bar', $arrayObject->search('baz'));
     $this->assertFalse($arrayObject->search('bar'));
 }
开发者ID:colonB,项目名称:Copycat,代码行数:11,代码来源:ArrayObjectTest.php

示例5:

 /**
  * @param \ArrayObject $collection
  */
 function it_records_array_access($collection)
 {
     $collection->offsetGet(1)->willReturn('one')->shouldBeCalled();
     $this[1]->shouldBePlayedAs($collection, 'one');
     // It's still immutable.
     $this->shouldBeEmpty();
 }
开发者ID:alexeyshockov,项目名称:colada-x,代码行数:10,代码来源:LazyObjectProxySpec.php

示例6: sentenceWrapper

 private function sentenceWrapper(SentenceUtil $sentence)
 {
     $it = $sentence->getBuildCommand()->getIterator();
     $attr = null;
     $main = new \ArrayObject();
     $append = new \ArrayObject();
     while ($it->valid()) {
         if (Util::contains($it->current()->getClause(), "commandPrint") || Util::contains($it->current()->getClause(), "commandReguler")) {
             if ($attr == null) {
                 $main->append($it->current());
             }
         } else {
             //if contains neither then add to append commands
             $append->append($it->current());
         }
         $it->next();
     }
     foreach ($append->getIterator() as $a) {
         $main->append($a);
     }
     /*
     
             $it->rewind();
     
             while ($it->valid()) {
                 if (!Util::contains($it->current()->getClause(), "commandPrint") &&
                     !Util::contains($it->current()->getClause(), "commandReguler")) {
                 }
                 $it->next();
             }
     */
     return $main;
 }
开发者ID:xwiz,项目名称:mikrotik-api,代码行数:33,代码来源:TalkerSender.php

示例7: getPayments

 /**
  * Get parsed payments
  *
  * @return \ArrayObject Payments array
  */
 public function getPayments()
 {
     if ($this->_payments->count() == 0) {
         $this->_logger->info("No payments found, did you invoke Parser::parse() before this call?");
     }
     return $this->_payments;
 }
开发者ID:Shmarkus,项目名称:PIM,代码行数:12,代码来源:AbstractParser.php

示例8: tokenize

 public function tokenize(string $string)
 {
     $beforeEncoding = mb_internal_encoding();
     mb_internal_encoding($string->getCharset());
     $tokens = new \ArrayObject();
     $currentSystem = null;
     $currentToken = '';
     $length = $string->length();
     for ($i = 0; $i <= $length; $i++) {
         $character = $string->substract($i, 1);
         if (in_array($character, $this->hiragana)) {
             $system = self::HIRAGANA;
         } elseif (in_array($character, $this->katakana)) {
             $system = self::KATAKANA;
         } else {
             $system = self::KANJI;
         }
         // First string did not have a starting system
         if ($currentSystem == null) {
             $currentSystem = $system;
         }
         // if the system still is the same, no boundary has been reached
         if ($currentSystem == $system) {
             $currentToken .= $character;
         } else {
             // Write ended token to tokens and start a new one
             $tokens->append($currentToken);
             $currentToken = $character;
             $currentSystem = $system;
         }
     }
     mb_internal_encoding($beforeEncoding);
     return $tokens;
 }
开发者ID:ssola,项目名称:monachus,代码行数:34,代码来源:Japanase.php

示例9: compare

 /**
  * Using specified comparison logic, compare invoices with payments and return the payments that match the invoices
  *
  * @param \ArrayObject $invoices Invoices to compare against
  * @param \ArrayObject $payments Payments to compare with
  *
  * @return \ArrayObject Mapped payments that represented an Invoice
  * @throws \Exception When comparison fails due to incompatible data types etc.
  */
 public function compare(\ArrayObject $invoices, \ArrayObject $payments)
 {
     $results = new \ArrayObject();
     foreach ($payments as $payment) {
         if ($payment instanceof Payment) {
             foreach ($invoices as $invoice) {
                 if ($invoice instanceof Invoice) {
                     $invoiceNoMatch = false;
                     if ($invoice->getInvoiceNo() != '') {
                         $invoiceNoMatch = strpos(strtoupper($payment->getDescription()), strtoupper($invoice->getInvoiceNo())) !== false;
                     }
                     $orderNoMatch = false;
                     if ($invoice->getOrderNo() != '') {
                         $orderNoMatch = strpos(strtoupper($payment->getDescription()), strtoupper($invoice->getOrderNo())) !== false;
                     }
                     if (strtoupper($payment->getReferenceNo()) == strtoupper($invoice->getReferenceNo()) && $payment->getReferenceNo() != '' || ($orderNoMatch || $invoiceNoMatch)) {
                         $payment->setRelatedInvoice($invoice);
                         $results->append($payment);
                     }
                 } else {
                     throw new \Exception("Invoice not implementing correct interface!");
                 }
             }
         } else {
             throw new \Exception("Payment data type is incorrect!");
         }
     }
     return $results;
 }
开发者ID:Shmarkus,项目名称:PIM,代码行数:38,代码来源:InvoicePaymentReferenceNoComparator.php

示例10: getArray

 /**
  * @return array
  */
 public function getArray()
 {
     if ($this->isArrayObject()) {
         return $this->data->getArray();
     }
     return $this->data;
 }
开发者ID:petrgrishin,项目名称:array-object,代码行数:10,代码来源:BaseArrayObject.php

示例11: render

 public function render()
 {
     $retObj = new \ArrayObject($this->definition);
     $ret = $retObj->getArrayCopy();
     $ret['data'] = $this->formatData();
     return $ret;
 }
开发者ID:nedvisol,项目名称:phporm,代码行数:7,代码来源:BaseForm.php

示例12: searchRegistrationByTeamId

 public function searchRegistrationByTeamId($teamId)
 {
     // the SQL query to be executed on the database
     $query = "SELECT REGISTRATION_ID, CONVERT(VARCHAR(10),REGISTRATION_ACTIVITY_DATE, 101) AS REGISTRATION_ACTIVITY_DATE,\r\n                            TOURNAMENT_ID, TOURNAMENT_NAME, CONVERT(VARCHAR(10), TOURNAMENT_DATE, 101) AS TOURNAMENT_DATE, \r\n                             Right(IsNull(Convert(Varchar,TOURNAMENT_BEGIN_TIME,100),''),7) AS TOURNAMENT_BEGIN_TIME, \r\n                             Right(IsNull(Convert(Varchar,TOURNAMENT_END_TIME,100),''),7) AS TOURNAMENT_END_TIME, \r\n                             TOURNAMENT_STREET, \r\n                             TOURNAMENT_CITY, \r\n                             TOURNAMENT_STATE_CODE,  \r\n                             TOURNAMENT_ZIP,\r\n                             TEAM_ID, TEAM_NAME,\r\n                             SPORT_TYPE_ID, SPORT_TYPE_NAME\r\n                        FROM dbo.REGISTRATION reg JOIN dbo.TEAM t on (reg.REGISTRATION_TEAM_ID = t.TEAM_ID) \r\n                        JOIN dbo.TOURNAMENT tour on(reg.REGISTRATION_TEAM_TOURNAMENT_ID = tour.TOURNAMENT_ID)\r\n                        join dbo.SPORT_TYPE sp ON (sp.SPORT_TYPE_ID = tour.TOURNAMENT_SPORT_TYPE_ID) WHERE t.TEAM_ID =" . $teamId;
     $results = executeQuery($query);
     $regList = new ArrayObject();
     foreach ($results as $result) {
         $regVO = new RegistrationVO();
         $regVO->set_registrationId($result['REGISTRATION_ID']);
         $regVO->set_activityDate($result['REGISTRATION_ACTIVITY_DATE']);
         $tournament = new Tournament();
         $tournament->set_tournamentName($result['TOURNAMENT_NAME']);
         $tournament->set_tournamentDate($result['TOURNAMENT_DATE']);
         $tournament->set_tournamentBeginTime($result['TOURNAMENT_BEGIN_TIME']);
         $tournament->set_tournamentEndTime($result['TOURNAMENT_END_TIME']);
         $tournament->set_sportTypeId($result['SPORT_TYPE_ID']);
         $tournament->set_sportTypeName($result['SPORT_TYPE_NAME']);
         $tournament->set_tournamentStreet($result['TOURNAMENT_STREET']);
         $tournament->set_tourcenameCity($result['TOURNAMENT_CITY']);
         $tournament->set_tournamentState($result['TOURNAMENT_STATE_CODE']);
         $tournament->set_tournamentZip($result['TOURNAMENT_ZIP']);
         $team = new TeamVO();
         $team->set_teamId($result['TEAM_ID']);
         $team->set_teamName($result['TEAM_NAME']);
         $regVO->set_tournament($tournament);
         $regVO->set_team($team);
         $regList->append($regVO);
     }
     return $regList;
 }
开发者ID:themohr,项目名称:cis665,代码行数:30,代码来源:RegistrationDAO.php

示例13: add

 /**
  * array object değeri add edilir
  * 
  * @param \ArrayObject $ArrayObject
  * @param string $key
  * @param string $name
  * @return void
  */
 public function add(\ArrayObject $ArrayObject, $key = null, $name = null)
 {
     $iterator = $ArrayObject->getIterator();
     $this->num_rows = $iterator->count();
     if ($key == null && $name == null) {
         while ($iterator->valid()) {
             $arr = $iterator->current();
             $this->dataArr[] = ['id' => $arr, 'name' => $arr];
             $iterator->next();
             $this->error = false;
         }
     } else {
         $sonaEklenecek = array();
         while ($iterator->valid()) {
             $arr = $iterator->current();
             if ($this->getEnSonaEklenecekDeger() == null) {
                 $this->dataArr[] = ['id' => $arr[$key], 'name' => trim($arr[$name])];
             } else {
                 $value = trim($arr[$name]);
                 if ($this->getEnSonaEklenecekDeger() == $value) {
                     $sonaEklenecek = ['id' => $arr[$key], 'name' => $value];
                 } else {
                     $this->dataArr[] = ['id' => $arr[$key], 'name' => $value];
                 }
             }
             $iterator->next();
             $this->error = false;
         }
         if (count($sonaEklenecek) != 0) {
             $this->dataArr[] = $sonaEklenecek;
         }
     }
 }
开发者ID:QRMarket,项目名称:PHP,代码行数:41,代码来源:DataListener.class.php

示例14: render

 public function render(FrontendController $frontendController, CmsView $view)
 {
     if (!$this->settingsFound) {
         return $this->renderEditable($frontendController, '<p>no settings found</p>');
     }
     $columnsArr = new \ArrayObject();
     for ($i = 1; $i <= $this->settings->cols; ++$i) {
         $colMods = new \ArrayObject();
         if (isset($this->settings->columns[$i]) === true) {
             foreach ($this->settings->columns[$i] as $mod) {
                 if (isset($this->elements[$mod]) === false) {
                     continue;
                 }
                 /** @var CmsElement $modInstance */
                 $modInstance = $this->elements[$mod];
                 $colMods->append($modInstance->render($frontendController, $view));
             }
         }
         $columnsArr->offsetSet($i, $colMods);
     }
     $this->tplVars->offsetSet('columns', $columnsArr);
     $this->tplVars->offsetSet('column_count', $this->settings->cols);
     $this->tplVars->offsetSet('logged_in', $frontendController->getAuth()->isLoggedIn());
     $html = $view->render($this->identifier . '.html', (array) $this->tplVars);
     return $this->renderEditable($frontendController, $html);
 }
开发者ID:TiMESPLiNTER,项目名称:meta-cms,代码行数:26,代码来源:ColumnLayoutElement.php

示例15: languageAndWorkspaceOverlay

 /**
  * Do translation and workspace overlay
  *
  * @param \ArrayObject $data
  * @return void
  */
 public function languageAndWorkspaceOverlay(\ArrayObject $data)
 {
     $overlayedMetaData = $this->getTsfe()->sys_page->getRecordOverlay('sys_file_metadata', $data->getArrayCopy(), $this->getTsfe()->sys_language_content, $this->getTsfe()->sys_language_contentOL);
     if ($overlayedMetaData !== NULL) {
         $data->exchangeArray($overlayedMetaData);
     }
 }
开发者ID:Mr-Robota,项目名称:TYPO3.CMS,代码行数:13,代码来源:FileMetadataOverlayAspect.php


注:本文中的ArrayObject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。