Exemple #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();
 }
Exemple #3
0
 /**
  * Get the singular form of an English word.
  *
  * @param  string  $value
  * @return string
  */
 public static function singular($value)
 {
     return Inflector::singularize($value);
 }
 /**
  * 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;
 }
 /**
  * Determine the URI from the given method name.
  *
  * @param  string  $name
  * @param  string  $prefix
  * @return string
  */
 public function getPlainUri($name, $prefix)
 {
     return $prefix . '/' . implode('-', array_slice(explode('_', Inflector::tableize($name)), 1));
 }
Exemple #6
0
 /**
  * Get the Table for the Model.
  *
  * @return string
  */
 public function getTable()
 {
     if (isset($this->table)) {
         return $this->table;
     }
     $baseName = class_basename($this);
     return str_replace('\\', '', Inflector::tableize($baseName));
 }
Exemple #7
0
 /**
  * Register a custom implicit Validator extension.
  *
  * @param  string   $rule
  * @param  \Closure|string  $extension
  * @param  string  $message
  * @return void
  */
 public function extendImplicit($rule, $extension, $message = null)
 {
     $this->implicitExtensions[$rule] = $extension;
     if ($message !== null) {
         $rule = Inflector::tableize($rule);
         $this->fallbackMessages[$rule] = $message;
     }
 }
Exemple #8
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;
 }
 /**
  * Resolve the correct module namespace.
  *
  * @param array $properties
  */
 public function resolveNamespace($properties)
 {
     if (isset($properties['namespace'])) {
         return $properties['namespace'];
     }
     return Inflector::classify($properties['slug']);
 }
 /**
  * Make FileName.
  *
  * @param string $filePath
  *
  * @return string
  */
 protected function makeFileName($filePath)
 {
     return date('Y_m_d_His') . '_' . strtolower(Inflector::tableize(basename($filePath)));
 }
 /**
  * Determines if the given module exists.
  *
  * @param string $slug
  *
  * @return bool
  */
 public function exists($slug)
 {
     $slug = Inflector::tableize($slug);
     $slugs = $this->slugs()->toArray();
     return in_array($slug, $slugs);
 }