Exemplo n.º 1
0
 /**
  * Resolve all of the outstanding migrations for a bundle.
  *
  * @param  string  $bundle
  * @return array
  */
 public function outstanding($bundle = null)
 {
     $migrations = array();
     // If no bundle was given to the command, we'll grab every bundle for
     // the application, including the "application" bundle, which is not
     // returned by "all" method on the Bundle class.
     if (is_null($bundle)) {
         $bundles = array_merge(Bundle::names(), array('application'));
     } else {
         $bundles = array($bundle);
     }
     foreach ($bundles as $bundle) {
         // First we need to grab all of the migrations that have already
         // run for this bundle, as well as all of the migration files
         // for the bundle. Once we have these, we can determine which
         // migrations are still outstanding.
         $ran = $this->database->ran($bundle);
         $files = $this->migrations($bundle);
         // To find outstanding migrations, we will simply iterate over
         // the migration files and add the files that do not exist in
         // the array of ran migrations to the outstanding array.
         foreach ($files as $key => $name) {
             if (!in_array($name, $ran)) {
                 $migrations[] = compact('bundle', 'name');
             }
         }
     }
     return $this->resolve($migrations);
 }
Exemplo n.º 2
0
 /**
  * Generate documentation for a given bundles.  If no bundles are provided
  * documentation will be generated for all registered bundles.
  * 
  * @param  array  $bundles
  * @return void
  */
 public function bundle(array $bundles = array())
 {
     // If no bundles are provided documentation will be generated for all
     // registered bundles.
     if (count($bundles) === 0) {
         $bundles = Bundle::names();
     }
     // Remove any bundles that have not been registered, and give a
     // warning for each one we come across.
     $bundles = array_filter($bundles, function ($name) {
         if (!Bundle::exists($name)) {
             if ($name == DEFAULT_BUNDLE) {
                 return true;
             }
             echo "Bundle [{$name}] is not registered.", PHP_EOL;
             return false;
         }
         return true;
     });
     // If there are no registered bundles then exit with a message
     if (count($bundles) === 0) {
         echo PHP_EOL, "Please register your bundles and try again.", PHP_EOL;
         return;
     }
     // Get the options
     $options = $this->config(array_map(array('Bundle', 'path'), $bundles));
     // Run ApiGen
     $this->apigen($options);
 }
Exemplo n.º 3
0
 /**
  * Run the tests for a given bundle.
  *
  * @param  array  $bundles
  * @return void
  */
 public function bundle($bundles = array())
 {
     if (count($bundles) == 0) {
         $bundles = Bundle::names();
     }
     foreach ($bundles as $bundle) {
         // To run PHPUnit for the application, bundles, and the framework
         // from one task, we'll dynamically stub PHPUnit.xml files via
         // the task and point the test suite to the correct directory
         // based on what was requested.
         if (is_dir($path = Bundle::path($bundle) . 'tests')) {
             $this->stub($path);
             $this->test();
         }
     }
 }
Exemplo n.º 4
0
 /**
  * Find a route by the route's assigned name.
  *
  * @param  string  $name
  * @return array
  */
 public static function find($name)
 {
     if (isset(static::$names[$name])) {
         return static::$names[$name];
     }
     // If no route names have been found at all, we will assume no reverse
     // routing has been done, and we will load the routes file for all of
     // the bundles that are installed for the application.
     if (count(static::$names) == 0) {
         foreach (Bundle::names() as $bundle) {
             Bundle::routes($bundle);
         }
     }
     // To find a named route, we will iterate through every route defined
     // for the application. We will cache the routes by name so we can
     // load them very quickly the next time.
     foreach (static::routes() as $method => $routes) {
         foreach ($routes as $key => $value) {
             if (isset($value['as']) and $value['as'] === $name) {
                 return static::$names[$name] = array($key => $value);
             }
         }
     }
 }
Exemplo n.º 5
0
 /**
  * Publish bundle assets to the public directory.
  *
  * @param  array  $bundles
  * @return void
  */
 public function publish($bundles)
 {
     if (count($bundles) == 0) {
         $bundles = Bundle::names();
     }
     array_walk($bundles, array(IoC::resolve('bundle.publisher'), 'publish'));
 }
Exemplo n.º 6
0
 public static function find($name)
 {
     if (isset(static::$names[$name])) {
         return static::$names[$name];
     }
     if (count(static::$names) == 0) {
         foreach (Bundle::names() as $bundle) {
             Bundle::routes($bundle);
         }
     }
     foreach (static::routes() as $method => $routes) {
         foreach ($routes as $key => $value) {
             if (isset($value['as']) and $value['as'] === $name) {
                 return static::$names[$name] = array($key => $value);
             }
         }
     }
 }