Log message #4103578

# At Username Text
# Dec 14th 2017, 12:41 eax This requires you to have a warning.ctp element under plugins/PluginName/src/Template/Element/Flash for rendering the flash message. And to run $this->Flash->render(); on the page the user is redirected to
# Dec 14th 2017, 12:41 eax @justchariz: Ahh, then you make a $this->Flash->warning('Your Message'); return $this->redirect(['controller' => 'OtherControllerName', 'action' => 'someAction']);
# Dec 14th 2017, 12:39 justcharlz @eax, Let's say an error occurs in a controller method and you want to redirect the user to another controller with the error message
# Dec 14th 2017, 12:37 eax Do you want to do a flash message, or redirect to another controller? Directly redirecting is pretty easy: return $this->redirect(['controller' => 'OtherControllerName', 'action' => 'someAction']);
# Dec 14th 2017, 12:36 justcharlz like redirect to another controller. say redirect to another method but the method is not in the same controller
# Dec 14th 2017, 12:35 eax *justchariz ^
# Dec 14th 2017, 12:35 eax just_chariz: What do you mean by another controller method?
# Dec 14th 2017, 12:34 justcharlz hello guys. how do I make a flash message appear on anther controller method
# Dec 14th 2017, 12:14 eax list?
# Dec 14th 2017, 12:11 circ-user-5T6dZ list
# Dec 14th 2017, 11:33 eax Hey folks! Cake3 ORM Question: I have the relation Users hasMany UserTags. I need to run a Query that gets Users who either have a certain UserTag, or no UserTags at all. Can anyone tell me how to do that? Thanks! :)
# Dec 14th 2017, 11:07 psantos I know the difference
# Dec 14th 2017, 11:07 psantos I got it. Thanks
# Dec 14th 2017, 11:07 neon1024 It’s worth knowing!
# Dec 14th 2017, 11:07 neon1024 There is a difference between `==` and `===`
# Dec 14th 2017, 11:06 psantos when you say that you is little more strict, what do you mean ? now it looks like this: (add is working) ``` if ($this->request->getParam('prefix') == 'admin') { $this->viewBuilder()->setLayout('admin'); } ```
# Dec 14th 2017, 11:04 psantos thanks.. .I was missing this
# Dec 14th 2017, 11:00 neon1024 If you’re on CakePHP 3.4+ at least
# Dec 14th 2017, 11:00 neon1024 You probably meant `$this->request->getParam('prefix') === 'admin'`
# Dec 14th 2017, 10:59 neon1024 I mean, that’s how I do it. Although my check of the prefix is a little more strict
# Dec 14th 2017, 10:59 neon1024 That’s how you do it
# Dec 14th 2017, 10:58 slackebot 'admin') { //$this->layout = 'admin'; $this->viewBuilder()->setLayout('admin'); } ``` any idea ?
# Dec 14th 2017, 10:58 psantos I need to use a differnt layout for all controller in my admin area with admin prefix... so in all controller I am including this: ``` public function beforeFilter(Event $event) { $this->viewBuilder()->setLayout('admin'); } ``` There is no a way to set this on one place only? I tried this in `beforeFilter()` from AppController.php but does not work: ``` if (isset($this->params['prefix']) andand $this->params['prefix'] ==
# Dec 14th 2017, 10:58 neon1024 Especially if you fall into the black hole of trying to mock a table instance, which then mocks the schema which mocks the connection, and down you gooooo
# Dec 14th 2017, 10:57 neon1024 Table method can sometimes be frustrating to test as they often rely on the ORM, which is hard to mock
# Dec 14th 2017, 10:56 neon1024 As you’re not testing the entity
# Dec 14th 2017, 10:56 neon1024 So in your test you use a generic entity mock
# Dec 14th 2017, 10:55 neon1024 Which then abstracts away the concrete class instance
# Dec 14th 2017, 10:55 neon1024 Unless your method requires a specific method in the entity class, you can typehint `EntityInterface`
# Dec 14th 2017, 10:55 neon1024 The D in SOLID
# Dec 14th 2017, 10:53 birdy247 :+1:
# Dec 14th 2017, 10:52 neon1024 Or mock it
# Dec 14th 2017, 10:52 neon1024 Use `new Entity()`
# Dec 14th 2017, 10:52 birdy247 i.e. new PaymentOptions([...
# Dec 14th 2017, 10:52 birdy247 Would it be ok, to use ->get() in my table test to get the entity, or better to setup the entity in the test itself
# Dec 14th 2017, 10:51 birdy247 @neon1024 I am trying to test a Table method. I pass the table method an entity
# Dec 14th 2017, 10:45 birdy247 @neon1024 SOLID advice :)
# Dec 14th 2017, 10:31 neon1024 Follow Chris, https://twitter.com/grmpyprogrammer
# Dec 14th 2017, 10:26 neon1024 That’s the balance
# Dec 14th 2017, 10:26 neon1024 But not pre-optimisation!
# Dec 14th 2017, 10:26 neon1024 Then you start seeing the code smells as you’re creating them, allowing for more pro-active refactoring