/** * {@inheritdoc} */ public function read($sessionId) { $sessionData = []; if ($this->fileSystem->exists($this->sessionPath . '/' . $sessionId) && $this->fileSystem->isReadable($this->sessionPath . '/' . $sessionId)) { $sessionData = unserialize($this->fileSystem->getContents($this->sessionPath . '/' . $sessionId)); } return $sessionData; }
/** * Executes the command. * * @access public * @param \mako\application\Application $application Application instance * @param \mako\file\FileSystem $fileSystem File system instance * @param string $package Package name * @param string $description Migration description */ public function execute(Application $application, FileSystem $fileSystem, $package = null, $description = null) { // Get file path and namespace if (empty($package)) { $namespace = $application->getNamespace() . '\\migrations'; $path = $application->getPath() . '/migrations/'; } else { $package = $application->getPackage($package); $namespace = $package->getClassNamespace() . '\\migrations'; $path = $package->getPath() . '/src/migrations/'; } $path .= 'Migration_' . ($version = gmdate('YmdHis')) . '.php'; // Create migration $description = str_replace("'", "\\'", $description); $search = ['{{namespace}}', '{{version}}', '{{description}}']; $replace = [$namespace, $version, $description]; $migration = str_replace($search, $replace, $fileSystem->getContents(__DIR__ . '/resources/migration.template')); try { $fileSystem->putContents($path, $migration); } catch (Exception $e) { $this->error('Failed to create migration. Make sure that the migrations directory is writable.'); return; } $this->write(vsprintf('Migration created at [ %s ].', [$path])); }
/** * Compiles templates into views. * * @access public * @return string */ public function compile() { // Get teplate contents $contents = $this->fileSystem->getContents($this->template); // Compile template foreach ($this->compileOrder as $method) { $contents = $this->{$method}($contents); } // Store compiled template $this->fileSystem->putContents($this->cachePath . '/' . md5($this->template) . '.php', trim($contents)); }
/** * Executes the command. * * @access public * @param \mako\application\Application $application Application instance * @param \mako\file\FileSystem $fileSystem File system instance */ public function execute(Application $application, FileSystem $fileSystem) { $configFile = $application->getPath() . '/config/application.php'; if (!$fileSystem->isWritable($configFile)) { $this->error('Unable to generate a new secret. Make sure that the [ app/config/application.php ] file is writable.'); return; } if (function_exists('openssl_random_pseudo_bytes')) { $secret = bin2hex(openssl_random_pseudo_bytes(32)); } else { $secret = str_replace(['"', '\''], ['|', '/'], Str::random(Str::ALNUM . Str::SYMBOLS, 64)); } $contents = $fileSystem->getContents($configFile); $contents = preg_replace('/\'secret\'(\\s*)=>(\\s*)\'(.*)\',/', '\'secret\'$1=>$2\'' . $secret . '\',', $contents); $fileSystem->putContents($configFile, $contents); $this->write('A new application secret has been generated.'); }