Esempio n. 1
0
 /**
  * Language constructor.
  * @param string $domain
  * @param string $code
  */
 public function __construct(LanguageManager $manager, $domain, $code)
 {
     $languages = $manager->getLanguages();
     if (isset($languages[$code]) && !empty($languages[$code])) {
         $info = $languages[$code];
         $this->code = $code;
         //
         $this->info = $info['info'];
         $this->name = $info['name'];
         $this->locale = $info['locale'];
         $this->direction = $info['dir'];
     } else {
         $code = 'en';
     }
     $this->domain = $domain;
     //
     if (strtolower($domain) == 'adminlte') {
         $pathName = 'AdminLTE';
     } else {
         $pathName = Inflector::classify($domain);
     }
     if ($pathName == 'Nova') {
         $basePath = SYSTEMDIR;
     } else {
         if ($pathName == 'Shared') {
             $basePath = ROOTDIR . 'shared' . DS;
         } else {
             if (is_dir(APPDIR . 'Modules' . DS . $pathName)) {
                 $basePath = APPDIR . 'Modules/' . $pathName . DS;
             } else {
                 if (is_dir(APPDIR . 'Templates' . DS . $pathName)) {
                     $basePath = APPDIR . 'Templates/' . $pathName . DS;
                 } else {
                     $basePath = APPDIR;
                 }
             }
         }
     }
     $filePath = $basePath . 'Language' . DS . ucfirst($code) . DS . 'messages.php';
     // Check if the language file is readable.
     if (!is_readable($filePath)) {
         return;
     }
     // Get the Domain's messages from the Language file.
     $messages = (include $filePath);
     // A final consistency check.
     if (is_array($messages) && !empty($messages)) {
         $this->messages = $messages;
     }
 }
 /**
  * Run "down" a migration instance.
  *
  * @param string $slug
  * @param object $migration
  * @param bool   $pretend
  */
 protected function runDown($slug, $migration, $pretend)
 {
     $migrationPath = $this->getMigrationPath($slug);
     $file = (string) $migrationPath . DS . $migration . '.php';
     $classFile = implode('_', array_slice(explode('_', basename($file, '.php')), 4));
     $className = Inflector::classify($classFile);
     $table = $this->nova['config']['database.migrations'];
     //
     include $file;
     $instance = new $className();
     $instance->down();
     $this->nova['db']->table($table)->where('migration', $migration)->delete();
 }
Esempio n. 3
0
 /**
  * Parse class name of the module.
  *
  * @param string $slug
  *
  * @return string
  */
 protected function parseName($name)
 {
     if (str_contains($name, '\\')) {
         $name = str_replace('\\', '/', $name);
     }
     if (str_contains($name, '/')) {
         $formats = collect(explode('/', $name))->map(function ($name) {
             return Inflector::classify($name);
         });
         $name = $formats->implode('/');
     } else {
         $name = Inflector::classify($name);
     }
     return $name;
 }
Esempio n. 4
0
 /**
  * Get path for the specified module.
  *
  * @param string $slug
  *
  * @return string
  */
 public function getModulePath($slug)
 {
     $module = Inflector::classify($slug);
     return $this->getPath() . DS . $module . DS;
 }
Esempio n. 5
0
 /**
  * Resolve the correct module namespace.
  *
  * @param array $properties
  */
 public function resolveNamespace($properties)
 {
     if (isset($properties['namespace'])) {
         return $properties['namespace'];
     }
     return Inflector::classify($properties['slug']);
 }