當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ArrayObject::toArray方法代碼示例

本文整理匯總了PHP中ArrayObject::toArray方法的典型用法代碼示例。如果您正苦於以下問題:PHP ArrayObject::toArray方法的具體用法?PHP ArrayObject::toArray怎麽用?PHP ArrayObject::toArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ArrayObject的用法示例。


在下文中一共展示了ArrayObject::toArray方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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;
         }
     }
     return self::$_presentationModel;
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:19,代碼來源:Topics.php

示例3: testInitialDataEqualsArrayRepresentation

 public function testInitialDataEqualsArrayRepresentation()
 {
     $initialData = array(5 => 'foo', 'bar');
     $arrayObject = new ArrayObject($initialData);
     $this->assertSame($initialData, $arrayObject->toArray());
 }
開發者ID:nathanklick,項目名稱:collections,代碼行數:6,代碼來源:ArrayObjectTest.php

示例4: count

        return array_search($find, $this->array);
    }
    function count()
    {
        return count($this->array);
    }
    function append($val)
    {
        return array_push($this->array, $val);
    }
    function prepend($val)
    {
        return array_unshift($this->array, $val);
    }
    function slice($offset, $lenth = null)
    {
        return new ArrayObject(array_slice($this->array, $offset, $lenth));
    }
    function rand()
    {
        return $this->array[array_rand($this->array, 1)];
    }
    function toArray()
    {
        return $this->array;
    }
}
$ar = new ArrayObject(['a', 'b', 'c']);
$ar->insert(1, '_');
var_dump($ar->toArray());
開發者ID:ruziyi,項目名稱:framework,代碼行數:30,代碼來源:ArrayObject.php

示例5: getPostsByTopicId

 /**
  * Returns the posts of a topic as a presentation model (array of arrays containing
  * information about each post, 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 ArrayObject (post info)
  */
 public static function getPostsByTopicId($topicId)
 {
     if (!isset(self::$_presentationModel[$topicId])) {
         $posts = array();
         foreach (self::getDomainModel($topicId) as $row) {
             $row = new ArrayObject($row->toArray(), ArrayObject::ARRAY_AS_PROPS);
             $row->user = ZFDemoModel_Users::getById($row->user_id);
             $posts[] = $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
             $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
         }
         // cache result only for duration of this request
         self::$_presentationModel[$topicId] = $posts;
     }
     return self::$_presentationModel[$topicId];
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:40,代碼來源:Posts.php

示例6: getPostsByTopicId

 /**
  * Returns the posts of a topic as a presentation model (array of arrays containing
  * information about each post, 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 ArrayObject (post info)
  */
 public static function getPostsByTopicId($topicId)
 {
     if (!isset(self::$_presentationModel[$topicId])) {
         $posts = array();
         foreach (self::getDomainModel($topicId) as $row) {
             $row = new ArrayObject($row->toArray(), ArrayObject::ARRAY_AS_PROPS);
             $row->user = ZFDemoModel_Users::getById($row->user_id);
             $posts[] = $row;
         }
         // cache result only for duration of this request
         self::$_presentationModel[$topicId] = $posts;
     }
     return self::$_presentationModel[$topicId];
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:22,代碼來源:Posts.php


注:本文中的ArrayObject::toArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。