/** * Set settings . * * @return mixed */ public function init() { $attributes = $this->getAttributes(); $fullPath = storage_path($attributes['path']); if (Support\is_path_exists($fullPath)) { $this->settings = Support\get_file_contents($fullPath); } else { Support\dump_file($fullPath, json_encode([])); } register_shutdown_function(function () use($fullPath) { Support\dump_file($fullPath, $this->packData($this->settings)); }); }
public function __construct($attributes = array()) { parent::__construct($attributes); $this->setTranslations(); register_shutdown_function(function () { $locales = $this->getLocales(); foreach ($locales as $locale => $options) { $path = $this->getFileFullPath($locale); $translations = $this->translations[$locale]; if ($translations != $this->loaded[$locale]) { $contents = Support\get_file_contents($path); $contents = array_merge($translations, $contents); $contents = Yaml::dump($contents, 1); Support\dump_file($path, $contents); } } }); }