Exemple #1
0
 /**
  * @return \Swilab\Exception\Manger
  */
 public static function getDefault()
 {
     if (static::$instance) {
         return static::$instance;
     }
     $instance = new self();
     $instance->setDI(Swilab::getDI());
     return $instance;
 }
Exemple #2
0
 public function getNamespace()
 {
     if (null !== static::$namespace) {
         return static::$namespace;
     }
     $namespace = get_called_class();
     if (false !== ($pos = strrpos($namespace, '\\'))) {
         $namespace = substr($namespace, 0, $pos + 1);
     } else {
         $namespace = Swilab::getBaseNamespace() . 'Modules\\' . $this->getName() . '\\';
     }
     return static::$namespace = $namespace;
 }
Exemple #3
0
 protected function getDefaultTableName()
 {
     $modelName = get_called_class();
     if (static::$structured) {
         $structureNamespace = static::$structureNamespace ?: Swilab::getBaseNamespace() . 'Models\\';
         $modelName = str_replace('\\', '', trim(substr($modelName, strlen($structureNamespace)), '\\') . '\\');
         return Str::convertSnake($modelName);
     } elseif (false !== ($pos = strrpos($modelName, '\\'))) {
         return Str::convertSnake(substr($modelName, $pos + 1));
     } else {
         return Str::convertSnake($modelName);
     }
 }
Exemple #4
0
<?php

namespace App\Bootstrap;

use Swilab\Swilab;
define('APP_PATH', realpath(__DIR__ . '/../') . DIRECTORY_SEPARATOR);
$paths = (require __DIR__ . '/paths.php');
Swilab::initialize($paths, 'App');