Word of God Naming Conventions
- Zend_Db_Table: Acceptable. Maps to "Zend/Db/Table.php".
- Zend_Pdf: Acceptable.
- Zend_pdf: Unacceptable. Each word needs to start with a majuscule letter followed by all minuscule letters.
- Zend_PDF: Unacceptable. Each word needs to start with a majuscule letter followed by all minuscule letters.
- Zend_Db_Table2: Tolerated but discouraged. Classes are strongly encouraged to avoid numbers.
- Zend_Not_From_Zend_Library: Unacceptable. Only classes the Zend framework nor related libraries should start with "Zend"
- Zend_Controller_PluginAbstract: Acceptable.
- Zend_Controller_Plugin_PluginAbstract: Acceptable.
- Zend_Controller_Plugin_Abstract: Unacceptable. There cannot be an underscore before the suffix "Abstract" due to namespace usage.
- Zend_Controller_PluginInterface: Acceptable.
- Zend_Controller_Plugin_PluginInterface: Acceptable.
- Zend_Controller_Plugin_Interface: Unacceptable. There cannot be an underscore before the suffix "Interface" due to namespace usage.
- MyFile.php: Acceptable.
- MyFile-v2-3-4: Acceptable.
- My-file.php: Acceptable.
- My_file.php: Acceptable.
- MyFile.xyz: Conditionally Acceptable. Files containing PHP code require an extension of php
- My File.php: Unacceptable. Spaces are not permitted.
- filterInput(): Acceptable. Descriptive verbosity is encouraged.
- WidgetFactory(): Unacceptable. Functions and methods must start with a minuscule letter.
- widgetfactory(): Unacceptable. Functions and methods should be camelcase.
- widget_Factory(): Unacceptable. Underscores are not allowed.
- widgetFactory2(): Tolerated but discouraged. Functions and methods are strongly encouraged to avoid numbers.
- getElementById(): Acceptable.
- fetchElementById(): Unacceptable. Accessors for instance or static variables should start with get or set.
- _privateMethod(): Acceptable.
- _protectedMethod(): Acceptable.
- _publicMethod(): Unacceptable. Only private and protected methods should start with an underscore.
- _filterInput(): Unacceptable. Only private and protected methods should start with an underscore.
- $userId: Acceptable.
- $user_id: Unacceptable. Must be alphanumeric.
- $Userid: Unacceptable. Must start with minuscule letter and be camelcase.
- $i: Conditinally acceptable. Indescriptive so should be used for only the smallest loops.
Only acceptable as class members with the const modifier -- not globally with the define.
- EMBED_SUPPRESS_EMBED_EXCEPTION: Acceptable.
- Embed_Suppress_Embed_Exception: Unacceptable. Must be all caps with words separated by underscores.
- EMBED-SUPPRESS-EMBED-EXCEPTION: Unacceptable. May only be alphanumeric with underscores.
- EMBED_SUPPRESSEMBEDEXCEPTION: Unacceptable. Words must be separated by underscores.
Zend's ACL is managed through creation of roles which request access to resources.
Roles are objects which request access.
Zend_Acl::addRole
- Role (string)
- Role to inherit from (string)
TBD
Resources which are objects to which the permission set will be applied, e.g. a specific page.
TBD
Zend_Acl::allow and Zend_Acl::deny Assigning any of these a null value makes it apply to all types in that parameter.
Zend_Acl_Role_Interface
|string|array $rolesZend_Acl_Resource_Interface
|string|array $resources- string|array $privileges
Zend_Acl_Assert_Interface
$assert
Conditional permissions are handled by assertions -- classes implementing the assert() method.
class CleanIPAssertion implements Zend_Acl_Assert_Interface {
public function assert( Zend_Acl $acl, Zend_Acl_Role_Interface $role = null, $resource = null, $privilege = null) {
return $this->_isCleanIP($_SERVER['REMOTE_ADDR']);
}
protected function _isCleanIP($ip) {
// …
}
}
The assertion may then be called by a defined rule. Permission will only be granted if the assertion returns true.
$acl = new Zend_Acl();
$acl->allow(null, null, null, new CleanIPAssertion());
For more in-depth explanation with the nuances, see the Zend ACL Advanced Usage page.