public function preloadMessages($category, $languages = [])
    {
        if ($category === '*') {
            $categoriesFind = $this->findAllCategories();
        } else {
            $categoriesFind = strpos($category, '*') > 0 ? $this->findCategoriesByPattern($category) : resolve([$category]);
        }
        return $categoriesFind
            ->otherwise(function() { return []; })
            ->then(function($categories) use ($languages) {
                $promises = [];
                foreach ($categories as $category) {
                    foreach ($languages as $language) {
                        $key = $language . '/' . $category;
                        $promises[$key] = $this->loadMessages($category, $language);
                    }
                }
                if (empty($promises)) {
                    return [];
                }
                return all($promises)
                    ->then(function($results) {
                        $this->_messages = Reaction\Helpers\ArrayHelper::merge($this->_messages, $results);
                        return $results;
                    });
            });
    }
public function preloadMessages($category, $languages = [])
    {
        if ($category === '*') {
            $categoriesFind = $this->findAllCategories();
        } else {
            $categoriesFind = strpos($category, '*') > 0 ? $this->findCategoriesByPattern($category) : resolve([$category]);
        }
        return $categoriesFind
            ->otherwise(function() { return []; })
            ->then(function($categories) use ($languages) {
                $promises = [];
                foreach ($categories as $category) {
                    foreach ($languages as $language) {
                        $key = $language . '/' . $category;
                        $promises[$key] = $this->loadMessages($category, $language);
                    }
                }
                if (empty($promises)) {
                    return [];
                }
                return all($promises)
                    ->then(function($results) {
                        $this->_messages = Reaction\Helpers\ArrayHelper::merge($this->_messages, $results);
                        return $results;
                    });
            });
    }
public function preloadMessages ( $ category , $ languages = [ ] ) { if ( $ category === '*' ) { $ categoriesFind = $ this -> findAllCategories ( ) ; } else { $ categoriesFind = strpos ( $ category , '*' ) > 0 ? $ this -> findCategoriesByPattern ( $ category ) : resolve ( [ $ category ] ) ; } return $ categoriesFind -> otherwise ( function ( ) { return [ ] ; } ) -> then ( function ( $ categories ) use ( $ languages ) { $ promises = [ ] ; foreach ( $ categories as $ category ) { foreach ( $ languages as $ language ) { $ key = $ language . '/' . $ category ; $ promises [ $ key ] = $ this -> loadMessages ( $ category , $ language ) ; } } if ( empty ( $ promises ) ) { return [ ] ; } return all ( $ promises ) -> then ( function ( $ results ) { $ this -> _messages = Reaction \ Helpers \ ArrayHelper :: merge ( $ this -> _messages , $ results ) ; return $ results ; } ) ; } ) ; }
Preload all messages from source
@param string $category Category or wildcard
@param array $languages Languages used to preload
@return ExtendedPromiseInterface
Preload all messages from source