get() 공개 메소드

Get a specific data from json file by given the key.
public get ( $key, null $default = null ) : mixed
$key
$default null
리턴 mixed
예제 #1
0
 /**
  * @param Module $module
  *
  * @return void
  */
 public function moduleSeed(Module $module)
 {
     $seeders = [];
     $name = $module->getName();
     $config = $module->get('migration');
     if (is_array($config) && array_key_exists('seeds', $config)) {
         foreach ((array) $config['seeds'] as $class) {
             if (@class_exists($class)) {
                 $seeders[] = $class;
             }
         }
     } else {
         $class = $this->getSeederName($name);
         //legacy support
         if (@class_exists($class)) {
             $seeders[] = $class;
         }
     }
     if (count($seeders) > 0) {
         array_walk($seeders, [$this, 'dbSeed']);
         $this->info("Module [{$name}] seeded.");
     }
 }
예제 #2
0
 /** @test */
 public function it_reads_key_from_module_json_file_via_helper_method()
 {
     $this->assertEquals('Recipe', $this->module->get('name'));
     $this->assertEquals('0.1', $this->module->get('version'));
     $this->assertEquals('my default', $this->module->get('some-thing-non-there', 'my default'));
 }
예제 #3
0
 /**
  * Get migration path.
  *
  * @return string
  */
 public function getPath()
 {
     $config = $this->module->get('migration');
     $path = is_array($config) && array_key_exists('path', $config) ? $config['path'] : config('modules.paths.generator.migration');
     return $this->module->getExtraPath($path);
 }