controller

How can I trigger controllerless core Magento modules that watch <controller_action_predispatch> in <frontend> in config.xml from external script

时光毁灭记忆、已成空白 提交于 2019-12-09 22:16:03
问题 For background reference SEE: Magento: How do I get observers to work in an external script? I wanted to ask what the preferred method to 'replicate' a frontend controller's action from an external script is. I am creating an external SSO login for Magento EE 1.12. My code exists as the following in a php file. You can test it by creating test.php and replacing my user (185) with whatever your user ID is. Navigate to the page and then again. You will notice you are logged in and out, however

Magento Router Url - Need Hyphnated Path Name

╄→尐↘猪︶ㄣ 提交于 2019-12-09 18:32:08
问题 Let's say I use a custom controller to have a url path/frontend name of /customcategory Well, obviously if I have a controller file named 'TestController.php' and indexAction the url path would be /customcategory/test/index What I am trying to figure out is how I do re-name the Test Controller, or modify the config xml file, so I can have a hyphenated url from a controller file such as /customcategory/test-section/index I know that if I want /customcategory to be hyphenated, I can just modify

Unit testing a controller method?

北城余情 提交于 2019-12-09 17:51:30
问题 I have a controller method like such: def search = { def query = params.query ... render results as JSON } How do I unit test this? Specifically, how do I call search to set params.query , and how do I test the results of the method render ? Is there a way to mock the render method, perhaps? 回答1: Subclass grails.test.ControllerUnitTestCase for your unit tests. Grails will automatically instantiate your controller and mock out versions of render and redirect that allow you to test the results

Symfony2 access user and doctrine in a service

回眸只為那壹抹淺笑 提交于 2019-12-09 16:11:33
问题 I'm running the equivalent of this code in lots and lots of controller actions, basically it grabs the user's username, and if that username is attached to a blog entity it will allow the user to see the blog entity(s): $em = $this->getDoctrine()->getManager(); $user = $this->get('security.context')->getToken()->getUser(); $entities = $em->getRepository('MySiteBundle:Blog')->findBy(array('user' => $user)); return $this->render('MySiteBundle:Blog:index.html.twig', array( 'entities' =>

Symfony BinaryFileResponse set filename

痞子三分冷 提交于 2019-12-09 14:42:42
问题 is it possible to set own filename when file is returned by Symfony2 controller throught BinaryFileResponse response? 回答1: Yes. The BinaryFileResponse class has a method setContentDisposition() that takes the file name as the second argument. The first argument is the way the file should be delivered. It can be ResponseHeaderBag::DISPOSITION_ATTACHMENT (or just the string "attachment" ) if the file should be offered for downloading, or ResponseHeaderBag::DISPOSITION_INLINE (or "inline" ) if

Passing local variables to a view from controller

本秂侑毒 提交于 2019-12-09 09:18:35
问题 I am not able for some reason to pass local variables to the show view... In my controller i have simply: def show render template: "books/show", :resource => "Some text" end In my view i print the following: <h1>My local variable text: <%= resource %></h1> And i am getting the following message: undefined local variable or method `resource' for #<#<Class:0x00000118ebce90>:0x00000118ec3498> I've tried the following syntaxes in the controller: render template: "books/show", locals: { resource:

MVC: Variables used for only for user-registration. Placed in Controller helper or Model?

a 夏天 提交于 2019-12-09 08:34:28
I found myself in a grey area while cleaning up my "Registration" method in my MVC. Quick background: I create arrays of values that are associated for a particular task. For example: $field_arr //array of all the values from the register-form. $user_arr //array of values needed to create a new user. $required_arr //array of all values that are required for sign up. $values_arr //array that holds all the values for the items in the multiple arrays. etc...etc... At first I began just reorganizing my code by placing these blocks of variable declarations/population in a helper function in the

How do I generate a URL outside of a controller in ASP.NET MVC?

房东的猫 提交于 2019-12-09 08:01:50
问题 How do I generate a URL pointing to a controller action from a helper method outside of the controller? 回答1: Pass UrlHelper to your helper function and then you could do the following: public SomeReturnType MyHelper(UrlHelper url, // your other parameters) { // Your other code var myUrl = url.Action("action", "controller"); // code that consumes your url } 回答2: You could use the following if you have access to the HttpContext : var urlHelper = new UrlHelper(HttpContext.Current.Request

Backbone JS multiple level navigation example

别说谁变了你拦得住时间么 提交于 2019-12-09 04:28:14
问题 I'm trying to construct a solid Backbone JS experiment, where I have a local JSON data file which contains my pages (a project I'm doing has this sort of requirement anyhow). And I've coded this example so I can have endless nested subpages in the pages data. It seems to be working great. But when it comes to the URLs, I'm a little stuck. How do I approach giving this multiple level navigation example totally dynamic URLs? What I mean is, correctly using the url property of the models and

Codeigniter issues with paths in localhost (XAMPP)

丶灬走出姿态 提交于 2019-12-09 03:20:06
问题 The index page (aka homepage.php) in my code igniter install is working fine no matter what. The problem lies with using subdirectories to store other pages, currently its setup like: loading homepage like http://localhost/VAw_CI/ works fine (loading homepage.php), this is setup in routes.php: $route['default_controller'] = "pages/homepage"; in config.php, I've setup: $config['base_url'] = 'http://localhost/VAw_CI'; /* |-------------------------------------------------------------------------