Development

#388 (support custom view class files on the app and not only on %SF_SYMFONY_LIB_DIR%/view)

You must first sign up to be able to contribute.

Ticket #388 (closed enhancement: fixed)

Opened 3 years ago

Last modified 7 months ago

support custom view class files on the app and not only on %SF_SYMFONY_LIB_DIR%/view

Reported by: juan.cataldo@gmail.com Assigned to:
Priority: major Milestone: 1.1.0
Component: view Version:
Keywords: Cc:
Qualification: Unreviewed

Description

Trying to override sfPHPView I created a file named module.yml on apps/myapp/config and filled it with:

all:
  view_class: dom

I wanted to provide the custom view class file (domView.class.php) from my app, but sfController->getView() looks for it only on %SF_SYMFONY_LIB_DIR%/view and crashes symfony.

I think it's impractical to mess with symfony files when I want to implement a customization for this app only.

As a workaround I made an autoload.yml rule for my custom class and removed some verification code from sfController.class.php (I'll post the patch) so it just autoload it.

I'd love to see a better solution for this problem. Thanks.

Attachments

patch-custom-view-class.diff (0.8 kB) - added by juan.cataldo@gmail.com on 04/02/06 09:51:34.
Removes validation of the existence of the view class on %SF_SYMFONY_LIB_DIR%/view

Change History

04/02/06 09:51:34 changed by juan.cataldo@gmail.com

  • attachment patch-custom-view-class.diff added.

Removes validation of the existence of the view class on %SF_SYMFONY_LIB_DIR%/view

04/10/06 11:17:17 changed by fabien

  • milestone set to 1.0.0.

06/16/06 09:46:47 changed by fabien

  • milestone changed from 0.6.4 to 1.0.0.

08/22/06 22:33:21 changed by fabien

  • status changed from new to closed.
  • resolution set to wontfix.

This patch can't work with the actual symfony release.

08/25/06 07:26:43 changed by juan

Granted, the patch was only a workaround.

But, does this mean that if I want to provide a custom view class for my app, I'm forced to put the file in %SF_SYMFONY_LIB_DIR%/view ?

I still think it's impractical to mess with symfony files when I want to implement a customization for this app only.

10/17/06 01:15:23 changed by pookey

  • status changed from closed to reopened.
  • version deleted.
  • resolution deleted.
  • milestone changed from 0.6.4 to post-1.0.

I'm re-opening this... becuase I feel it's important.

a sfSmaryPlugin would be a fantastic addition to symfony (even though I hate smarty, and don't understand why someone would want to use it, but that choice isn't mine to make), and without this it's not possible.

here's a quick patch to atleast allow people to put a view class in apps/$app/lib/view, however I'm not sure why loading this class can't just be left upto the autoload system?

Index: lib/symfony/controller/sfController.class.php
===================================================================
--- lib/symfony/controller/sfController.class.php       (revision 2414)
+++ lib/symfony/controller/sfController.class.php       (working copy)
@@ -473,7 +473,14 @@
       // view class (as configured in module.yml or defined in action)
       $viewName = $this->getContext()->getRequest()->getAttribute($moduleName.'_'.$actionName.'_view_name', sfConfig::get('mod_'.strtolower($moduleName).'_view_class'), 'symfony/action/view');
       $file     = sfConfig::get('sf_symfony_lib_dir').'/view/'.$viewName.'View.class.php';
-      $class    = is_readable($file) ? $viewName.'View' : 'sfPHPView';
+      if (is_readable($file) || is_readable(sfConfig::get('sf_app_lib_dir').'/view/'.$viewName.'View.class.php'))
+      {
+        $class = $viewName.'View';
+      }
+      else
+      {
+        $class = 'sfPHPView';
+      }
     }

     return new $class();

02/26/08 04:59:27 changed by Carl.Vondrick

  • component set to view.
  • qualification set to Unreviewed.

05/10/08 22:38:41 changed by fabien

  • status changed from reopened to closed.
  • resolution set to fixed.
  • milestone changed from post-1.0 to 1.1.0.