-
Notifications
You must be signed in to change notification settings - Fork 43
New configuration keys #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…omponent and changed the behaviour of undefined pivot tables
|
Nice starting point. I personally do not like making non-CakePHP defaults the "defaults" for this plugin. For example; the original |
|
I agree with you in general on the user_roles (use that myself), but the former was and is convention. So I am with @bravo-kernel . |
|
ok, and the build is not passing, so... :) |
src/Auth/TinyAuthorize.php
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It used to be Users, sure this needs to be singular now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure but I recall discussing this with you before (and reverting the exact same thing). Might be totally unrelated though 😜
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was stuck with an habit of naming my pivot tables in a singular_plural form... I was sure to read that in cake doc some years ago, but it appears i'm totally wrong :) I'm reverting this now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
singular_plural is fine in general, just not for HABTM. And this pivot table is HABTM.
People can use their own convention as custom config.
|
Yes, the builds break because you changed config but not the fixtures |
|
|
|
Yes :P |
…d added missing spaces... to correct previous failing PR
docs/README.md
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overridden
|
Thanks for your remarks :) |
src/Auth/TinyAuthorize.php
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no spacing after cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
damn autoformat...
|
... If there is anything else, i'll do one commit to fix the remaining things instead of small multiple ones... |
src/Auth/TinyAuthorize.php
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please look into your changes again and only change whats necessary, those lines are neither correct nor necessary to change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for that, I use an autoformat feature on my IDE to keep my code clean between all of my projects... But as it depends from one project to another, I should have checked the spaces changes before commiting.
|
And more importantly... hang in there buddy, almost there :wink |
|
@bravo-kernel I am OK with the changes. What do you think? @mtancoigne Can you please squash all commits? |
|
I think we should make the doc about loading the plugin more explanatory (and consistent with other plugin readmes). Copy-paste from this example if you like https://gist.github.com/bravo-kernel/7219d5bd8295b265b893. Other than that I just dropped it in my app and no issues there so looks good to me. |
|
@bravo-kernel That can be added after the PR mege. |
|
True, ship it |
README.md
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we please keep the loadAll() part?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a need for that now that bootstrap is no longer there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point ;) Derp
Never mind then.
|
Thanks for including the plugin load Mr. @mtancoigne |
|
Thank you! I will soon tag a new 1.2.0 release. |
|
👏 |
|
I am still a little bit hesitant regarding the new plugin keys 'pivotTablePlugin' and 'rolesTablePlugin'. Those two keys are not necessary then. And Users table can also be pluginized if desired. |
|
For usersTable, there seems to be no need, as i did not see any probe to it in the code. The only place where it's used is on lines 368/383 (sorry, I don't know how to reference those in this comment), to create the pivot table name... So if a pivotTablePlugin is specified it will precede the But I may be wrong. |
|
Why |
|
Just to be sure, creating a usersTablePlugin, even if it's unused, may be useless as there is no naming convention for that kind of thing. A line in the doc to explain that users should NOT include the plugin name in the usersTableName may be enough... If cake had some standards about naming configuration options in those particular cases, it would be obvious to add it, but it's not the case... I want the advice of @bravo-kernel to push me in :) (Or someone else too) |
|
Re-reading the comments and looking at the code I believe must side with @dereuromark here if I understand correctly that the starting point of the logic is that there always can/should be:
If this is indeed the case then the new Where I am lost is how |
|
As far as I understand the code, there is, for now three config key/values, used in different setups (all for multi-group support):
Then, as the userTable, rolesTable and pivotTable may have been defined in a custom plugin, we need a In the code, we have this : // line 365
// multi-role: reverse engineer name of the pivot table IF NOT DEFINED.
$rolesTableName = $this->_config['rolesTable'];
$pivotTableName = $this->_config['pivotTable'];
$usersTableName = $this->_config['usersTable'];
if (!$pivotTableName) {
$tables = [
$usersTableName,
$rolesTableName
];
asort($tables);
$pivotTableName = implode('', $tables);
}
// fetch roles directly from the pivot table
$pivotTablePlugin = $this->_config['pivotTablePlugin'];
if (!$pivotTablePlugin) {
$pivotTableName = $pivotTablePlugin . '.' . $pivotTableName;
}
$pivotTable = TableRegistry::get($pivotTableName);So : If the pivot table is not defined it is created from users and role tables. Then the pivotTablePlugin is added, if defined. (note: It should be clear to users in docs, a point on this may be good)
But |
|
Hmmm, I guess I was a bit too quick with the last point there Mr @mtancoigne . Seems we are not talking about the table but about figuring out which Table class to load in this line and this line correct? In that light I totally agree with what @dereuromark suggested in #18 (comment) so all we seem to need is just a way to filter/parse the value of the three "old" keys userTable, rolesTable and pivotTable to support CakePHP dotted plugin notation. Jump on to irc if you like to discuss more efficiently. Good to see you getting involved 👍 |
|
ps: check http://book.cakephp.org/3.0/en/appendices/glossary.html and find plugin syntax |
|
Yes, plugin syntax should be accepted, so people using it won't trip over it, making the additional config keys unncessary :) |
Added some config keys to allow a simpler configuration through loadComponent and
CLASS_USERconstant : custom plugin is handled with thepivotTablePluginoption.I can't run the tests as i'm not at home, but as far as I tried, it works.