コード例 #1
0
 public function preSave($event)
 {
     parent::preSave($event);
     if (!$this->hash) {
         $this->hash = dmString::random(8);
     }
 }
コード例 #2
0
 public function save($con = null)
 {
     $highlighted = myUtils::highlight($this->getRawBody());
     $this->setBody($highlighted['body']);
     foreach ($this->getSnippetLanguages() as $language) {
         $language->delete();
     }
     foreach ($highlighted['langs'] as $lang => $count) {
         $sl = new SnippetLanguage();
         $sl->setName($lang);
         $sl->setSnippet($this);
         $this->addSnippetLanguage($sl);
     }
     $summarizer = new Summarizer(400);
     $this->setSummary($summarizer->summarize($this->getBody()));
     parent::save();
 }