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


PHP Iterator::append方法代码示例

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


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

示例1: getDocumentsToSettle

 /**
  * 
  * @param array $documents Lista obiektow stdClass zawierajaca dane z grida "dokumenty do rozliczenia"
  * @return \Vindication\BankStatement\Document\Iterator
  */
 public function getDocumentsToSettle(array $documents)
 {
     $get = function ($data) {
         if (in_array($data->document_type, array('note', 'invoice', 'installment'))) {
             $entity = $this->getRepository($entityName = ucfirst($data->document_type))->find($data->document_id);
             if (null === $entity) {
                 throw new \Exception("Entity not found: {$entityName} Id:{$data->document_id}");
             }
             return (new Wrapper($data))->setDocument($entity);
         } else {
             throw new \Exception('Unknown document type: ' . $data->document_type);
         }
     };
     $iterator = new Iterator();
     foreach ($documents as $data) {
         $iterator->append($get($data));
     }
     return $iterator;
 }
开发者ID:krozner,项目名称:BankStatement,代码行数:24,代码来源:Mapper.php

示例2: getDocuments

 /**
  * zwraca liste dokumentow ksiegowych
  *
  *
  * @param Transaction $transaction
  * @return \Vindication\BankStatement\Document\Iterator
  */
 public function getDocuments(Transaction $transaction)
 {
     /* przechowuje liste dokumentow ktore rozliczone maja zostac w 1-szej kolejnosci */
     $priority = new Iterator();
     /* przechowuje liste porostowanych dokumentow */
     $documents = new Iterator();
     /* faktury moga byc powiazane z notami Faktura zawiera note,
      * kwota noty w tym przypadku jest zawarta w fakturze - nie rozliczac noty jako kolejny dokument */
     $invoices = $this->getService('InvoiceMapper')->getStatementExecuteInvoices($transaction);
     /* @var $invoices \Vindication\Invoice\Iterator\Invoices */
     foreach ($invoices as $invoice) {
         /* wyszukuje faktury po numerze i dodaje je do listy jako piersze */
         /* @var $invoice \Vindication\Invoice\Entity\Invoice */
         if (false !== strpos($transaction->getTitle(), $invoice->getNumber())) {
             $priority->append($invoice);
             $invoices->remove($invoice);
         }
     }
     /* kazda rata ma fakture do wplat dodac oba klucze FK_ugody_raty i FK_Faktury */
     /* @var \Vindication\Installment\Mapper */
     $installments = $this->getService('InstallmentMapper')->getStatementExecuteInstallments($transaction);
     /* @var $installments \Vindication\Installment\Iterator\Installments */
     foreach ($installments as $installment) {
         /* @var $installment \Vindication\Installment\Entity\Installment */
         if (false !== strpos($transaction->getTitle(), $installment->getInvoice()->getNumber())) {
             $priority->append($installment);
             $installments->remove($installment);
         }
     }
     /* sortuje po datach faktury i raty */
     $sort = array();
     foreach ($invoices as $entity) {
         /* @var $entity \Vindication\Invoice\Entity\Invoice */
         $sort[] = array(substr($entity->get('DataFaktury'), 0, 10) => $entity);
     }
     foreach ($installments as $entity) {
         /* @var $entity \Vindication\Installment\Entity\Installment */
         $sort[] = array(substr($entity->get('data_raty'), 0, 10) => $entity);
     }
     uksort($sort, function ($a, $b) use($sort) {
         return strcmp(key($sort[$a]), key($sort[$b]));
     });
     foreach ($sort as $array) {
         $documents->append($array[key($array)]);
     }
     /* @var \Vindication\Note\Mapper */
     $notes = $this->getService('NoteMapper')->getStatementExecuteNotes($transaction);
     /* @var $notes \Vindication\Note\Iterator\Notes */
     foreach ($notes as $note) {
         /* @var $note \Vindication\Note\Entity\Note */
         if (false !== strpos($transaction->getTitle(), $note->getNumber())) {
             $priority->append($note);
             $notes->remove($note);
         }
     }
     foreach ($notes as $entity) {
         /* @var $entity \Vindication\Note\Entity\Note */
         if ($entity->getAmount() < 0) {
             /* nota odsetkowa jest pomijana ze wzgledu na ujemna wartosc */
             continue;
         }
         $documents->append($entity);
     }
     /* scala posortowane dokumenty */
     $results = new Iterator();
     foreach ($priority as $item) {
         $results->append($item);
     }
     foreach ($documents as $item) {
         $results->append($item);
     }
     return $results;
 }
开发者ID:krozner,项目名称:BankStatement,代码行数:80,代码来源:Manager.php


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