/** * Retrieve an item and expiry time from the cache by key. * * @param string $key * @return array */ protected function getPayload($key) { $path = $this->path($key); // If the file doesn't exists, we obviously can't return the cache so we will // just return null. Otherwise, we'll get the contents of the file and get // the expiration UNIX timestamps from the start of the file's contents. if (!$this->files->exists($path)) { return array('data' => null, 'time' => null); } try { $expire = substr($contents = $this->files->get($path), 0, 10); } catch (\Exception $e) { return array('data' => null, 'time' => null); } // If the current time is greater than expiration timestamps we will delete // the file and return null. This helps clean up the old files and keeps // this directory much cleaner for us as old files aren't hanging out. if (time() >= $expire) { $this->forget($key); return array('data' => null, 'time' => null); } $data = unserialize(substr($contents, 10)); // Next, we'll extract the number of minutes that are remaining for a cache // so that we can properly retain the time for things like the increment // operation that may be performed on the cache. We'll round this out. $time = ceil(($expire - time()) / 60); return compact('data', 'time'); }
/** * {@inheritDoc} */ public function read($sessionId) { if ($this->files->exists($path = $this->path . DS . $sessionId)) { return $this->files->get($path); } return ''; }
/** * Execute the console command. * * @return void */ public function fire() { $fullPath = $this->createBaseMigration(); $this->files->put($fullPath, $this->files->get(__DIR__ . DS . 'stubs' . DS . 'database.stub')); $this->info('Migration created successfully!'); $this->call('dump-autoload'); }
/** * Get the migration stub file. * * @param string $table * @param bool $create * @return string */ protected function getStub($table, $create) { if (is_null($table)) { return $this->files->get($this->getStubPath() . DS . 'blank.stub'); } else { $stub = $create ? 'create.stub' : 'update.stub'; return $this->files->get($this->getStubPath() . DS . $stub); } }
/** * Get a module's manifest contents. * * @param string $slug * * @return Collection|null */ public function getManifest($slug) { if (is_null($slug)) { return; } $module = Str::slug($slug); $path = $this->getManifestPath($module); $contents = $this->files->get($path); $collection = collect(json_decode($contents, true)); return $collection; }
/** * Get stub content by key. * * @param int $key * * @return string */ protected function getStubContent($key) { $stub = $this->moduleStubs[$key]; $path = __DIR__ . DS . 'stubs' . DS . $stub . '.stub'; $content = $this->files->get($path); return $this->formatContent($content); }
/** * Get all of the method stubs for the given options. * * @param array $options * @return array */ protected function getMethodStubs($options) { $stubs = array(); foreach ($this->getMethods($options) as $method) { $stubs[] = $this->files->get(__DIR__ . DS . 'stubs' . DS . $method . '.stub'); } return $stubs; }
/** * Load the service provider manifest JSON file. * * @return array */ public function loadManifest() { $path = $this->manifestPath . '/services.json'; // The service manifest is a file containing a JSON representation of every // service provided by the application and whether its provider is using // deferred loading or should be eagerly loaded on each request to us. if ($this->files->exists($path)) { $manifest = json_decode($this->files->get($path), true); return array_merge($this->default, $manifest); } }
/** * Get stub content by key. * * @param int $key * * @return string */ protected function getStubContent($stubName) { $stubPath = __DIR__ . DS . 'stubs' . DS; $content = $this->files->get($stubPath . $stubName); return $this->formatContent($content); }
/** * Get the contents of the reminder migration stub. * * @return string */ protected function getMigrationStub() { $stub = $this->files->get(__DIR__ . DS . 'stubs' . DS . 'reminders.stub'); return str_replace('password_reminders', $this->getTable(), $stub); }