# |
Oct 18th 2019, 18:18 |
slackebot1 |
'MspPivotActivityLogDetails' ] ] ); $this->set('logs', $query); } |
# |
Oct 18th 2019, 18:18 |
ron.rattie |
namespace AuditTrails\Controller; use AuditTrails\Controller\AppController; use Cake\ORM\TableRegistry; class LogsController extends AppController { public function index() { $AuditTrailsLog = TableRegistry::getTableLocator()->get('AuditTrails.MspPivotActivityLog'); $query = $AuditTrailsLog->find( 'all', [ 'contain' => [ 'MspPivotActivityLogRequest', |
# |
Oct 18th 2019, 18:18 |
ron.rattie |
My Logs controller has this: |
# |
Oct 18th 2019, 18:17 |
ron.rattie |
use Cake\Routing\RouteBuilder; use Cake\Routing\Router; use Cake\Routing\Route\DashedRoute; Router::plugin( 'AuditTrails', ['path' => '/audit-trails'], function ($routes) { $routes->get('/logs', ['controller' => 'Logs']); } ); |
# |
Oct 18th 2019, 18:16 |
ron.rattie |
This is the router for the plugin: |
# |
Oct 18th 2019, 18:16 |
ron.rattie |
Hey, I have a routing question I think. I have a plugin "Audit Trails" with a controller "Logs" with an index function. When I go to /audit-trails/logs I see "Controller class AuditTrails could not be found". |
# |
Oct 18th 2019, 16:48 |
daniel.upshaw |
I bet my routes issue is that this project uses `"cakephp/cakephp": "3.5.*"` |
# |
Oct 18th 2019, 16:19 |
neothermic |
sweet, init was the key |
# |
Oct 18th 2019, 16:18 |
daniel.upshaw |
You might have to `use` the trait in the `Table` class |
# |
Oct 18th 2019, 16:17 |
noel |
I'm trying to get friendsofcake/Search and friendsofcake/crud-json-api to work together. What isn't clear is how to make a search request? Is this documented somewhere? I'm assuming it would be GET request using a query string but I'm getting an error `Missing Search.Search behavior on App\\Model\\Table\\CocktailsTable` |
# |
Oct 18th 2019, 16:17 |
neothermic |
```This branch is for CakePHP 3.4 and newer``` |
# |
Oct 18th 2019, 16:17 |
steinkel |
https://github.com/jippi/cakephp-newrelic/tree/cake3 |
# |
Oct 18th 2019, 16:16 |
neothermic |
(I'm aware that there's a middelware for this, but that one needs cake 3.6 and PHP 7.1+... and yeah.) |
# |
Oct 18th 2019, 16:16 |
steinkel |
there's also a plugin for that I've used time ago... |
# |
Oct 18th 2019, 16:16 |
steinkel |
middleware after routing middleware would work |
# |
Oct 18th 2019, 16:16 |
steinkel |
because AppController happens now much deeper in the stack, Middleware sound like a good place for non cake stuff happening in the request |
# |
Oct 18th 2019, 16:16 |
neothermic |
I need to construct enough of a path to be able to name the transaction for newrelic |
# |
Oct 18th 2019, 16:15 |
noel |
Hi all |
# |
Oct 18th 2019, 16:14 |
steinkel |
what do you need to inject? |
# |
Oct 18th 2019, 16:14 |
daniel.upshaw |
Niiiice |
# |
Oct 18th 2019, 16:14 |
neothermic |
been using cake since 1.3 :) |
# |
Oct 18th 2019, 16:14 |
daniel.upshaw |
Lol I wish I could say that I've been a Cake dev that long.. PHP since v4, but I've only discovered the magic of Cake within the past year or so |
# |
Oct 18th 2019, 16:13 |
neothermic |
very dirty |
# |
Oct 18th 2019, 16:13 |
neothermic |
in 2.x I went into invokeAction() in Controller.php :) |
# |
Oct 18th 2019, 16:13 |
daniel.upshaw |
If you need the request object, seems like you found a good way to do it |
# |
Oct 18th 2019, 16:12 |
neothermic |
in cake2, I hijacked core code |
# |
Oct 18th 2019, 16:12 |
daniel.upshaw |
Ah |
# |
Oct 18th 2019, 16:12 |
neothermic |
so it can't be too high up |
# |
Oct 18th 2019, 16:12 |
neothermic |
I need the request object to be a thing :slightly_smiling_face: |
# |
Oct 18th 2019, 16:12 |
daniel.upshaw |
Oh, and `bootstrap()` in `Application.php` |
# |
Oct 18th 2019, 16:12 |
daniel.upshaw |
`initialize()` seems a pretty clean way |
# |
Oct 18th 2019, 16:12 |
daniel.upshaw |
Ah there's also `bootstrap.php` |
# |
Oct 18th 2019, 16:12 |
neothermic |
if I find edge cases I'll look into a middleware |
# |
Oct 18th 2019, 16:11 |
neothermic |
I'm hoping that init is high enough for what I'm doing |
# |
Oct 18th 2019, 16:11 |
steinkel |
@neothermic webroot/index is the first one, the I would go to Application, but my first spot would be a Middleware added top of your stack |
# |
Oct 18th 2019, 16:10 |
daniel.upshaw |
That sounds exactly right @neothermic |
# |
Oct 18th 2019, 16:10 |
neothermic |
went with initialize() in AppController in the end :slightly_smiling_face: |
# |
Oct 18th 2019, 16:10 |
daniel.upshaw |
All 3 are params, yes |
# |
Oct 18th 2019, 16:10 |
daniel.upshaw |
@ricksaccous it's routed to a custom class, e.g. `$routes->connect('/:article-type/:id/:slug', [], ['routeClass' => 'CustomRoute'])` |
# |
Oct 18th 2019, 16:01 |
neothermic |
I suppose I could be devilish and alter index.php in the webroot, but that feels dirty even though it's not in /vendor |
# |
Oct 18th 2019, 16:00 |
neothermic |
Hmm, what's the earliest function in the request stack that I can hook into without altering core in cake3? :slightly_smiling_face: |