コード例 #1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $args = $this->argument();
     $opts = $this->option();
     $type = $args['type'] ?: 'app';
     $file = file_get_contents(__DIR__ . '/../../views/generators/angular/' . $type . '.js.stub');
     if ($type == 'app') {
         $name = $args['name'];
     } else {
         $name = $args['name'] . ucfirst(strtolower($type));
     }
     $data = array_dot(['namespace' => $args['name'], 'name' => $name, 'modules' => isset($opts['modules']) ? $opts['modules'] : '']);
     $file = Str::smrtr($file, $data, ['<%= ', ' %>']);
     if (!$args['folder']) {
         $args['folder'] = 'components';
     }
     $path = $opts['path'] . '/' . $args['folder'] . '/' . $args['name'] . '/';
     if (isset($opts['bench'])) {
         $path = 'workench/' . $opts['bench'] . '/public/src/js/';
     }
     if (!is_dir($path)) {
         mkdir($path, 0775, true);
     }
     $filepath = $path . $name . '.js';
     file_put_contents($filepath, $file);
     $this->info($filepath . ' created');
 }
コード例 #2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     if ($this->confirm('This will override existing assets files, do you whish to continue ?')) {
         $dir = __DIR__ . '/../../views/generators/assets/';
         $files = glob($dir . '*');
         $name = $this->ask('What\'s the name of your project ?', 'my-project');
         $description = $this->ask('Please describe your project', 'Laravel awesome project');
         foreach ($files as $file) {
             if (is_file($file)) {
                 $tmp = Arx\classes\Str::smrtr(file_get_contents($file), ['project.name' => strtolower(str_slug($name)), 'project.description' => $description], ['<%=', '%>']);
                 $file = str_replace($dir, '', $file);
                 file_put_contents(base_path($file), $tmp);
             } elseif (is_dir($file)) {
                 $folder = str_replace($dir, '', $file);
                 app('files')->copyDirectory($file, resource_path('assets/' . $folder));
             }
         }
         $this->info('Default Arx assets created');
     }
 }
コード例 #3
0
ファイル: JsCommand.php プロジェクト: SerdarSanri/arx-core
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $args = $this->argument();
     $opts = $this->option();
     $file = file_get_contents(__DIR__ . '/../../views/generators/js/es6-class.js.stub');
     # Define the name of the class
     $parts = explode('/', $args['name']);
     $className = array_pop($parts);
     # Define the folder path of the class
     $folderPath = implode('/', $parts) . '/';
     # Prepare data to replace
     $data = array_dot(['name' => $className]);
     # Replace data
     $file = Str::smrtr($file, $data, ['<%= ', ' %>']);
     # check if folder exist
     $path = $opts['path'] . '/' . $folderPath;
     if (!is_dir($path)) {
         mkdir($path, 0775, true);
     }
     $filepath = $path . $className . '.js';
     file_put_contents($filepath, $file);
     $this->info($filepath . ' created');
 }
コード例 #4
0
ファイル: Shortcode.php プロジェクト: SerdarSanri/arx-core
 /**
  * Get callback from given shortcode name.
  *
  * @param  string  $name
  * @return mixed
  */
 protected function getCallback($name)
 {
     $callback = $this->shortcodes[$name];
     if (is_string($callback)) {
         if (\Str::contains($callback, '@')) {
             $parsedCallback = \Str::parseCallback($callback, 'register');
             $instance = $this->container->make($parsedCallback[0]);
             return [$instance, $parsedCallback[1]];
         } elseif (class_exists($callback)) {
             $instance = $this->container->make($callback);
             return [$instance, 'register'];
         } else {
             return $callback;
         }
     }
     return $callback;
 }
コード例 #5
0
ファイル: Utils.php プロジェクト: SerdarSanri/arx-core
 /**
  * Fastest template engine ever !
  *
  * @return mixed
  */
 public static function smrtr($haystack, $aMatch, $aDelimiter = array("{", "}"))
 {
     return Str::smrtr($haystack, $aMatch, $aDelimiter);
 }
コード例 #6
0
ファイル: Module.php プロジェクト: php-arx/arxmin
 public static function moduleUrl($path = null)
 {
     return arxminUrl('modules/' . strtolower(self::getUsed()) . Str::mustBeginWith('/', $path));
 }