Since: 1.0
Author: Bernhard Schussek (bschussek@gmail.com)
Author: Titouan Galopin (galopintitouan@gmail.com)
Inheritance: extends AbstractRepository, implements Puli\Repository\Api\EditableRepository
 /**
  * Creates a new repository.
  *
  * @param string            $path          The path to the JSON file. If
  *                                         relative, it must be relative to
  *                                         the base directory.
  * @param string            $baseDirectory The base directory of the store.
  *                                         Paths inside that directory are
  *                                         stored as relative paths. Paths
  *                                         outside that directory are stored
  *                                         as absolute paths.
  * @param bool              $validateJson  Whether to validate the JSON file
  *                                         against the schema. Slow but
  *                                         spots problems.
  * @param ChangeStream|null $changeStream  If provided, the repository will
  *                                         append resource changes to this
  *                                         change stream.
  */
 public function __construct($path, $baseDirectory, $validateJson = false, ChangeStream $changeStream = null)
 {
     parent::__construct($changeStream);
     $this->baseDirectory = $baseDirectory;
     $this->path = Path::makeAbsolute($path, $baseDirectory);
     $this->encoder = new JsonEncoder();
     $this->encoder->setPrettyPrinting(true);
     $this->encoder->setEscapeSlash(false);
     if ($validateJson) {
         $this->schemaPath = Path::canonicalize(__DIR__ . '/../res/schema/path-mappings-schema-1.0.json');
     }
 }
示例#2
0
 /**
  * Create the repository.
  *
  * @param ChangeStream|null $changeStream If provided, the repository will log
  *                                        resources changes in this change stream.
  */
 public function __construct(ChangeStream $changeStream = null)
 {
     parent::__construct($changeStream);
     $this->clear();
 }
示例#3
0
 /**
  * Creates a new repository.
  *
  * @param string            $baseDir      The base directory of the repository on the file
  *                                        system.
  * @param bool              $symlink      Whether to use symbolic links for added files. If
  *                                        symbolic links are not supported on the current
  *                                        system, the repository will create hard copies
  *                                        instead.
  * @param bool              $relative     Whether to create relative symbolic links. If
  *                                        relative links are not supported on the current
  *                                        system, the repository will create absolute links
  *                                        instead.
  * @param ChangeStream|null $changeStream If provided, the repository will log
  *                                        resources changes in this change stream.
  */
 public function __construct($baseDir = '/', $symlink = true, $relative = true, ChangeStream $changeStream = null)
 {
     parent::__construct($changeStream);
     Assert::directory($baseDir);
     Assert::boolean($symlink);
     $this->baseDir = rtrim(Path::canonicalize($baseDir), '/');
     $this->baseDirLength = strlen($baseDir);
     $this->symlink = $symlink && self::isSymlinkSupported();
     $this->relative = $this->symlink && $relative;
     $this->filesystem = new Filesystem();
 }