Exemple #1
0
 /**
  * Constructor
  *
  * @param string $name   The name of the repository. Must match /[A-Za-z0-9_-]{1,63}+/
  * @param Config $config The config to use for this repo
  */
 public function __construct($name, Config $config)
 {
     // Setup class properties
     $this->name = $name;
     $this->path = $config->getPath() . DIRECTORY_SEPARATOR . $name;
     $this->formatter = $config->getOption('formatter');
     // Ensure the repo name is valid
     $this->validateName($this->name);
     // Ensure directory exists and we can write there
     if (!file_exists($this->path)) {
         mkdir($this->path);
         chmod($this->path, 0777);
     }
 }
Exemple #2
0
 /**
  * Constructor
  *
  * @param string $name   The name of the repository. Must match /[A-Za-z0-9_-]{1,63}+/
  * @param Config $config The config to use for this repo
  */
 public function __construct($name, Config $config)
 {
     // Setup class properties
     $this->name = $name;
     $this->path = $config->getPath() . DIRECTORY_SEPARATOR . $name;
     $this->formatter = $config->getOption('formatter');
     $this->queryClass = $config->getOption('query_class');
     $this->documentClass = $config->getOption('document_class');
     // Ensure the repo name is valid
     $this->validateName($this->name);
     // Ensure directory exists and we can write there
     if (!is_dir($this->path)) {
         if (!@mkdir($this->path, 0777, true)) {
             throw new \RuntimeException(sprintf('`%s` doesn\'t exist and can\'t be created.', $this->path));
         }
     } else {
         if (!is_writable($this->path)) {
             throw new \RuntimeException(sprintf('`%s` is not writable.', $this->path));
         }
     }
 }
Exemple #3
0
 public function testSlashesTidedUp()
 {
     $path = __DIR__ . '/fixtures/datastore/writable';
     $config = new Config($path . '/');
     $this->assertSame($path, $config->getPath());
 }
Exemple #4
0
 /**
  * Test the get/set of the path to the configuration file (yal)
  */
 public function testSetPathOnConstruct()
 {
     $path = __DIR__ . '/' . $this->path;
     $config = new Config($path);
     $this->assertEquals($path, $config->getPath());
 }
Exemple #5
0
 protected function getAppClass(Config $config)
 {
     // Use a custom App class?
     if ($this->allow_custom_class) {
         $__file = $config->get('class_file') ?: $config->getPath() . 'Application.php';
         if (is_readable($__file)) {
             include $__file;
             if ($config->has('namespace')) {
                 $class = $config->get('namespace') . '\\Application';
             } else {
                 $class = ucfirst($name) . 'Application';
             }
             if (class_exists($class, false) && $this->isValidClass($class)) {
                 return $class;
             }
         }
     }
     return $this->class;
 }