예제 #1
0
파일: stub.php 프로젝트: jaz303/zing
 public function __construct($dir)
 {
     $this->directory = $dir;
     $metadata_json = file_get_contents($this->directory . '/zing/plugin.json');
     if ($metadata_json === false) {
         throw new InvalidPluginException("Error loading plugin metadata");
     }
     $this->metadata = json_decode($metadata_json, true);
     if (!$this->metadata) {
         throw new InvalidPluginException("Error decoding JSON metadata");
     }
     if (!$this->metadata('id')) {
         throw new InvalidPluginException("Plugin ID not found");
     }
     if (!Utils::is_valid_plugin_id($this->metadata('id'))) {
         throw new InvalidPluginException("Plugin ID is invalid");
     }
     if (!isset($this->metadata['version'])) {
         throw new InvalidPluginException("Plugin version is missing");
     }
     $this->class_name = \zing\lang\Introspector::first_class_in_file($this->directory . '/zing/plugin.php');
     if (!$this->class_name) {
         throw new InvalidPluginException("plugin primary class is missing");
     }
 }
예제 #2
0
 public function locate_generators()
 {
     $generators = array();
     foreach ($this->generator_paths() as $gp) {
         foreach (glob($gp . '/*.php') as $file) {
             $generators[] = array('name' => preg_replace('/\\.php$/', '', basename($file)), 'file' => $file, 'class' => \zing\lang\Introspector::first_class_in_file($file));
         }
     }
     return $generators;
 }
예제 #3
0
파일: migration.php 프로젝트: jaz303/zing
 /**
  * Locate migrations and return a populated MigrationList
  */
 public function locate_migrations()
 {
     $list = new MigrationList();
     foreach ($this->sources() as $source => $path) {
         foreach (glob($path . '/*.php') as $file) {
             if (preg_match('|/(\\d+)_(\\w+)\\.php$|', $file, $matches)) {
                 $stub = new MigrationStub($this->migrator);
                 $stub->source = $source;
                 $stub->path = $file;
                 $stub->timestamp = (int) $matches[1];
                 $stub->migration_name = $matches[2];
                 $stub->class_name = \zing\lang\Introspector::first_class_in_file($file);
                 $list->add($stub);
             }
         }
     }
     return $list;
 }