original_string: public function beforeRender(Event $event)
      {
          $plugin = (string)Inflector::camelize($event->subject()->request->params['plugin']);
          $controller = Inflector::camelize($event->subject()->request->params['controller']);
          $action = Inflector::underscore($event->subject()->request->params['action']);
          $prefix = '';
  
          if (!empty($event->subject()->request->params['prefix'])) {
              $prefix = Inflector::camelize($event->subject()->request->params['prefix']) . '/';
          }
  
          $templatePath = Plugin::classPath($plugin) . "Template/{$prefix}{$controller}/{$action}.ctp";
          if (!is_readable($templatePath)) {
              $alternativeTemplatePath = Plugin::classPath('Comment') . 'Template/CommentUI';
              if (is_readable("{$alternativeTemplatePath}/{$action}.ctp")) {
                  $this->plugin = 'Comment';
                  $this->viewBuilder()->templatePath('CommentUI');
              }
          }
  
          parent::beforeRender($event);
      }
code: public function beforeRender(Event $event)
      {
          $plugin = (string)Inflector::camelize($event->subject()->request->params['plugin']);
          $controller = Inflector::camelize($event->subject()->request->params['controller']);
          $action = Inflector::underscore($event->subject()->request->params['action']);
          $prefix = '';
  
          if (!empty($event->subject()->request->params['prefix'])) {
              $prefix = Inflector::camelize($event->subject()->request->params['prefix']) . '/';
          }
  
          $templatePath = Plugin::classPath($plugin) . "Template/{$prefix}{$controller}/{$action}.ctp";
          if (!is_readable($templatePath)) {
              $alternativeTemplatePath = Plugin::classPath('Comment') . 'Template/CommentUI';
              if (is_readable("{$alternativeTemplatePath}/{$action}.ctp")) {
                  $this->plugin = 'Comment';
                  $this->viewBuilder()->templatePath('CommentUI');
              }
          }
  
          parent::beforeRender($event);
      }
code_tokens: public function beforeRender ( Event $ event ) { $ plugin = ( string ) Inflector :: camelize ( $ event -> subject ( ) -> request -> params [ 'plugin' ] ) ; $ controller = Inflector :: camelize ( $ event -> subject ( ) -> request -> params [ 'controller' ] ) ; $ action = Inflector :: underscore ( $ event -> subject ( ) -> request -> params [ 'action' ] ) ; $ prefix = '' ; if ( ! empty ( $ event -> subject ( ) -> request -> params [ 'prefix' ] ) ) { $ prefix = Inflector :: camelize ( $ event -> subject ( ) -> request -> params [ 'prefix' ] ) . '/' ; } $ templatePath = Plugin :: classPath ( $ plugin ) . "Template/{$prefix}{$controller}/{$action}.ctp" ; if ( ! is_readable ( $ templatePath ) ) { $ alternativeTemplatePath = Plugin :: classPath ( 'Comment' ) . 'Template/CommentUI' ; if ( is_readable ( "{$alternativeTemplatePath}/{$action}.ctp" ) ) { $ this -> plugin = 'Comment' ; $ this -> viewBuilder ( ) -> templatePath ( 'CommentUI' ) ; } } parent :: beforeRender ( $ event ) ; }
docstring: Fallback for template location when extending Comment UI API.
  
  If controller tries to render an unexisting template under its Template
  directory, then we try to find that view under `Comment/Template/CommentUI`
  directory.
  
  ### Example:
  
  Suppose you are using this trait to manage comments attached to `Persons`
  entities. You would probably have a `Person` plugin and a `clean` controller
  as follow:
  
  // http://example.com/admin/person/comments_manager
  Person\Controller\CommentsManagerController::index()
  
  The above controller action will try to render
  `/plugins/Person/Template/CommentsManager/index.ctp`. But if does not exists
  then `<QuickAppsCorePath>/plugins/Comment/Template/CommentUI/index.ctp` will
  be used instead.
  
  Of course you may create your own template and skip this fallback functionality.
  
  @param \Cake\Event\Event $event the event instance.
  @return void
docstring_tokens: Fallback for template location when extending Comment UI API .