Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Only register routes if required by the user

  • Loading branch information...
commit 36a1251ad1b0f7437e4a2b5902d466c1f822206e 1 parent d11fa78
@VanTanev authored
View
2  config/app.yml
@@ -30,6 +30,8 @@
# escape_values: false
# ## For foreign keys, this setting will make the plugin retrieve the foreign object and use its __toString() representation.
# get_foreign_values: false
+# ## Register routes for a simple interface to view changelogs
+# routes_register: false
# ## Fields that should be ignored when looking for changes in an object...
# ignore_fields:
View
7 config/config.php
@@ -6,7 +6,6 @@
array('ncPropelChangeLogBehavior', 'get1NRelatedChangeLog'),
array('ncPropelChangeLogBehavior', 'getNNRelatedChangeLog'),
array('ncPropelChangeLogBehavior', 'getRelatedChangeLog'),
- array('ncPropelChangeLogBehavior', 'getChangeLogRoute'),
array('ncPropelChangeLogBehavior', 'getLatestChangeLogEntry'),
array('ncPropelChangeLogBehavior', 'setCustomChangeMessage')
));
@@ -17,3 +16,9 @@
':save:post' => array('ncPropelChangeLogBehavior', 'postSave'),
':delete:post' => array('ncPropelChangeLogBehavior', 'postDelete'),
));
+
+if (sfConfig::get('app_nc_change_log_behavior_register_routes', false) && in_array('ncChangeLogEntry', sfConfig::get('sf_enabled_modules', array())))
+{
+ // setup the ncChangeLogEntry routes
+ $this->dispatcher->connect('routing.load_configuration', array('ncChangeLogRouting', 'listenToRoutingLoadConfigurationEvent'));
+}
View
14 config/routing.yml
@@ -1,14 +0,0 @@
-## Copyright: 2009 - José Nahuel Cuesta Luengo <ncuesta@cespi.unlp.edu.ar>
-##
-## ncPropelChangeLogBehaviorPlugin routing file.
-##
-
-## Details for an entry
-nc_change_log_detail:
- url: /change_log/show/:id
- param: { module: ncchangelogentry, action: show }
-
-## Change Log for a specific object
-nc_change_log:
- url: /change_log/:class/:pk
- param: { module: ncchangelogentry, action: index }
View
18 lib/routing/ncChangeLogRouting.class.php
@@ -0,0 +1,18 @@
+<?php
+
+class ncChangeLogRouting
+{
+ /**
+ * Listens to the routing.load_configuration event.
+ *
+ * @param sfEvent An sfEvent instance
+ */
+ static public function listenToRoutingLoadConfigurationEvent(sfEvent $event)
+ {
+ $r = $event->getSubject();
+
+ // preprend our routes
+ $r->prependRoute('nc_change_log_detail', new sfRoute('/change_log/show/:id', array('module' => 'ncChangeLogEntry', 'action' => 'show')));
+ $r->prependRoute('nc_change_log', new sfRoute('/change_log/:class/:pk', array('module' => 'ncChangeLogEntry', 'action' => 'index')));
+ }
+}
View
4 modules/ncchangelogentry/actions/actions.class.php
@@ -6,10 +6,10 @@
* ncchangelogentry actions.
*
* @package sumarios
- * @subpackage ncchangelogentry
+ * @subpackage ncChangeLogEntry
* @author ncuesta
* @version SVN: $Id: actions.class.php 12479 2008-10-31 10:54:40Z fabien $
*/
-class ncchangelogentryActions extends autoNcchangelogentryActions
+class ncChangeLogEntryActions extends autoNcChangeLogEntryActions
{
}
View
9 modules/ncchangelogentry/lib/autoNcchangelogentryActions.class.php
@@ -4,11 +4,10 @@
* autoNcchangelogentry actions.
*
* @package sumarios
- * @subpackage ncchangelogentry
+ * @subpackage ncChangeLogEntryActionsy
* @author ncuesta
- * @version SVN: $Id: actions.class.php 12479 2008-10-31 10:54:40Z fabien $
*/
-class autoNcchangelogentryActions extends sfActions
+class autoNcChangeLogEntryActions extends sfActions
{
/**
* Executes index action.
@@ -43,7 +42,7 @@ public function executeShow(sfWebRequest $request)
/**
* Use $request to obtain the object of the changeLog.
- *
+ *
* @param sfWebRequest $request
*/
protected function getObject(sfWebRequest $request)
@@ -58,7 +57,7 @@ protected function getObject(sfWebRequest $request)
{// throw new Exception($pk);
return call_user_func_array(array($peer_class, 'retrieveByPK'), $pk);
}
-
+
throw new sfException('Unable to find class "'.$peer_class.'".');
}
Please sign in to comment.
Something went wrong with that request. Please try again.