[Solar-svn] Revision 3280
pmjones at solarphp.com
pmjones at solarphp.com
Wed Jul 30 09:53:01 CDT 2008
Solar_View_Helper_ActionHref: [NEW] Helper to work with action 'href' values directly, instead of via Solar_View_Helper_Action. Thanks, Jeff Moore, for the report that led to this.
Added: trunk/Solar/View/Helper/ActionHref.php
===================================================================
--- trunk/Solar/View/Helper/ActionHref.php (rev 0)
+++ trunk/Solar/View/Helper/ActionHref.php 2008-07-30 14:53:01 UTC (rev 3280)
@@ -0,0 +1,50 @@
+<?php
+class Solar_View_Helper_ActionHref extends Solar_View_Helper
+{
+ /**
+ *
+ * Internal URI object for creating links.
+ *
+ * @var Solar_Uri_Action
+ *
+ */
+ protected $_uri = null;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param array $config User-specified configuration.
+ *
+ */
+ public function __construct($config = null)
+ {
+ // do the real configuration
+ parent::__construct($config);
+
+ // get a URI processor
+ $this->_uri = Solar::factory('Solar_Uri_Action');
+ }
+
+ /**
+ *
+ * Returns an escaped href or src attribute value for an action URI.
+ *
+ * @param Solar_Uri_Action|string $spec The href or src specification.
+ *
+ * @return string
+ *
+ */
+ public function actionHref($spec)
+ {
+ if ($spec instanceof Solar_Uri_Action) {
+ // already an action uri object
+ $href = $spec->get();
+ } else {
+ // build-and-fetch the string as an action spec
+ $href = $this->_uri->quick($spec);
+ }
+
+ return $this->_view->escape($href);
+ }
+}
\ No newline at end of file
More information about the Solar-svn
mailing list