# |
Jun 24th 2019, 17:14 |
daniel.upshaw |
```object(Cake\View\ViewBuilder) { [protected] _templatePath => 'Admin/MenuLinks/ajax' [protected] _template => null [protected] _plugin => null [protected] _theme => 'CoreManager' [protected] _layout => null [protected] _autoLayout => null [protected] _layoutPath => 'ajax' [protected] _name => null [protected] _className => 'App' [protected] _options => [] [protected] _helpers => [ (int) 0 => 'CoreManager.Core' ] |
# |
Jun 24th 2019, 17:14 |
daniel.upshaw |
Wow even if I `$this->viewBuilder()->setClassName('App')` |
# |
Jun 24th 2019, 17:12 |
daniel.upshaw |
Could be `setClassName()` perhaps |
# |
Jun 24th 2019, 17:11 |
daniel.upshaw |
Putting it in `beforeRender()` did at least have an effect.. thanks for the input though, I can keep tinkering with this |
# |
Jun 24th 2019, 17:10 |
daniel.upshaw |
@admad Interestingly, even forcing the path to `$this->viewBuilder()->setTemplatePath('Admin/MenuLinks');`, it adds the `ajax` subfolder to that |
# |
Jun 24th 2019, 17:09 |
daniel.upshaw |
I'll try that to test |
# |
Jun 24th 2019, 17:09 |
daniel.upshaw |
Although then it might be for the whole controller |
# |
Jun 24th 2019, 17:09 |
admad |
beforeRender |
# |
Jun 24th 2019, 17:09 |
daniel.upshaw |
Maybe I need it in a beforeFilter method |
# |
Jun 24th 2019, 17:08 |
daniel.upshaw |
The `debug` call does say `null` |
# |
Jun 24th 2019, 17:08 |
daniel.upshaw |
Also tried an empty string `''`, and double checking `debug($this->viewBuilder()->getTemplatePath());` |
# |
Jun 24th 2019, 17:08 |
daniel.upshaw |
@admad That seems like it would be perfect... did try in the `index()` method setting `$this->viewBuilder()->setTemplatePath(null);` but it still tries to fetch the `ajax` subfolder |
# |
Jun 24th 2019, 16:52 |
admad |
@daniel.upshaw RequestHandler sets the template path to `ajax` subfolder. Use `viewBuilder()->setTemplatePath()` to reset it to `null`. |
# |
Jun 24th 2019, 16:36 |
daniel.upshaw |
What if you want to request the HTML page like the normal route? |
# |
Jun 24th 2019, 16:36 |
daniel.upshaw |
An AJAX call with jQuery.... Cake is requiring a separate `/ajax/index.ctp`, with a layout when it detects an AJAX call |
# |
Jun 24th 2019, 16:35 |
slackebot |
<daniel.upshaw> |
# |
Jun 24th 2019, 16:35 |
daniel.upshaw |
Here's something super annoying |
# |
Jun 24th 2019, 16:17 |
daniel.upshaw |
Lol darn |
# |
Jun 24th 2019, 16:17 |
daniel.upshaw |
Oy |
# |
Jun 24th 2019, 16:17 |
a.didier |
i see... I'm on a really old project and i'm not really used to Cake2 and the previous dev did some weird stuff XD Hard to understand |
# |
Jun 24th 2019, 16:15 |
daniel.upshaw |
`app/View/Recipes/search.ctp` |
# |
Jun 24th 2019, 16:15 |
daniel.upshaw |
`app/View/Recipes/share.ctp` |
# |
Jun 24th 2019, 16:15 |
daniel.upshaw |
`app/View/Recipes/view.ctp` |
# |
Jun 24th 2019, 16:15 |
daniel.upshaw |
So each of `view`, `share`, `search` generates a response |
# |
Jun 24th 2019, 16:15 |
daniel.upshaw |
```# /app/Controller/RecipesController.php class RecipesController extends AppController { public function view($id) { //action logic goes here.. } public function share($customerId, $recipeId) { //action logic goes here.. } public function search($query) { //action logic goes here.. } }``` |
# |
Jun 24th 2019, 16:14 |
daniel.upshaw |
Controller should automatically generate a response, but you can customize it first if you need to |
# |
Jun 24th 2019, 16:14 |
daniel.upshaw |
The response is probably from here: https://book.cakephp.org/2.0/en/controllers.html |
# |
Jun 24th 2019, 16:13 |
daniel.upshaw |
So it would already know about `json` for example, so `type->('json')` is already prepared whereas as `vcf` needs `$this->response->type(array('vcf' => 'text/v-card'));` to be set first |
# |
Jun 24th 2019, 16:13 |
daniel.upshaw |
Although in the example, that's a custom one |
# |
Jun 24th 2019, 16:12 |
daniel.upshaw |
So by setting `type->('vcf');`, it's just adding the `text/v-card` MIME type to the headers |
# |
Jun 24th 2019, 16:12 |
daniel.upshaw |
@a.didier I think you can still use a template with a different response type |
# |
Jun 24th 2019, 16:02 |
a.didier |
Hello, quick question : I want to use CakeResponse on Cake2.10 but i have no idea on how to load it... The book show small code like this `$this->response->type('vcf');` nothing on how response is set... |
# |
Jun 24th 2019, 15:01 |
jeremyharris |
I believe the Croogo CMS has visual ACLs. I haven’t looked at it in a while but that might be a good example if they still have it |
# |
Jun 24th 2019, 14:59 |
feLiruc |
Hello guys... I need to implement ACL in a visual way for CakePHP 3.7, do you guys have any good source or tutorial to do that? |
# |
Jun 24th 2019, 14:03 |
jeremyharris |
I’m glad you got it working. I’ll try and set aside some time this week to see if I can make it automatically restore existing handlers somehow |
# |
Jun 24th 2019, 14:03 |
jeremyharris |
I don’t remember at the moment to be honest. I think all known cake-related state is cleaned so that the test cases have a clean state to work with |
# |
Jun 24th 2019, 13:27 |
madbbb |
what is the purpose of EventManager cleaning in default test case setUp() method? I don't get it. As you said I rewrote the setup method and now it works. thank you |
# |
Jun 24th 2019, 13:23 |
jeremyharris |
so your bootstrap will be run when the initial test suite runs, but you’ll need to re-add them in TestCase::setUp (I usually have a base test case class to do this in) so they are added for each test thereafter |
# |
Jun 24th 2019, 13:22 |
jeremyharris |
sorry, your test case setup I mean |
# |
Jun 24th 2019, 13:21 |
madbbb |
but I have require dirname(__DIR__) . '/config/bootstrap.php'; in my test bootstrap.php |
# |
Jun 24th 2019, 13:20 |
jeremyharris |
I think restoring them automatically might be possible, but I haven’t looked into it too much to set up a PR yet |