Skip to content

Commit

Permalink
Merge pull request #6439 from CarsonF/rm-fire
Browse files Browse the repository at this point in the history
Deprecated ResourceManager Completely
  • Loading branch information
GwendolenLynch committed Mar 2, 2017
2 parents 3450bd6 + 637860b commit 60a3747
Show file tree
Hide file tree
Showing 28 changed files with 309 additions and 289 deletions.
3 changes: 2 additions & 1 deletion app/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@

// Set any non-standard paths
foreach ((array) $config['paths'] as $name => $path) {
$resources->setPath($name, $path);
$resources->setPath($name, $path, false);
}

$resources->verify();
Expand All @@ -164,6 +164,7 @@
'path_resolver_factory' => $pathResolverFactoryFactory,
'path_resolver.root' => $rootPath,
'path_resolver.paths' => (array) $config['paths'],
'resources.bootstrap' => $config['resources'] !== null,
]);

foreach ((array) $config['services'] as $service) {
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"license": "MIT",
"require": {
"bolt/filesystem": "^2.0",
"bolt/filesystem": "^2.2",
"bolt/pathogen": "~0.6",
"bolt/thumbs": "^3.1.1",
"brandonwamboldt/utilphp": "^1.0",
Expand Down
4 changes: 4 additions & 0 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Bolt\Events\ControllerEvents;
use Bolt\Events\MountEvent;
use Bolt\Legacy\AppSingleton;
use Bolt\Provider\LoggerServiceProvider;
use Bolt\Provider\PathServiceProvider;
use Cocur\Slugify\Bridge\Silex\SlugifyServiceProvider;
Expand All @@ -27,6 +28,9 @@ public function __construct(array $values = [])
{
parent::__construct();

/** @deprecated since 3.3, to be removed in 4.0. */
AppSingleton::set($this);

/** @deprecated since 3.0, to be removed in 4.0. */
$values['bolt_version'] = Version::VERSION;
/** @deprecated since 3.0, to be removed in 4.0. */
Expand Down
28 changes: 22 additions & 6 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Bolt\Filesystem\Handler\JsonFile;
use Bolt\Filesystem\Handler\ParsableInterface;
use Bolt\Helpers\Arr;
use Bolt\Helpers\Deprecated;
use Bolt\Helpers\Html;
use Bolt\Helpers\Str;
use Bolt\Translation\Translator;
Expand Down Expand Up @@ -93,7 +94,7 @@ public function initialize()
$this->fields = new Storage\Field\Manager();
$this->defaultConfig = $this->getDefaults();

$this->cacheFile = $this->app['filesystem.cache']->getFile('config-cache.json');
$this->cacheFile = $this->app['filesystem']->getFile('cache://config-cache.json');

$data = $this->loadCache();
if ($data === null) {
Expand Down Expand Up @@ -122,7 +123,7 @@ private function loadTheme()
}
$this->invalidateCache();

$themeDir = $this->app['filesystem.themes']->getDir($this->get('general/theme'));
$themeDir = $this->app['filesystem']->getDir('themes://' . $this->get('general/theme'));

$this->data['theme'] = $this->parseTheme($themeDir, $this->data['general']);
}
Expand All @@ -137,12 +138,19 @@ private function loadTheme()
*/
protected function parseConfigYaml($filename, DirectoryInterface $directory = null)
{
$directory = $directory ?: $this->app['filesystem.config']->getDir('');
$directory = $directory ?: $this->app['filesystem']->getDir('config://');

try {
$file = $directory->get($filename);
} catch (FileNotFoundException $e) {
return [];
// Copy in dist files if applicable
$distFiles = ['config.yml', 'contenttypes.yml', 'menu.yml', 'permissions.yml', 'routing.yml', 'taxonomy.yml'];
if ($directory->getMountPoint() !== 'config' || !in_array($filename, $distFiles)) {
return [];
}

$this->app['filesystem']->copy("bolt://app/config/$filename.dist", "config://$filename");
$file = $directory->get($filename);
}

if (!$file instanceof ParsableInterface) {
Expand Down Expand Up @@ -1213,6 +1221,8 @@ protected function getDefaults()
*/
public function getTwigPath()
{
Deprecated::method(3.3);

$themepath = $this->app['resources']->getPath('templatespath');

$twigpath = [];
Expand Down Expand Up @@ -1300,7 +1310,7 @@ private function isCacheValid()
$cachedConfigTimestamp = $this->cacheFile->getTimestamp();

/** @var \Bolt\Filesystem\Filesystem $configFs */
$configFs = $this->app['filesystem.config'];
$configFs = $this->app['filesystem']->getFilesystem('config');

$configFiles = [
'config.yml',
Expand Down Expand Up @@ -1336,7 +1346,7 @@ private function isThemeCacheValid()
return false;
}

$themeDir = $this->app['filesystem.themes']->getDir($this->get('general/theme'));
$themeDir = $this->app['filesystem']->getDir('themes://' . $this->get('general/theme'));

// Check the timestamp for the theme's configuration file
$timestampTheme = 0;
Expand Down Expand Up @@ -1397,6 +1407,8 @@ protected function checkValidCache()
*/
public function getTimestamp($when)
{
Deprecated::method(3.3);

$timezone = $this->get('general/timezone');
$now = date_format(new \DateTime($when, new \DateTimeZone($timezone)), 'Y-m-d H:i:s');

Expand All @@ -1410,6 +1422,8 @@ public function getTimestamp($when)
*/
public function getCurrentTimestamp()
{
Deprecated::method(3.3);

$timezone = $this->get('general/timezone');
$now = date_format(new \DateTime($timezone), 'Y-m-d H:i:s');

Expand All @@ -1436,6 +1450,8 @@ public function getCurrentTimestamp()
*/
public function getWhichEnd()
{
Deprecated::method(3.0);

$zone = $this->determineZone();
$this->app['end'] = $zone; // This is also deprecated

Expand Down
3 changes: 3 additions & 0 deletions src/Configuration/Composer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Bolt\Configuration;

use Bolt\Helpers\Deprecated;
use Symfony\Component\HttpFoundation\Request;

/**
Expand Down Expand Up @@ -30,6 +31,8 @@ public function __construct($path, Request $request = null, PathResolverFactory

public function getVerifier()
{
Deprecated::method(3.3);

if (! $this->verifier) {
$this->verifier = new ComposerChecks($this);
}
Expand Down
2 changes: 2 additions & 0 deletions src/Configuration/LowlevelChecks.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class LowlevelChecks
*/
public function __construct($config = null)
{
Deprecated::cls(static::class, 3.1);

$this->config = $config;
$this->magicQuotes = get_magic_quotes_gpc();
$this->safeMode = ini_get('safe_mode');
Expand Down
2 changes: 1 addition & 1 deletion src/Configuration/PathResolverFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function setPaths(array $paths)
*/
public function addPaths(array $paths)
{
$this->paths = $paths + $this->paths;
$this->paths = array_replace($this->paths, $paths);

return $this;
}
Expand Down
11 changes: 10 additions & 1 deletion src/Configuration/PathsProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Bolt\Configuration;

use Bolt\Helpers\Deprecated;

/**
* Bolt\Configuration\ResourceManager::getPaths() is proxied here, which used to return a simple array.
*
Expand Down Expand Up @@ -39,6 +41,13 @@ public function offsetExists($offset)
*/
public function offsetGet($offset)
{
Deprecated::warn(
"\$app['paths']['$offset'] in PHP and {{ paths.$offset }} in Twig",
3.0,
'Instead use UrlGenerator or Asset Packages for urls, and Bolt\Filesystem (recommended)' .
' or PathResolver::resolve for filesystem paths.'
);

try {
return $this->resources->getRequest($offset);
} catch (\InvalidArgumentException $e) {
Expand All @@ -62,7 +71,7 @@ public function offsetGet($offset)
*/
public function offsetSet($offset, $value)
{
throw new \LogicException('Use Bolt\Configuration\ResourceManager::setUrl() or setPath() instead.');
throw new \LogicException('You cannot change urls or paths.');
}

/**
Expand Down
67 changes: 0 additions & 67 deletions src/Configuration/PreBoot/ConfigurationFile.php

This file was deleted.

Loading

0 comments on commit 60a3747

Please sign in to comment.