Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecated ResourceManager Completely #6439

Merged
merged 16 commits into from
Mar 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
324d70c
Replace usage of ResourceManager "templatespath" with our filesystem …
CarsonF Feb 28, 2017
b82cccc
Refactor app singleton out of ResourceManager so other parts of the c…
CarsonF Mar 1, 2017
534395e
There are no php files (with translatable strings) in app folder.
CarsonF Mar 1, 2017
f4516ec
Use "app" alias from PathResolver instead of ResourceManager for scan…
CarsonF Mar 1, 2017
456b83d
Removed app::generatePath usage...how did that get through.
CarsonF Mar 1, 2017
95861d0
Updated deprecated filesystems to be lazy and added deprecation notic…
CarsonF Mar 1, 2017
7403fb6
Check for missing .bolt bootstrap file at boot with PathResolver inst…
CarsonF Mar 1, 2017
793c3e6
Add "theme" and authorized plugin to filesystem at boot instead of de…
CarsonF Mar 1, 2017
06cb6f9
Copy config dist files as needed in Config with FS abstraction instea…
CarsonF Mar 1, 2017
ef67a4e
[Tests] Don't delete config.yml for ResourceManagerTest. It isn't rec…
CarsonF Mar 1, 2017
ed98bf1
[Tests] Update AssetTrait tests to use FS memory adapter instead of L…
CarsonF Mar 1, 2017
f73867d
Tweak. This set call doesn't change anything and isn't needed.
CarsonF Mar 1, 2017
5ed4562
Added deprecation notices for Config::getTwigPath, getTimestamp, getC…
CarsonF Mar 1, 2017
72ce119
Added deprecation notices for everything I can around ResourceManager.
CarsonF Mar 1, 2017
c3d01d1
Fix PathResolverFactory::addPaths so they are processed after default…
CarsonF Mar 2, 2017
637860b
Ensure the 'file' parameter exists in individual traces
GwendolenLynch Mar 2, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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