base/DictionaryManager.php
public function getHeadwords($class = null, $words = [])
    {
        // Method One:
        if ($class === null || $class === false || (is_string($class) && empty($class))) {
            $query = Headword::find();
        } else {
            $extensions = ExtensionManager::getModels($class);
            $guids = [];
            foreach ($extensions as $extension) {
                $guids[] = $extension->guid;
            }
            $query = Headword::find()->guid($guids);
        }
        if (is_array($words) && !empty($words)) {
            $query = $query->word($words);
        }
        foreach ($query->all() as $headword) {
            yield $headword;
        }
        // Method Two:
        //return Headword::find()->all();
    }
public function getHeadwords($class = null, $words = [])
    {
        // Method One:
        if ($class === null || $class === false || (is_string($class) && empty($class))) {
            $query = Headword::find();
        } else {
            $extensions = ExtensionManager::getModels($class);
            $guids = [];
            foreach ($extensions as $extension) {
                $guids[] = $extension->guid;
            }
            $query = Headword::find()->guid($guids);
        }
        if (is_array($words) && !empty($words)) {
            $query = $query->word($words);
        }
        foreach ($query->all() as $headword) {
            yield $headword;
        }
        // Method Two:
        //return Headword::find()->all();
    }
public function getHeadwords ( $ class = null , $ words = [ ] ) { // Method One: if ( $ class === null || $ class === false || ( is_string ( $ class ) && empty ( $ class ) ) ) { $ query = Headword :: find ( ) ; } else { $ extensions = ExtensionManager :: getModels ( $ class ) ; $ guids = [ ] ; foreach ( $ extensions as $ extension ) { $ guids [ ] = $ extension -> guid ; } $ query = Headword :: find ( ) -> guid ( $ guids ) ; } if ( is_array ( $ words ) && ! empty ( $ words ) ) { $ query = $ query -> word ( $ words ) ; } foreach ( $ query -> all ( ) as $ headword ) { yield $ headword ; } // Method Two: //return Headword::find()->all(); }
Headwords generator.
@param string|\rhoone\extension\Extension|\rhoone\models\Extension|mixed $class
`string` if extension class.
@param string[] $words
@throws InvalidParamException
Headwords generator .