Mercurial > hg > isophonics-drupal-site
comparison core/lib/Drupal/Core/Extension/ThemeHandler.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 4c8ae668cc8c |
children | af1871eacc83 |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
1 <?php | 1 <?php |
2 | 2 |
3 namespace Drupal\Core\Extension; | 3 namespace Drupal\Core\Extension; |
4 | 4 |
5 use Drupal\Core\Config\ConfigFactoryInterface; | 5 use Drupal\Core\Config\ConfigFactoryInterface; |
6 use Drupal\Core\Extension\Exception\UninstalledExtensionException; | |
7 use Drupal\Core\Extension\Exception\UnknownExtensionException; | |
6 use Drupal\Core\State\StateInterface; | 8 use Drupal\Core\State\StateInterface; |
7 | 9 |
8 /** | 10 /** |
9 * Default theme handler using the config system to store installation statuses. | 11 * Default theme handler using the config system to store installation statuses. |
10 */ | 12 */ |
145 * {@inheritdoc} | 147 * {@inheritdoc} |
146 */ | 148 */ |
147 public function setDefault($name) { | 149 public function setDefault($name) { |
148 $list = $this->listInfo(); | 150 $list = $this->listInfo(); |
149 if (!isset($list[$name])) { | 151 if (!isset($list[$name])) { |
150 throw new \InvalidArgumentException("$name theme is not installed."); | 152 throw new UninstalledExtensionException("$name theme is not installed."); |
151 } | 153 } |
152 $this->configFactory->getEditable('system.theme') | 154 $this->configFactory->getEditable('system.theme') |
153 ->set('default', $name) | 155 ->set('default', $name) |
154 ->save(); | 156 ->save(); |
155 return $this; | 157 return $this; |
435 * {@inheritdoc} | 437 * {@inheritdoc} |
436 */ | 438 */ |
437 public function getName($theme) { | 439 public function getName($theme) { |
438 $themes = $this->listInfo(); | 440 $themes = $this->listInfo(); |
439 if (!isset($themes[$theme])) { | 441 if (!isset($themes[$theme])) { |
440 throw new \InvalidArgumentException("Requested the name of a non-existing theme $theme"); | 442 throw new UnknownExtensionException("Requested the name of a non-existing theme $theme"); |
441 } | 443 } |
442 return $themes[$theme]->info['name']; | 444 return $themes[$theme]->info['name']; |
443 } | 445 } |
444 | 446 |
445 /** | 447 /** |
484 public function getTheme($name) { | 486 public function getTheme($name) { |
485 $themes = $this->listInfo(); | 487 $themes = $this->listInfo(); |
486 if (isset($themes[$name])) { | 488 if (isset($themes[$name])) { |
487 return $themes[$name]; | 489 return $themes[$name]; |
488 } | 490 } |
489 throw new \InvalidArgumentException(sprintf('The theme %s does not exist.', $name)); | 491 throw new UnknownExtensionException(sprintf('The theme %s does not exist.', $name)); |
490 } | 492 } |
491 | 493 |
492 /** | 494 /** |
493 * {@inheritdoc} | 495 * {@inheritdoc} |
494 */ | 496 */ |