Example #1
0
 /**
  * Get the composer command for the environment.
  *
  * @return string
  */
 protected function findComposer()
 {
     if ($this->files->exists($this->workingPath . '/composer.phar')) {
         return 'php composer.phar';
     } else {
         return 'composer';
     }
 }
 /**
  * Copy all assets from a given path to the publish path.
  *
  * @param  string  $name
  * @param  string  $source
  * @return bool
  */
 public function publish($name, $source)
 {
     $destination = $this->publishPath . "/packages/{$name}";
     $success = $this->files->copyDirectory($source, $destination);
     if (!$success) {
         throw new \RuntimeException("Unable to publish assets.");
     }
     return $success;
 }
 /**
  * Get the migration stub file.
  *
  * @param  string  $table
  * @return void
  */
 protected function getStub($table, $create)
 {
     if (is_null($table)) {
         return $this->files->get($this->getStubPath() . '/blank.php');
     } else {
         $stub = $create ? 'create.php' : 'update.php';
         return $this->files->get($this->getStubPath() . "/{$stub}");
     }
 }
 /**
  * Get all of the method stubs for the given options.
  *
  * @param  array  $options
  * @return array
  */
 protected function getMethodStubs($options)
 {
     $stubs = array();
     // Each stub is conveniently kept in its own file so we can just grab the ones
     // we need from disk to build the controller file. Once we have them all in
     // an array we will return this list of methods so they can be joined up.
     foreach ($this->getMethods($options) as $method) {
         $stubs[] = $this->files->get(__DIR__ . "/stubs/{$method}.php");
     }
     return $stubs;
 }
 /**
  * Remove session records older than a given expiration.
  *
  * @param  int   $expiration
  * @return void
  */
 public function sweep($expiration)
 {
     foreach ($this->files->files($this->path) as $file) {
         // If the last modification timestamp is less than the given UNIX expiration
         // timestamp, it indicates the session has expired and should be removed
         // off of the disks so we don't use space for files that have expired.
         if ($this->files->lastModified($file) < $expiration) {
             $this->files->delete($file);
         }
     }
 }
Example #6
0
 /**
  * Copy all assets from a given path to the publish path.
  *
  * @param  string  $source
  * @param  string  $name
  * @return bool
  */
 public function publish($source, $name)
 {
     $destination = $this->publishPath . "/packages/{$name}";
     $success = $this->files->copyDirectory($source, $destination);
     // If were unable to publish the assets, it coule mean that the source folder
     // does not exists. So, the developer should probably check that the given
     // source location is valid, otherwise, verify the target's permissions.
     if (!$success) {
         throw new \RuntimeException("Unable to publish assets.");
     }
     return $success;
 }
Example #7
0
 /**
  * Get all of the files at a given path.
  *
  * @param  string  $path
  * @return array
  */
 protected function getFiles($path)
 {
     if (isset($this->seeds)) {
         return $this->seeds;
     }
     // If the seeds haven't been read before, we will glob the directory and sort
     // them alphabetically just in case the developer is using numbers to make
     // the seed run in a certain order based on their database design needs.
     $files = $this->files->glob($path . '/*.php');
     sort($files);
     return $this->seeds = $files;
 }
 /**
  * Determine if the view at the given path is expired.
  *
  * @param  string  $path
  * @return bool
  */
 public function isExpired($path)
 {
     $compiled = $this->getCompiledPath($path);
     // If the compiled file doesn't exist we will indicate that the view is expired
     // so that it can be re-compiled. Else, we will verify the last modification
     // of the views is less than the modification times of the compiled views.
     if (!$this->cachePath or !$this->files->exists($compiled)) {
         return true;
     }
     $lastModified = $this->files->lastModified($path);
     return $lastModified >= $this->files->lastModified($compiled);
 }
 /**
  * Find the given view in the list of paths.
  *
  * @param  string  $name
  * @param  array   $paths
  * @return string
  */
 protected function findInPaths($name, $paths)
 {
     foreach ((array) $paths as $path) {
         foreach ($this->getPossibleViewFiles($name) as $file) {
             if ($this->files->exists($viewPath = $path . '/' . $file)) {
                 return $viewPath;
             }
         }
     }
     throw new \InvalidArgumentException("View [{$name}] not found.");
 }
 /**
  * Create a workbench directory for the package.
  *
  * @param  Illuminate\Workbench\Package  $package
  * @param  string  $path
  * @return string
  */
 protected function createDirectory(Package $package, $path)
 {
     $fullPath = $path . '/' . $package->getFullName();
     // If the directory doesn't exist, we will go ahead and create the package
     // directory in the workbench location. We will use this entire package
     // name when creating the directory to avoid any potential conflicts.
     if (!$this->files->isDirectory($fullPath)) {
         $this->files->makeDirectory($fullPath, 0777, true);
         return $fullPath;
     }
     throw new \InvalidArgumentException("Package exists.");
 }
Example #11
0
 /**
  * Get all of the migration files in a given path.
  *
  * @param  string  $path
  * @return array
  */
 public function getMigrationFiles($path)
 {
     $files = $this->files->glob($path . '/*_*.php');
     // Once we have the array of files in the directory we will just remove the
     // extension and take the basename of the file which is all we need when
     // finding the migrations that haven't been run against the databases.
     if ($files === false) {
         return array();
     }
     $files = array_map(function ($file) {
         return str_replace('.php', '', basename($file));
     }, $files);
     // Once we have all of the formatted file names we will sort them and since
     // they all start with a timestamp this should give us the migrations in
     // the order they were actually created by the application developers.
     sort($files);
     return $files;
 }
Example #12
0
 /**
  * Create the destination directory if it doesn't exist.
  *
  * @param  string  $destination
  * @return void
  */
 protected function makeDestination($destination)
 {
     if (!$this->files->isDirectory($destination)) {
         $this->files->makeDirectory($destination, 0777, true);
     }
 }
 /**
  * Get a file's contents by requiring it.
  *
  * @param  string  $path
  * @return mixed
  */
 protected function getRequire($path)
 {
     return $this->files->getRequire($path);
 }
Example #14
0
 /**
  * Require the given migration files.
  *
  * @param  array  $files
  * @return void
  */
 protected function requireFiles(array $files)
 {
     foreach ($files as $file) {
         $this->files->requireOnce($file);
     }
 }
Example #15
0
 /**
  * Write the service manifest file to disk.
  *
  * @param  Illuminate\Foundation\Application  $app
  * @param  array  $manifest
  * @return array
  */
 public function writeManifest(Application $app, $manifest)
 {
     $this->files->put($this->manifestPath($app), json_encode($manifest));
     return $manifest;
 }
 /**
  * Write the service manifest file to disk.
  *
  * @param  array  $manifest
  * @return array
  */
 public function writeManifest($manifest)
 {
     $path = $this->manifestPath . '/services.json';
     $this->files->put($path, json_encode($manifest));
     return $manifest;
 }
 /**
  * Remove all items from the cache.
  *
  * @return void
  */
 protected function flushItems()
 {
     $this->files->cleanDirectory($this->directory);
 }
Example #18
-1
 /**
  * Load a locale from a given path.
  *
  * @param  string  $path
  * @param  string  $locale
  * @param  string  $group
  * @return array
  */
 protected function loadPath($path, $locale, $group)
 {
     if ($this->files->exists($full = "{$path}/{$locale}/{$group}.php")) {
         return array_dot($this->files->getRequire($full));
     }
     return array();
 }