示例#1
0
 /**
  * Dispatch a Assets File Response.
  *
  * @return \Symfony\Component\HttpFoundation\Response|null
  */
 public function dispatch(SymfonyRequest $request)
 {
     // For proper Assets serving, the file URI should be either of the following:
     //
     // /templates/default/assets/css/style.css
     // /modules/blog/assets/css/style.css
     // /assets/css/style.css
     if (!in_array($request->method(), array('GET', 'HEAD'))) {
         // The Request Method is not valid for Asset Files.
         return null;
     }
     // Calculate the Asset File path, looking for a valid one.
     $uri = $request->path();
     if (preg_match('#^(templates|modules)/([^/]+)/assets/(.*)$#i', $uri, $matches)) {
         $baseName = strtolower($matches[1]);
         //
         $folder = $matches[2];
         if ($folder == 'adminlte' && $baseName == 'templates') {
             // The Asset path is on the AdminLTE Template.
             $folder = 'AdminLTE';
         } else {
             if (strlen($folder) > 3) {
                 // A standard Template or Module name.
                 $folder = Str::studly($folder);
             } else {
                 // A short Template or Module name.
                 $folder = strtoupper($folder);
             }
         }
         $path = str_replace('/', DS, $matches[3]);
         $filePath = APPDIR . ucfirst($baseName) . DS . $folder . DS . 'Assets' . DS . $path;
     } else {
         if (preg_match('#^(assets|vendor)/(.*)$#i', $uri, $matches)) {
             $baseName = strtolower($matches[1]);
             //
             $path = $matches[2];
             if ($baseName == 'vendor' && !Str::startsWith($path, $this->paths)) {
                 // The current URI is not a valid Asset File path on Vendor.
                 return null;
             }
             $filePath = ROOTDIR . $baseName . DS . str_replace('/', DS, $path);
         } else {
             // The current URI is not a valid Asset File path.
             return null;
         }
     }
     // Create a Response for the current Asset File path.
     $response = $this->serve($filePath, $request);
     // Prepare the Response instance.
     $response->prepare($request);
     return $response;
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $this->container['slug'] = Str::slug($this->argument('slug'));
     //
     $slug = $this->container['slug'];
     $this->container['name'] = Str::studly($slug);
     $this->container['namespace'] = Str::studly($slug);
     $this->container['version'] = '1.0';
     $this->container['description'] = 'This is the description for the ' . $this->container['name'] . ' module.';
     $this->container['license'] = 'MIT';
     $this->container['author'] = 'John Doe';
     $this->container['email'] = '*****@*****.**';
     $this->container['homepage'] = 'http://www.novaframework.dev';
     if ($this->option('quick')) {
         return $this->generate();
     }
     $this->stepOne();
 }
示例#3
0
 /**
  * Convert a value to studly caps case.
  *
  * @param  string  $value
  * @return string
  */
 function studly_case($value)
 {
     return Str::studly($value);
 }
示例#4
0
 /**
  * Determine if a set mutator exists for an attribute.
  *
  * @param  string  $key
  * @return bool
  */
 public function hasSetMutator($key)
 {
     return method_exists($this, 'set' . Str::studly($key) . 'Attribute');
 }
示例#5
0
 /**
  * Register a custom implicit validator extension.
  *
  * @param  string   $rule
  * @param  \Closure|string  $extension
  * @return void
  */
 public function addImplicitExtension($rule, $extension)
 {
     $this->addExtension($rule, $extension);
     $this->implicitRules[] = Str::studly($rule);
 }
示例#6
0
 public function getModules()
 {
     if (isset(static::$modules)) {
         return static::$modules;
     }
     //
     $modules = $this->config->get('modules.modules', array());
     $modules = array_map(function ($slug, $properties) {
         $autoload = array('config', 'events', 'filters', 'routes');
         $options = array_get($properties, 'autoload', array());
         if (!empty($options)) {
             $autoload = array_intersect($options, $autoload);
         }
         array_push($autoload, 'bootstrap');
         //
         $namespace = isset($properties['namespace']) ? $properties['namespace'] : Str::studly($slug);
         return array_merge(array('slug' => $slug, 'name' => isset($properties['name']) ? $properties['name'] : $namespace, 'namespace' => $namespace, 'enabled' => isset($properties['enabled']) ? $properties['enabled'] : true, 'order' => isset($properties['order']) ? $properties['order'] : 9001, 'autoload' => $autoload), $properties);
     }, array_keys($modules), $modules);
     return static::$modules = Collection::make($modules)->sortBy('order');
 }