diff --git a/caches/uim/caches/classes/caches/cache.d b/caches/uim/caches/classes/caches/cache.d index 55b79fbbb..5c8475b40 100644 --- a/caches/uim/caches/classes/caches/cache.d +++ b/caches/uim/caches/classes/caches/cache.d @@ -57,8 +57,7 @@ class DCache : ICache { } this(string newName) { - this(); - this.name(newName); + this().name(newName); } bool initialize(Json[string] initData = null) { @@ -245,13 +244,9 @@ class DCache : ICache { * ``` * Cache.writeMany(["cached_data_1": 'data 1", "cached_data_2": 'data 2"], "long_term"); * ``` - * Params: - * range mydata An array or Traversable of data to be stored in the cache - * @param string configName Optional string configuration name to write to. Defaults to "default" - * returns = True on success, false on failure */ - /* static bool writeMany(Range mydata, string configName = "default") { - return pool(configName).setMultiple(mydata); + /* static bool writeMany(Json[data] dataToStore, string configName = "default") { + return pool(configName).set(dataToStore); } */ /** diff --git a/caches/uim/caches/classes/engines/apcu.d b/caches/uim/caches/classes/engines/apcu.d index 6646c8c49..f2bf9c91a 100644 --- a/caches/uim/caches/classes/engines/apcu.d +++ b/caches/uim/caches/classes/engines/apcu.d @@ -27,7 +27,7 @@ class DApcuCacheEngine : DCacheEngine { /* override bool set(string itemKey, Json dataToCache, long timeToLive = 0) { auto aKey = _key(itemKey); - auto myDuration = this.duration(timeToLive); + auto myDuration = duration(timeToLive); return apcu_store(aKey, dataToCache, myDuration); } */ diff --git a/caches/uim/caches/classes/engines/memory.d b/caches/uim/caches/classes/engines/memory.d index 00ab6863b..e3e4008f6 100644 --- a/caches/uim/caches/classes/engines/memory.d +++ b/caches/uim/caches/classes/engines/memory.d @@ -242,14 +242,11 @@ Json getOption(int myname) { * remember that the Memory pecl extension does not support cache expiry * times greater than 30 days in the future. Any duration greater than 30 days * will be treated as real Unix time value rather than an offset from current time. - * Params: - * string aKey Identifier for the data - * @param Json aValue Data to be cached * / -override bool set(string aKey, Json aValue, long timeToLive = 0) { - myduration = this.duration(myttl); +override bool set(string itemKey, Json dataToCache, long timeToLive = 0) { + myduration = duration(timeToLive); - return _Memory.set(_key(aKey), myvalue, myduration); + return _Memory.set(_key(itemKey), dataToCache, myduration); } /** @@ -264,7 +261,7 @@ override bool set(Json[string] values, long timeToLive = 0) { auto cacheData = null; myvalues.byKeyValue .each!(kv => cacheData[_key(kv.key)] = kv.value); - auto duration = this.duration(myttl); + auto duration = duration(myttl); return _Memory.setMulti(cacheData, duration); } diff --git a/caches/uim/caches/classes/engines/redis.d b/caches/uim/caches/classes/engines/redis.d index 55d17b89c..c271379ab 100644 --- a/caches/uim/caches/classes/engines/redis.d +++ b/caches/uim/caches/classes/engines/redis.d @@ -69,7 +69,7 @@ class DRedisCacheEngine : DCacheEngine { _redis = new DRedis(); if (!configuration.isEmpty("unix_socket")) { result = _redis.connect(configuration.get("unix_socket"]); - } elseif (configuration.get("persistent"].isEmpty) { + } elseif (configuration.isEmpty("persistent")) { result = _redis.connect( configuration.get("server"], configuration.get("port"].toInt, @@ -104,7 +104,7 @@ class DRedisCacheEngine : DCacheEngine { auto myKey = _key(dataId); auto serializedData = this.serialize(dataToCache); - auto myDuration = this.duration(timeToLive); + auto myDuration = duration(timeToLive); return myDuration == 0 : _redis.set(myKey, serializedData) : _redis.setEx(myKey, myDuration, serializedData); diff --git a/collections/uim/collections/classes/iterators/zip.d b/collections/uim/collections/classes/iterators/zip.d index b0e2ea693..d5d7d6624 100644 --- a/collections/uim/collections/classes/iterators/zip.d +++ b/collections/uim/collections/classes/iterators/zip.d @@ -46,7 +46,7 @@ class DZipIterator : ICollection { * @param callable|null aCallable The auto to use for zipping the elements of each iterator. * / this(array sets, ?callable aCallable = null) { - this.multipleIterator = new DMultipleIterator( + _multipleIterator = new DMultipleIterator( MultipleIterator.MIT_NEED_ALL | MultipleIterator.MIT_KEYS_NUMERIC ); @@ -55,7 +55,7 @@ class DZipIterator : ICollection { sets.each!((set) { anIterator = (new DCollection(set)).unwrap(); _iterators ~= anIterator; - this.multipleIterator.attachIterator(anIterator); + _multipleIterator.attachIterator(anIterator); }); } @@ -64,7 +64,7 @@ class DZipIterator : ICollection { * iterators with the same positional index. * / Json current() { - current = this.multipleIterator.current(); + current = _multipleIterator.current(); if (_callback) { return call_user_func_array(_callback, current); } @@ -74,10 +74,10 @@ class DZipIterator : ICollection { return _multipleIterator.key(); } void next() { - this.multipleIterator.next(); + _multipleIterator.next(); } void rewind()) { - this.multipleIterator.rewind(); + _multipleIterator.rewind(); } bool valid() { return _multipleIterator.valid(); @@ -94,11 +94,11 @@ class DZipIterator : ICollection { * array data Data array. * / void __unserialize(array data) { - this.multipleIterator = new DMultipleIterator( + _multipleIterator = new DMultipleIterator( MultipleIterator.MIT_NEED_ALL | MultipleIterator.MIT_KEYS_NUMERIC ); _iterators = someData; - _iterators.each!(iterator => this.multipleIterator.attachIterator(iterator)); + _iterators.each!(iterator => _multipleIterator.attachIterator(iterator)); } */ } diff --git a/commands/uim/commands/classes/commands/i18n/i18n.d b/commands/uim/commands/classes/commands/i18n/i18n.d index 3af909a1d..841853284 100644 --- a/commands/uim/commands/classes/commands/i18n/i18n.d +++ b/commands/uim/commands/classes/commands/i18n/i18n.d @@ -31,11 +31,11 @@ class DI18nCommand : DCommand { .toLower; code = null; switch (choice) { - case "e" : code = this.executeCommand(I18nExtractCommand.classname, [], aConsoleIo); + case "e" : code = executeCommand(I18nExtractCommand.classname, [], aConsoleIo); break; - case "i" : code = this.executeCommand(I18nInitCommand.classname, [], aConsoleIo); + case "i" : code = executeCommand(I18nInitCommand.classname, [], aConsoleIo); break; - case "h" : aConsoleIo.writeln(this.getOptionParser().help()); + case "h" : aConsoleIo.writeln(getOptionParser().help()); break; case "q" : // Do nothing break; diff --git a/commands/uim/commands/classes/commands/i18n/i18nextract.d b/commands/uim/commands/classes/commands/i18n/i18nextract.d index b1aaa2ca9..987e93558 100644 --- a/commands/uim/commands/classes/commands/i18n/i18nextract.d +++ b/commands/uim/commands/classes/commands/i18n/i18nextract.d @@ -76,7 +76,7 @@ class DI18nExtractCommand : DCommand { string response = aConsoleIo.ask(message, defaultPaths[defaultPathIndex] ?? "D"); if (strtoupper(response) == "Q") { aConsoleIo.writeErrorMessages("Extract Aborted"); - this.abort(); + abort(); } if (strtoupper(response) == "D" && count(_paths)) { aConsoleIo.writeln(); diff --git a/consoles/uim/consoles/classes/consoles/io.d b/consoles/uim/consoles/classes/consoles/io.d index 19ce34875..6da2a7c56 100644 --- a/consoles/uim/consoles/classes/consoles/io.d +++ b/consoles/uim/consoles/classes/consoles/io.d @@ -163,26 +163,20 @@ class DConsoleIo { int info(string[] outputMessages, int newLinesToAppend = 1, int outputLevel = NORMAL) { string messageType = "info"; - auto myOutputMessages = this.wrapMessageWithType(messageType, outputMessages); + auto myOutputMessages = wrapMessageWithType(messageType, outputMessages); return _writeln(myOutputMessages, newLinesToAppend, level); } - /** - * Convenience method for out() that wraps message between tag - * Params: - * @param int newLinesToAppend Number of newLinesToAppend to append - * @param int level The message`s output level, see above. - * / + // Convenience method for out() that wraps message between tag int comment(string[] outputMessages...) { return comment(outputMessages.dup); } - int comment(string[] outputMessages, int newLinesToAppendToAppend = 1, int level = self.NORMAL) { - string messageType = "comment"; - message = this.wrapMessageWithType(messageType, message); + int comment(string[] outputMessages, int newLinesToAppendToAppend = 1, int outputLevel = self.NORMAL) { + auto message = wrapMessageWithType("comment", message); - return _writeln(message, newLinesToAppend, level); + return _writeln(message, newLinesToAppend, outputLevel); } /** @@ -193,7 +187,7 @@ class DConsoleIo { * / int warning(string[] amessage, int newLinesToAppend = 1) { string messageType = "warning"; - message = this.wrapMessageWithType(messageType, message); + message = wrapMessageWithType(messageType, message); return _writeErrorMessages(message, newLinesToAppend); } @@ -206,7 +200,7 @@ class DConsoleIo { * / int error(string[] messagesToOutput, int newLinesToAppend = 1) { string messageType = "error"; - auto message = this.wrapMessageWithType(messageType, messagesToOutput); + auto message = wrapMessageWithType(messageType, messagesToOutput); return _writeErrorMessages(message, newLinesToAppend); } @@ -219,7 +213,7 @@ class DConsoleIo { * / int success(string[] messagesToOutput, int newLinesToAppend = 1, int outputLevel = self.NORMAL) { string messageType = "success"; - message = this.wrapMessageWithType(messageType, message); + message = wrapMessageWithType(messageType, message); return _writeln(message, newLinesToAppend, outputLevel); } diff --git a/views/uim/views/classes/views/view.d b/views/uim/views/classes/views/view.d index 250a6f849..073ee96ec 100644 --- a/views/uim/views/classes/views/view.d +++ b/views/uim/views/classes/views/view.d @@ -496,8 +496,11 @@ static string contentType() { * callable myblock The block of code that you want to cache the output of. * / string cache(callable myblock, Json[string] options = null) { - Json[string] options = options.update["key": "", "config": _elementCache]; - if (options["key"].isEmpty) { + Json[string] options = options.merge([ + "key": Json(""), + "config": Json(_elementCache)]); + + if (options.isEmpty("key")) { throw new DInvalidArgumentException("Cannot cache content with an empty key"); } result = Cache.read(options["key"], options["config"]); diff --git a/views/uim/views/helpers/form.d b/views/uim/views/helpers/form.d index 872fcbfee..e52ed1214 100644 --- a/views/uim/views/helpers/form.d +++ b/views/uim/views/helpers/form.d @@ -806,11 +806,10 @@ class DFormHelper : DHelper { mymodelName = Inflector.humanize( Inflector.singularize(_View.getRequest().getParam("controller")) ); - if (!myisCreate) { - mylegend = __d("uim", "Edit {0}", mymodelName); - } else { - mylegend = __d("uim", "New {0}", mymodelName); - } + + mylegend = !myisCreate + ? __d("uim", "Edit {0}", mymodelName) + : __d("uim", "New {0}", mymodelName); } if (myfieldset != false) { if (mylegend) { @@ -943,11 +942,11 @@ class DFormHelper : DHelper { return myinput; } mylabel = _getLabel(fieldName, compact("input", "label", "error", "nestedInput") + options); - if (mynestedInput) { - result = _groupTemplate(compact("label", "error", "options")); - } else { - result = _groupTemplate(compact("input", "label", "error", "options")); - } + + result = mynestedInput + ? _groupTemplate(compact("label", "error", "options")) + : _groupTemplate(compact("input", "label", "error", "options")); + result = _inputContainerTemplate([ "content": result, "error": myerror, @@ -962,13 +961,9 @@ class DFormHelper : DHelper { return result; } - /** - * Generates an group template element - * Params: - * Json[string] options The options for group template - * / + // Generates an group template element protected string _groupTemplate(Json[string] options) { - mygroupTemplate = options["options"]["type"] ~ "FormGroup"; + string mygroupTemplate = options["options"]["type"] ~ "FormGroup"; if (!this.templater().get(mygroupTemplate)) { mygroupTemplate = "formGroup"; }