Esempio n. 1
0
 protected function runMigration($version, $migration, $method)
 {
     $file = $this->path() . $version . DS . $migration . '.php';
     $this->log('Migrate ' . $migration . '...');
     $class = 'FluxBB_Update_' . Str::classify($migration);
     include_once $file;
     $instance = new $class();
     $instance->{$method}();
 }
Esempio n. 2
0
 /**
  * Get the stub migration with the proper class name.
  *
  * @param  string  $bundle
  * @param  string  $migration
  * @return string
  */
 protected function stub($bundle, $migration)
 {
     $stub = File::get(Bundle::path('doctrine') . 'migration_stub' . EXT);
     $prefix = Bundle::class_prefix($bundle);
     // The class name is formatted simialrly to tasks and controllers,
     // where the bundle name is prefixed to the class if it is not in
     // the default "application" bundle.
     $class = $prefix . Str::classify($migration);
     return str_replace('{{class}}', $class, $stub);
 }
Esempio n. 3
0
 /**
  * Resolve an array of migration instances.
  *
  * @param  array  $migrations
  * @return array
  */
 protected function resolve($migrations)
 {
     $instances = array();
     foreach ($migrations as $migration) {
         $migration = (array) $migration;
         // The migration array contains the bundle name, so we will get the
         // path to the bundle's migrations and resolve an instance of the
         // migration using the name.
         $bundle = $migration['bundle'];
         $path = Bundle::path($bundle) . 'migrations/';
         // Migrations are not resolved through the auto-loader, so we will
         // manually instantiate the migration class instances for each of
         // the migration names we're given.
         $name = $migration['name'];
         require_once $path . $name . EXT;
         // Since the migration name will begin with the numeric ID, we'll
         // slice off the ID so we are left with the migration class name.
         // The IDs are for sorting when resolving outstanding migrations.
         //
         // Migrations that exist within bundles other than the default
         // will be prefixed with the bundle name to avoid any possible
         // naming collisions with other bundle's migrations.
         $prefix = Bundle::class_prefix($bundle);
         $class = $prefix . \Laravel\Str::classify(substr($name, 18));
         $migration = new $class();
         // When adding to the array of instances, we will actually
         // add the migration instance, the bundle, and the name.
         // This allows the migrator to log the bundle and name
         // when the migration is executed.
         $instances[] = compact('bundle', 'name', 'migration');
     }
     // At this point the migrations are only sorted within their
     // bundles so we need to resort them by name to ensure they
     // are in a consistent order.
     usort($instances, function ($a, $b) {
         return strcmp($a['name'], $b['name']);
     });
     return $instances;
 }
 /**
  * Format a bundle and controller identifier into the controller's class name.
  *
  * @param  string  $bundle
  * @param  string  $controller
  * @return string
  */
 protected static function format($bundle, $controller)
 {
     return Bundle::class_prefix($bundle) . Str::classify($controller) . '_Controller';
 }
Esempio n. 5
0
 /**
  * Get the class prefix for a given bundle.
  *
  * @param  string  $bundle
  * @return string
  */
 public static function class_prefix($bundle)
 {
     return $bundle !== DEFAULT_BUNDLE ? Str::classify($bundle) . '_' : '';
 }
Esempio n. 6
0
 /**
  * Format a bundle and task into a task class name.
  *
  * @param  string  $bundle
  * @param  string  $task
  * @return string
  */
 protected static function format($bundle, $task)
 {
     $prefix = Bundle::class_prefix($bundle);
     return '\\' . $prefix . Str::classify($task) . '_Task';
 }
Esempio n. 7
0
 /**
  * Format a bundle and controller identifier into the Form's or Page's class name.
  *
  * @param  string  $bundle
  * @param  string  $controller
  * 
  * @return string
  */
 protected static function format($bundle, $path, $type)
 {
     return Bundle::class_prefix($bundle) . Str::classify($path) . '_' . ucfirst($type);
 }
Esempio n. 8
0
 /**
  * Get the stub migration with the proper class name.
  *
  * @param  string  $bundle
  * @param  string  $migration
  * @return string
  */
 protected function stub($bundle, $migration)
 {
     $stub = File::get(path('sys') . 'cli/tasks/migrate/stub' . EXT);
     // The class name is formatted simialrly to tasks and controllers,
     // where the bundle name is prefixed to the class if it is not in
     // the default bundle.
     $class = Bundle::class_prefix($bundle) . Str::classify($migration);
     return str_replace('{{class}}', $class, $stub);
 }