missing_helper.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 0.10.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. if (!empty($plugin)) {
  20. $namespace = str_replace('/', '\\', $plugin);
  21. }
  22. $pluginPath = Configure::read('App.paths.plugins.0');
  23. $pluginDot = empty($plugin) ? null : $plugin . '.';
  24. if (empty($plugin)) {
  25. $filePath = APP_DIR . DIRECTORY_SEPARATOR;
  26. }
  27. if (!empty($plugin) && Plugin::isLoaded($plugin)) {
  28. $filePath = Plugin::classPath($plugin);
  29. }
  30. if (!empty($plugin) && !Plugin::isLoaded($plugin)) {
  31. $filePath = $pluginPath . h($plugin) . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR;
  32. }
  33. $this->layout = 'dev_error';
  34. $this->assign('title', 'Missing Helper');
  35. $this->assign('templateName', 'missing_helper.php');
  36. $this->start('subheading');
  37. ?>
  38. <strong>Error</strong>
  39. <em><?= h($pluginDot . $class) ?></em> could not be found.
  40. <?= $this->element('plugin_class_error', ['pluginPath' => $pluginPath]) ?>
  41. <?php $this->end() ?>
  42. <?php $this->start('file') ?>
  43. <p class="error">
  44. <strong>Suggestion</strong>
  45. <?= sprintf('Create the class <em>%s</em> below in file: %s', h($class), $filePath . 'View' . DIRECTORY_SEPARATOR . 'Helper' . DIRECTORY_SEPARATOR . h($class) . '.php'); ?>
  46. </p>
  47. <?php
  48. $code = <<<PHP
  49. <?php
  50. namespace {$namespace}\View\Helper;
  51. use Cake\View\Helper;
  52. class {$class} extends Helper
  53. {
  54. }
  55. PHP;
  56. ?>
  57. <div class="code-dump"><?php highlight_string($code) ?></div>
  58. <?php $this->end() ?>