• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP ArrayObject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: handleRequest

 /**
  * do the magic!
  *
  * @param tx_rnbase_parameters $parameters
  * @param tx_rnbase_configurations $configurations
  * @param ArrayObject $viewData
  *
  * @return string error msg or null
  */
 public function handleRequest(&$parameters, &$configurations, &$viewData)
 {
     $items = $this->getItems();
     $viewData->offsetSet('items', is_array($items) ? array_values($items) : array());
     $viewData->offsetSet('searched', $items !== FALSE);
     return;
 }
开发者ID:RocKordier,项目名称:typo3-mklib,代码行数:16,代码来源:class.tx_mklib_action_AbstractList.php


示例17: getListAsAnArrayObject

 private function getListAsAnArrayObject($list)
 {
     if ($list instanceof ArrayIterator) {
         $list = new ArrayObject($list->getArrayCopy());
     }
     return $list;
 }
开发者ID:raigons,项目名称:bureauinteligencia,代码行数:7,代码来源:Report.php


示例18: getSettingsHtml

 public function getSettingsHtml()
 {
     $pluginSettings = craft()->plugins->getPlugin('placid')->getSettings();
     // Get placid requests and send them to the widget settings
     $requests = craft()->placid_requests->findAllRequests();
     $requestsArray = array('' => 'No request selected');
     foreach ($requests as $request) {
         $requestsArray[$request->handle] = $request->name;
     }
     $templatesPath = craft()->path->getSiteTemplatesPath() . $pluginSettings->widgetTemplatesPath;
     $templates = IOHelper::getFolderContents($templatesPath, TRUE);
     $templatesArray = array('' => Craft::t('No template selected'));
     if (!$templates) {
         $templatesArray = array('' => 'Cannot find templates');
         Craft::log('Cannot find templates in path "' . $templatesPath . '"', LogLevel::Error);
     } else {
         // Turn array into ArrayObject
         $templates = new \ArrayObject($templates);
         // Iterate over template list
         // * Remove full path
         // * Remove folders from list
         for ($list = $templates->getIterator(); $list->valid(); $list->next()) {
             $filename = $list->current();
             $filename = str_replace($templatesPath, '', $filename);
             $filenameIncludingSubfolder = $filename;
             $isTemplate = preg_match("/(.html|.twig)\$/u", $filename);
             if ($isTemplate) {
                 $templatesArray[$filenameIncludingSubfolder] = $filename;
             }
         }
     }
     return craft()->templates->render('placid/_widgets/request/settings', array('requests' => $requestsArray, 'templates' => $templatesArray, 'settings' => $this->getSettings()));
 }
开发者ID:andyra,项目名称:tes,代码行数:33,代码来源:Placid_RequestWidget.php


示例19: toArray

 /**
  * @param string $csv the file pathname
  * @param bool $object if true, returns array object, otherwise a plain array
  * @return ArrayObject
  * @throws Exception
  */
 public static function toArray($csv, $object = true)
 {
     if ($object == false) {
         $array = array();
     } else {
         $array = new ArrayObject();
     }
     if (!file_exists($csv)) {
         throw new Exception('CSV File not found', 404);
     }
     $file = new SplFileObject($csv);
     $file->setFlags(SplFileObject::READ_CSV);
     foreach ($file as $data) {
         $count = count($data);
         if ($object == false) {
             $item = array();
         } else {
             $item = new ArrayObject();
         }
         for ($x = 0; $x < $count; $x++) {
             if ($item instanceof ArrayObject) {
                 $item->append($data[$x]);
             } else {
                 array_push($item, $data[$x]);
             }
         }
         if ($array instanceof ArrayObject) {
             $array->append($item);
         } else {
             array_push($array, $item);
         }
     }
     return $array;
 }
开发者ID:delboy1978uk,项目名称:csv,代码行数:40,代码来源:Csv.php


示例20: getInputHtml

 public function getInputHtml($name, $value)
 {
     // Get site templates path
     $templatesPath = $siteTemplatesPath = craft()->path->getSiteTemplatesPath();
     // Check if the templates path is overriden by configuration
     // TODO: Normalize path
     $limitToSubfolder = craft()->config->get('templateselectSubfolder');
     if ($limitToSubfolder) {
         $templatesPath = $templatesPath . rtrim($limitToSubfolder, '/') . '/';
     }
     // Check if folder exists, or give error
     if (!IOHelper::folderExists($templatesPath)) {
         throw new \InvalidArgumentException('(Template Select) Folder doesn\'t exist: ' . $templatesPath);
     }
     // Get folder contents
     $templates = IOHelper::getFolderContents($templatesPath, TRUE);
     // Add placeholder for when there is no template selected
     $filteredTemplates = array('' => Craft::t('No template selected'));
     // Turn array into ArrayObject
     $templates = new \ArrayObject($templates);
     // Iterate over template list
     // * Remove full path
     // * Remove folders from list
     for ($list = $templates->getIterator(); $list->valid(); $list->next()) {
         $filename = $list->current();
         $filename = str_replace($templatesPath, '', $filename);
         $filenameIncludingSubfolder = $limitToSubfolder ? $limitToSubfolder . $filename : $filename;
         $isTemplate = preg_match("/(.html|.twig)\$/u", $filename);
         if ($isTemplate) {
             $filteredTemplates[$filenameIncludingSubfolder] = $filename;
         }
     }
     // Render field
     return craft()->templates->render('_includes/forms/select', array('name' => $name, 'value' => $value, 'options' => $filteredTemplates));
 }
开发者ID:alexrubin,项目名称:Craft-TemplateSelect,代码行数:35,代码来源:TemplateSelect_SelectFieldType.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ArrayUtil类代码示例发布时间:2022-05-23
下一篇:
PHP ArrayList类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap