# |
May 21st 2021, 11:28 |
paolo.bragagni |
I want to make an 'internal' skeleton |
# |
May 21st 2021, 11:27 |
neon1024 |
@paolo.bragagni Are you building a multiple tenant application? |
# |
May 21st 2021, 11:19 |
paolo.bragagni |
I'm only searching best method |
# |
May 21st 2021, 11:18 |
paolo.bragagni |
Ssme template etc |
# |
May 21st 2021, 11:18 |
neon1024 |
I am trying to test when my `delete()` fails, and I’m caught between using an Integration test where I’m not sure how to mock the Table::delete() or a Unit test where I cannot assert the Flash messages. Any tips? |
# |
May 21st 2021, 11:18 |
paolo.bragagni |
I have to build many apps all of them eith same authandauth |
# |
May 21st 2021, 11:12 |
ndm |
:upside_down_face: |
# |
May 21st 2021, 11:11 |
steinkel |
lol, what @ndm said |
# |
May 21st 2021, 11:11 |
steinkel |
@paolo.bragagni if your're aiming to create a plugin to handle these items, remember you can inject middlewares from the plugin and handle all configuration so your main app will be "clea" |
# |
May 21st 2021, 11:11 |
slackebot |
collection directly to do that, like ```$plugins = \Cake\Core\Plugin::getCollection(); $plugins->add($plugins->create('Authentication'));``` To modify controllers you'd probably have to use events, like `Controller.initialize` (which is equivalent to `beforeFilter()`). Whether it makes sense to move this all into a plugin... that would be a different question :) |
# |
May 21st 2021, 11:11 |
ndm |
That can be summed up as adding middleware, which is also possible from within your plugin's `Plugin` class, it has a `middleware()` method too. However depending on the specific middleware, you might need to add it using `insertAfter()`/`insertBefore()` as otherwise they will be appended after all application level middlewares. Plugins can also add other plugins in their bootstrap, but they need to obtain and use the plugin |
# |
May 21st 2021, 11:02 |
paolo.bragagni |
etc etc |
# |
May 21st 2021, 11:02 |
paolo.bragagni |
some changes in middleware |
# |
May 21st 2021, 11:01 |
paolo.bragagni |
then $this->addPlugin('Authentication'); |
# |
May 21st 2021, 11:01 |
paolo.bragagni |
etc etc |
# |
May 21st 2021, 11:01 |
paolo.bragagni |
in class Application I've implemented AuthenticationServiceProviderInterface, AuthorizationServiceProviderInterface |
# |
May 21st 2021, 11:00 |
paolo.bragagni |
(for authentication) |
# |
May 21st 2021, 11:00 |
paolo.bragagni |
in application I add //Authentication use Authentication\AuthenticationService; use Authentication\AuthenticationServiceInterface; use Authentication\AuthenticationServiceProviderInterface; use Authentication\Identifier\IdentifierInterface; use Authentication\Middleware\AuthenticationMiddleware; |
# |
May 21st 2021, 10:59 |
paolo.bragagni |
I simply follow the guide for Authorization and Authentication |
# |
May 21st 2021, 10:58 |
ndm |
Depends on what exactly you change in `Application` and `AppController` I guess. |
# |
May 21st 2021, 10:47 |
paolo.bragagni |
(sorry for my english) |
# |
May 21st 2021, 10:47 |
paolo.bragagni |
but how to keep 'src' as clean as possible and put all 'my' changes in my plugin? |
# |
May 21st 2021, 10:46 |
paolo.bragagni |
right now I build my authenticator componentI put it in src/authenticator etc.. then I follow the guide and change something in Application.php and AppController.php |
# |
May 21st 2021, 10:44 |
paolo.bragagni |
that have the skeleton of my app with authentication and authorization etc |
# |
May 21st 2021, 10:43 |
paolo.bragagni |
the idea is to bake the new application, install 'my' plugin |
# |
May 21st 2021, 10:42 |
paolo.bragagni |
I'fd like to use m plugin as 'base' for authentication and authorization to keep the APP as clean as possible |
# |
May 21st 2021, 09:59 |
ndm |
The former would also avoid problems with your modifier, as only the ORM query builder will nest complex count queries. |
# |
May 21st 2021, 09:58 |
ndm |
If you don't need to use any ORM features for your count query, then your best bet might be to use the lower level database query builder instead of the ORM one. Another workaround could be to dynamically load the table with a different alias, and unload the behavior on that alias. |
# |
May 21st 2021, 09:47 |
ndm |
There probably is no overly straightforward way, as it applies for all queries of table, and joins and formatters for translations are being added in the `Model.beforeFind` event. |
# |
May 21st 2021, 09:44 |
thomas465 |
oh, neat, what about a clean way of disabling translations where they are not needed ? |
# |
May 21st 2021, 09:43 |
ndm |
@thomas465 You can use the query builder's `counter()` method to define a custom count query. https://book.cakephp.org/4/en/orm/query-builder.html#returning-the-total-count-of-records |
# |
May 21st 2021, 09:40 |
paolo.bragagni |
it works!! great! |
# |
May 21st 2021, 09:40 |
ndm |
I don't think so, IIRC that's only required on application level. |
# |
May 21st 2021, 09:38 |
paolo.bragagni |
no 'authorization' path somewhere in my plugin template? |
# |
May 21st 2021, 09:38 |
thomas465 |
sorry, fails with ` Syntax error or access violation: 1234 Incorrect usage/placement of ‘SQL_NO_CACHE’` |
# |
May 21st 2021, 09:38 |
slackebot |
(SELECT sql_no_cache `Products`.`id` AS `Produ``` |
# |
May 21st 2021, 09:38 |
thomas465 |
Regarding pagination, i have a rather large query that i need paginated, the problem is that the count method in the Paginator uses the complete query, including translation tables. It always fails when giving the query a modifier like ```$query = $query->where(['Products.is_active' => true])->select([ 'id', 'name', 'children_count'], false)->modifier('sql_no_cache');``` fails with ```SELECT (COUNT(*)) AS `count` FROM |
# |
May 21st 2021, 09:34 |
ndm |
See also https://book.cakephp.org/bake/2/en/development.html#creating-a-bake-theme |
# |
May 21st 2021, 09:33 |
ndm |
Given the paths in the authorization plugin, the path inside your theme plugin should be `templates/bake/policy.twig` and `templates/bake/element/entity_methods.twig`. |
# |
May 21st 2021, 09:31 |
paolo.bragagni |
(and I'd like to insert the modified twig policy template in a plugin) |
# |
May 21st 2021, 09:30 |
paolo.bragagni |
I'd like to insert something in before method and add all my standard actions |