setConfig() public method

Set the config.
public setConfig ( Gdn_Configuration $config ) : CategoryCollection
$config Gdn_Configuration The config.
return CategoryCollection Returns `$this` for fluent calls.
Ejemplo n.º 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());
 }
Ejemplo n.º 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;
 }