@@ -1772,6 +1772,73 @@ public static function assertLayoutBlockPropertyNotNull($blockName, $propertyNam
1772
1772
);
1773
1773
}
1774
1774
1775
+
1776
+ /**
1777
+ * Dispatch a request.
1778
+ *
1779
+ * @param $baseUrl
1780
+ * @param $requestUri
1781
+ * @param $urlModel
1782
+ *
1783
+ * @return $this
1784
+ */
1785
+ protected function _dispatch ($ baseUrl , $ requestUri , $ urlModel )
1786
+ {
1787
+ $ this ->getRequest ()->resetInternalProperties ();
1788
+
1789
+ $ this ->getRequest ()->setBaseUrl ($ baseUrl )
1790
+ ->setRequestUri ($ requestUri )
1791
+ ->setPathInfo ();
1792
+
1793
+ $ customCookies = $ this ->getRequest ()->getCookie ();
1794
+
1795
+ $ autoCookies = $ this ->getCookies ()->getMatchingCookies ($ requestUri );
1796
+
1797
+ /* @var $cookie Zend_Http_Cookie */
1798
+ foreach ($ autoCookies as $ cookie )
1799
+ {
1800
+ $ this ->getRequest ()->setCookie (
1801
+ $ cookie ->getName (),
1802
+ $ cookie ->getValue ()
1803
+ );
1804
+ }
1805
+
1806
+ if ($ urlModel instanceof Mage_Adminhtml_Model_Url)
1807
+ {
1808
+ // Workaround for secret key in admin
1809
+ $ this ->getRequest ()->setParam (
1810
+ Mage_Adminhtml_Model_Url::SECRET_KEY_PARAM_NAME ,
1811
+ $ urlModel ->getSecretKey ()
1812
+ );
1813
+ }
1814
+
1815
+ if (!$ this ->getRequest ()->getMethod ())
1816
+ {
1817
+ $ this ->getRequest ()->setMethod ('GET ' );
1818
+ }
1819
+
1820
+ // Workaround for form key
1821
+ if ($ this ->getRequest ()->isPost ())
1822
+ {
1823
+ $ this ->getRequest ()->setPost (
1824
+ 'form_key ' ,
1825
+ Mage::getSingleton ('core/session ' )->getFormKey ()
1826
+ );
1827
+ }
1828
+
1829
+ $ this ->getLayout ()->reset ();
1830
+ $ this ->getResponse ()->reset ();
1831
+
1832
+ $ this ->app ()->getFrontController ()->dispatch ();
1833
+
1834
+ // Unset changed cookies
1835
+ $ this ->getRequest ()->resetCookies ();
1836
+ $ this ->getRequest ()->setCookies ($ customCookies );
1837
+
1838
+ return $ this ;
1839
+ }
1840
+
1841
+
1775
1842
/**
1776
1843
* Set up controller params
1777
1844
* (non-PHPdoc)
@@ -1941,12 +2008,32 @@ protected function getUrlModel($route = null, array &$params)
1941
2008
return $ urlModel ;
1942
2009
}
1943
2010
2011
+
1944
2012
/**
1945
- * Dispatches controller action
2013
+ * Dispatch an URL to magento.
2014
+ *
2015
+ * @param string $requestUri
2016
+ * @param array $params
2017
+ *
2018
+ * @return $this
2019
+ */
2020
+ public function dispatchUrl ($ requestUri , $ params = array ())
2021
+ {
2022
+ $ urlModel = $ this ->getUrlModel (null , $ params );
2023
+ $ baseUrl = $ urlModel ->getBaseUrl ($ params );
2024
+
2025
+ return $ this ->_dispatch ($ baseUrl , $ requestUri , $ urlModel );
2026
+ }
2027
+
2028
+
2029
+ /**
2030
+ * Dispatches a route.
1946
2031
*
1947
2032
*
1948
2033
* @param string $route
1949
- * @param array $params
2034
+ * @param array $params
2035
+ *
2036
+ * @return $this
1950
2037
*/
1951
2038
public function dispatch ($ route = null , array $ params = array ())
1952
2039
{
@@ -1957,50 +2044,7 @@ public function dispatch($route = null, array $params = array())
1957
2044
$ requestUri = $ urlModel ->getUrl ($ route , $ params );
1958
2045
$ baseUrl = $ urlModel ->getBaseUrl ($ params );
1959
2046
1960
- $ this ->getRequest ()->resetInternalProperties ();
1961
-
1962
- $ this ->getRequest ()->setBaseUrl ($ baseUrl )
1963
- ->setRequestUri ($ requestUri )
1964
- ->setPathInfo ();
1965
-
1966
- $ customCookies = $ this ->getRequest ()->getCookie ();
1967
-
1968
- $ autoCookies = $ this ->getCookies ()->getMatchingCookies ($ requestUri );
1969
-
1970
- /* @var $cookie Zend_Http_Cookie */
1971
- foreach ($ autoCookies as $ cookie ) {
1972
- $ this ->getRequest ()->setCookie (
1973
- $ cookie ->getName (),
1974
- $ cookie ->getValue ()
1975
- );
1976
- }
1977
-
1978
- if ($ urlModel instanceof Mage_Adminhtml_Model_Url) {
1979
- // Workaround for secret key in admin
1980
- $ this ->getRequest ()->setParam (
1981
- Mage_Adminhtml_Model_Url::SECRET_KEY_PARAM_NAME ,
1982
- $ urlModel ->getSecretKey ()
1983
- );
1984
- }
1985
-
1986
- if (!$ this ->getRequest ()->getMethod ()) {
1987
- $ this ->getRequest ()->setMethod ('GET ' );
1988
- }
1989
-
1990
- // Workaround for form key
1991
- if ($ this ->getRequest ()->isPost ()) {
1992
- $ this ->getRequest ()->setPost ('form_key ' , Mage::getSingleton ('core/session ' )->getFormKey ());
1993
- }
1994
-
1995
- $ this ->getLayout ()->reset ();
1996
- $ this ->getResponse ()->reset ();
1997
-
1998
- $ this ->app ()->getFrontController ()->dispatch ();
1999
-
2000
- // Unset changed cookies
2001
- $ this ->getRequest ()->resetCookies ();
2002
- $ this ->getRequest ()->setCookies ($ customCookies );
2003
- return $ this ;
2047
+ return $ this ->_dispatch ($ baseUrl , $ requestUri , $ urlModel );
2004
2048
}
2005
2049
2006
2050
/**
0 commit comments