urAdminThemePlugin
1.0.0beta
for sf 1.4sf 1.3 and Doctrine
MIT
urAdminThemePlugin allows some new options for admin generation.
1) Layout
2) Row Level Credentials
3) Context Level Credentials
It is more of a frontend generator and not an admin generator. We use Dojo for layout purpose.
use
symfony doctrine:generate-admin --theme=urAdmin app_name module_name
to use this theme.
Developers
| Name |
Status |
Email |
Chugh Robin |
lead |
moc.liamg <<ta>> hguhc.nibor
|
License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Please read Sample.yml to understand how generator.yml file for a module can be modified to be able to use this plugin.
Feature Provided:
1) Layout
A layout node typically looks like this
heading_name
class: layout_class
children:
layout_class can be any of 'Accordian' or 'Tabs' or 'Fields'. (Next releases will have more types.)
children must be an array of field_names for layout_class=Fields. For other layout classes it must be another layout node.
heading_name is used as the heading for Accordians or Tabs.
2) Credential:
$helper->hasCredential($object, $user, $credentials) returns true/false based on current object, user and credentials array.
* If $object is not an object
* If $object is null; returns true
* else returns $object.
* else
* returns $helper->is{capitalized(RowLevelCredentialName)}($object, $user)
3) There are 2 different type of credentials provided here.
A) Row Level Credentials
* Starts with _. for ex: _owner
* helper class has to define a function which returns true/false depending on the user crednetials.
The prototype of the function looks like this for credential= _owner. (Note the name is isOwner)
function isOwner($object, $user){
return $object->user_id === $user->getGuardUser()->id;
}
$object is the object of this modle type.
$user is current sf_user.
* If show action has rowLevelCredentials, then it is mandatory to define a function in helper that looks like following
(Note the name is getCredentialQueryOwner for _owner)
function getCredentialQueryOwner($user){
return array('%%alias%%.user_id=?', $user->getGuardUser()->id);
}
$user is current sf_user
notice the return value. its array(queryText, bindParmeters).
%%alias%% will be replaced by query root table alias automatically.
* If a field has rowLevelCredentials, it will not be shows in filter form.
* Defult context credentials defined are-
: show - show
: edit - edit, form
: new - new, form
: index - list
: filter - filter
Can be overridden by passing it in the generator.yml file as context_credentials. Check in sample.yml.
B) Context Level Credentials
* Starts with ~. For ex: ~edit
* Can be set by calling $helper->setContextCredentials(array('form', 'new'));
* A context level credentials holds true If setContextCredentials has been called and passed as parameter the name of context credentials.
3) If display.fields is set, only these fields will be shown. If it is not set, all the fields for the model and the relationships will be shown on list page.
4) Field credentials have been divided into three parts
A) showIf: [credentials_array]
* If credentials are held by current user for current object in current context, the field is shown. Else it is hidden.
b) setIf:
* If credentials are held by current user for current object in current context, the field is set. Else it is unset. Mainly useful for forms.
If a field is supposed to be unset, it is not set in the form and can not be passed from the request.
c) editableIf:
* does not have any difference for non-form contexts. Field becomes read-only of the credential criteria is not fulfilled.