예제 #1
0
 /**
  * Register new public module file. File will moved to application webroot directory when module
  * will be installed or updated and replace existed file if allowed.
  *
  * File must be located in module directory and defined by relative name (to moduleDirectory).
  * Destination may differ from original filename or have specified file permissions.
  *
  * Examples:
  * $installer->registerFile(
  *      'resources/script.js',
  *      '/resources/scripts/plugin/script.js',
  *      FilesInterface::RUNTIME
  * );
  *
  * @see moduleDirectory()
  * @param string $source      Source filename relative to modules directory.
  * @param string $destination Destination filename relative to "webroot" directory.
  * @param int    $mode        File mode.
  * @return $this
  * @throws InstallerException
  */
 public function publishFile($source, $destination, $mode = FilesInterface::READONLY)
 {
     $source = $this->files->normalizePath($source);
     //Full path to module filename
     $filename = $this->files->normalizePath($this->moduleDirectory . FilesInterface::SEPARATOR . $source);
     if (!$this->files->exists($filename)) {
         throw new InstallerException("Unable to public file '{$source}'', file not found in module root directory.");
     }
     $fullDestination = $this->files->normalizePath($this->modules->publicDirectory() . FilesInterface::SEPARATOR . $destination);
     $this->publicFiles[$this->files->normalizePath($destination)] = ['filename' => $filename, 'destination' => $fullDestination, 'hash' => $this->files->md5($filename), 'size' => $this->files->size($filename), 'mode' => $mode];
     return $this;
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function isInstalled()
 {
     return (bool) $this->modules->hasModule($this->getName());
 }