setConfig() 공개 메소드

Set the config.
public setConfig ( Gdn_Configuration $config ) : CategoryCollection
$config Gdn_Configuration The config.
리턴 CategoryCollection Returns `$this` for fluent calls.
예제 #1
0
 /**
  * Class constructor. Defines the related database table name.
  *
  * @since 2.0.0
  * @access public
  */
 public function __construct()
 {
     parent::__construct('Category');
     $this->collection = new CategoryCollection();
     $this->collection->setConfig(Gdn::config());
 }
예제 #2
0
 /**
  * Create a new category collection tied to this model.
  *
  * @return CategoryCollection Returns a new collection.
  */
 public function createCollection(Gdn_SQLDriver $sql = null, Gdn_Cache $cache = null)
 {
     if ($sql === null) {
         $sql = $this->SQL;
     }
     if ($cache === null) {
         $cache = Gdn::cache();
     }
     $collection = new CategoryCollection($sql, $cache);
     // Inject the calculator dependency.
     $collection->setConfig(Gdn::config());
     $collection->setStaticCalculator(function (&$category) {
         self::calculate($category);
     });
     $collection->setUserCalculator(function (&$category) {
         $this->calculateUser($category);
     });
     return $collection;
 }