/** * Delete lexems that do not have their own definitions. * Arguments for participles: 'A', ($adjectiveModel). * Arguments for long infinitives: 'F', ('107', '113'). */ private function _deleteDependentModels($inflId, $modelType, $modelNumbers) { // Load and hash all the definitionIds $ldms = LexemDefinitionMap::get_all_by_lexemId($this->id); $defHash = array(); foreach ($ldms as $ldm) { $defHash[$ldm->definitionId] = true; } // Iterate through all the forms of the desired inflection (participle / long infinitive) foreach ($this->getLexemModels() as $lm) { $ifs = InflectedForm::get_all_by_lexemModelId_inflectionId($lm->id, $inflId); foreach ($ifs as $if) { // Examine all lexems having one of the above forms $lexems = Lexem::get_all_by_formNoAccent($if->formNoAccent); foreach ($lexems as $l) { // Keep only the ones that have acceptable model types/numbers $acceptable = false; foreach ($l->getLexemModels() as $o) { if ($o->modelType == 'T' || $o->modelType == $modelType && in_array($o->modelNumber, $modelNumbers)) { $acceptable = true; } } // If $l has the right model, delete it unless it has its own definitions if ($acceptable) { $ownDefinitions = false; $ldms = LexemDefinitionMap::get_all_by_lexemId($l->id); foreach ($ldms as $ldm) { if (!array_key_exists($ldm->definitionId, $defHash)) { $ownDefinitions = true; } } if (!$ownDefinitions) { FlashMessage::add("Am șters automat lexemul {$l->formNoAccent}.", 'info'); $l->delete(); } } } } } }