public function __construct(Caching\Cache $cache = NULL, Nette\Database\Context $database, \Trejjam\Emailing\Emails $emails) { $this->cache = $cache; $this->database = $database; $this->emails = $emails; $emails->connectGroups($this); }
protected function createGroupTree() { foreach ($this->database->table($this->config['groups']['table']) as $v) { $this->groups[$v->{$this->getTableInfo()["id"]}] = $group = new Group($v, $this->getTableInfo()); foreach ($v->related($this->config['group_email']['table'], $this->config['group_email']['groupId']) as $v2) { $group->registerEmail($this->emails->getEmailById($v2->{$this->config['group_email']['emailId']})); } } foreach ($this->groups as $v) { $v->connectToParent($this->groups); if (!$v->hasParent()) { $this->rootGroups[$v->getId()] = $v; } } return $this->rootGroups; }