/** * Creates trigger object from tokens. * <p> * And registers trigger in the table trigger registry. * * @param Tokenizer $tokenizer Tokens collection. * * @return Table * @see Constraint::create */ public function createTrigger(Tokenizer $tokenizer) { $trigger = Trigger::create($tokenizer); $trigger->setParent($this); $this->triggers->add($trigger); return $this; }
/** * @param Tokenizer $tokenizer Statement tokens. * * @return void * @throws NotSupportedException */ protected function executeCreateTrigger(Tokenizer $tokenizer) { $tokenizer->skipWhiteSpace(); $tokenizer->setBookmark(); Trigger::searchTableName($tokenizer); $tableName = $tokenizer->getCurrentToken()->text; /** @var Table $table */ $table = $this->tables->search($tableName); if (!$table) { throw new NotSupportedException("Table [{$tableName}] not found. line: " . $tokenizer->getCurrentToken()->line); } $tokenizer->restoreBookmark(); $table->createTrigger($tokenizer); }