/** * 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)) { $folder = $matches[2]; // Adjust the name of the requested folder, the short ones becoming uppercase. $folder = strlen($folder) > 3 ? Str::studly($folder) : strtoupper($folder); // $path = str_replace('/', DS, $matches[3]); // $baseName = strtolower($matches[1]); $filePath = APPDIR . ucfirst($baseName) . DS . $folder . DS . 'Assets' . DS . $path; } else { if (preg_match('#^(assets|vendor)/(.*)$#i', $uri, $matches)) { $path = $matches[2]; // $baseName = strtolower($matches[1]); 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; }
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'); }
/** * 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); }
/** * 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'); }