missing_view.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  5. *
  6. * Licensed under The MIT License
  7. * For full copyright and license information, please see the LICENSE.txt
  8. * Redistributions of files must retain the above copyright notice.
  9. *
  10. * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  11. * @link https://cakephp.org CakePHP(tm) Project
  12. * @since 3.0.0
  13. * @license https://opensource.org/licenses/mit-license.php MIT License
  14. * @var string $class
  15. */
  16. use Cake\Core\Configure;
  17. use Cake\Core\Plugin;
  18. $namespace = Configure::read('App.namespace');
  19. $pluginPath = Configure::read('App.paths.plugins.0');
  20. $pluginDot = empty($plugin) ? null : $plugin . '.';
  21. if (empty($plugin)) {
  22. $filePath = APP_DIR . DIRECTORY_SEPARATOR;
  23. $namespace = str_replace('/', '\\', $plugin);
  24. }
  25. if (!empty($plugin) && Plugin::isLoaded($plugin)) {
  26. $filePath = Plugin::classPath($plugin);
  27. }
  28. if (!empty($plugin) && !Plugin::isLoaded($plugin)) {
  29. $filePath = $pluginPath . h($plugin) . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR;
  30. }
  31. $this->layout = 'dev_error';
  32. $this->assign('title', 'Missing View');
  33. $this->assign('templateName', 'missing_view.php');
  34. $this->start('subheading');
  35. ?>
  36. <strong>Error</strong>
  37. <em><?= h($pluginDot . $class) ?></em> could not be found.
  38. <?php if (!empty($plugin) && !Plugin::isLoaded($plugin)): ?>
  39. Make sure your plugin <em><?= h($plugin) ?></em> is in the <?= h($pluginPath) ?> directory and was loaded.
  40. <?php endif ?>
  41. <?= $this->element('plugin_class_error', ['pluginPath' => $pluginPath]) ?>
  42. <?php $this->end() ?>
  43. <?php $this->start('file') ?>
  44. <p class="error">
  45. <strong>Suggestion</strong>
  46. <?= sprintf('Create the class <em>%s</em> below in file: %s', h($class), $filePath . 'View' . DIRECTORY_SEPARATOR . h($class) . '.php'); ?>
  47. </p>
  48. <?php
  49. $code = <<<PHP
  50. <?php
  51. namespace {$namespace}\View;
  52. use Cake\View\View;
  53. class {$class}View extends View
  54. {
  55. }
  56. PHP;
  57. ?>
  58. <div class="code-dump"><?php highlight_string($code) ?></div>
  59. <?php $this->end() ?>