コード例 #1
0
ファイル: DataObject.php プロジェクト: nomidi/sapphire
 /**
  * @deprecated 3.0 Use DataList::create and DataList to do your querying
  */
 public function Aggregate($class = null)
 {
     Deprecation::notice('3.0', 'Call aggregate methods on a DataList directly instead. In templates ' . 'an example of the new syntax is &lt% cached List(Member).max(LastEdited) %&gt instead (check partial-caching.md documentation ' . 'for more details.)');
     if ($class) {
         $list = new DataList($class);
         $list->setDataModel(DataModel::inst());
     } else {
         if (isset($this)) {
             $list = new DataList(get_class($this));
             $list->setDataModel($this->model);
         } else {
             throw new InvalidArgumentException("DataObject::aggregate() must be called as an instance method or passed a classname");
         }
     }
     return $list;
 }
コード例 #2
0
 /**
  * This allows templates to create a new `DataList` from a known
  * DataObject class name, and call methods such as aggregates.
  *
  * The common use case is for partial caching:
  * <code>
  *	<% cached List(Member).max(LastEdited) %>
  *		loop members here
  *	<% end_cached %>
  * </code>
  *
  * @return DataList
  */
 public static function getDataList($className)
 {
     $list = new DataList($className);
     $list->setDataModel(DataModel::inst());
     return $list;
 }