missing_component.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 Component');
  35. $this->assign('templateName', 'missing_component.php');
  36. $this->start('subheading');
  37. printf('<em>%s</em> could not be found.', h($pluginDot . $class));
  38. echo $this->element('plugin_class_error', ['pluginPath' => $pluginPath]);
  39. $this->end();
  40. $this->start('file');
  41. ?>
  42. <p class="error">
  43. <strong>Error</strong>
  44. <?= sprintf('Create the class <em>%s</em> below in file: %s', h($class), $filePath . 'Controller' . DIRECTORY_SEPARATOR . 'Component' . DIRECTORY_SEPARATOR . h($class) . '.php'); ?>
  45. </p>
  46. <?php
  47. $code = <<<PHP
  48. <?php
  49. namespace {$namespace}\Controller\Component;
  50. use Cake\Controller\Component;
  51. class {$class} extends Component
  52. {
  53. }
  54. PHP;
  55. ?>
  56. <div class="code-dump"><?php highlight_string($code) ?></div>
  57. <?php $this->end() ?>