Skip to content

Commit

Permalink
Mage_Admin - DOC block update (#778)
Browse files Browse the repository at this point in the history
* Mage_Admin - DOC block update

- doc blocks added/fixed
- PSR2 fixes (whitespaces, linebreaks, ...)

* Fixed return types (methods are not used)
  • Loading branch information
sreichel authored May 14, 2020
1 parent 992db4e commit d3f64bf
Show file tree
Hide file tree
Showing 39 changed files with 311 additions and 190 deletions.
2 changes: 1 addition & 1 deletion app/code/core/Mage/Admin/Helper/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function isTypeAllowed($type)
/**
* Get disallowed names for block
*
* @return bool
* @return array
*/
public function getDisallowedBlockNames()
{
Expand Down
6 changes: 3 additions & 3 deletions app/code/core/Mage/Admin/Helper/Rules/Fallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Mage_Admin_Helper_Rules_Fallback extends Mage_Core_Helper_Abstract
{
/**
* Fallback to resource parent node
* @param $resourceId
* @param string $resourceId
*
* @return string
*/
Expand All @@ -50,8 +50,8 @@ protected function _getParentResourceId($resourceId)

/**
* Fallback resource permissions similarly to zend_acl
* @param $resources
* @param $resourceId
* @param array $resources
* @param string $resourceId
* @param string $defaultValue
*
* @return string
Expand Down
14 changes: 9 additions & 5 deletions app/code/core/Mage/Admin/Model/Acl.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/


/**
* Acl model
*
*
* @category Mage
* @package Mage_Admin
* @author Magento Core Team <core@magentocommerce.com>
*
* @property Mage_Admin_Model_Acl_Role_Registry $_roleRegistry
*
* @method Mage_Admin_Model_Resource_Acl _getResource()
* @method Mage_Admin_Model_Resource_Acl getResource()
*/
class Mage_Admin_Model_Acl extends Zend_Acl
{
Expand Down Expand Up @@ -63,7 +67,7 @@ class Mage_Admin_Model_Acl extends Zend_Acl
*
*/
const RULE_PERM_ALLOW = 2;

/**
* Get role registry object or create one
*
Expand All @@ -80,8 +84,8 @@ protected function _getRoleRegistry()
/**
* Add parent to role object
*
* @param Zend_Acl_Role $role
* @param Zend_Acl_Role $parent
* @param Zend_Acl_Role|string $role
* @param Zend_Acl_Role|string $parent
* @return $this
*/
public function addRoleParent($role, $parent)
Expand Down
18 changes: 12 additions & 6 deletions app/code/core/Mage/Admin/Model/Acl/Assert/Ip.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,24 @@ class Mage_Admin_Model_Acl_Assert_Ip implements Zend_Acl_Assert_Interface
/**
* Check whether ip is allowed
*
* @param Zend_Acl $acl
* @param Zend_Acl_Role_Interface $role
* @param Zend_Acl_Resource_Interface $resource
* @param Mage_Admin_Model_Acl $acl
* @param Mage_Admin_Model_Acl_Role $role
* @param Mage_Admin_Model_Acl_Resource $resource
* @param string $privilege
* @return boolean
*/
public function assert(Mage_Admin_Model_Acl $acl, Mage_Admin_Model_Acl_Role $role = null,
Mage_Admin_Model_Acl_Resource $resource = null, $privilege = null)
{
public function assert(
Mage_Admin_Model_Acl $acl,
Mage_Admin_Model_Acl_Role $role = null,
Mage_Admin_Model_Acl_Resource $resource = null,
$privilege = null
) {
return $this->_isCleanIP(Mage::helper('core/http')->getRemoteAddr());
}

/**
* @param string|false $ip
*/
protected function _isCleanIP($ip)
{
// ...
Expand Down
22 changes: 14 additions & 8 deletions app/code/core/Mage/Admin/Model/Acl/Assert/Time.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,34 @@

/**
* Assert time for admin acl
*
*
* @category Mage
* @package Mage_Admin
* @author Magento Core Team <core@magentocommerce.com>
*/
class Mage_Admin_Model_Acl_Assert_Time implements Zend_Acl_Assert_Interface
class Mage_Admin_Model_Acl_Assert_Time implements Zend_Acl_Assert_Interface
{
/**
* Assert time
*
* @param Zend_Acl $acl
* @param Zend_Acl_Role_Interface $role
* @param Zend_Acl_Resource_Interface $resource
* @param Mage_Admin_Model_Acl $acl
* @param Mage_Admin_Model_Acl_Role $role
* @param Mage_Admin_Model_Acl_Resource $resource
* @param string $privilege
* @return boolean
*/
public function assert(Mage_Admin_Model_Acl $acl, Mage_Admin_Model_Acl_Role $role = null,
Mage_Admin_Model_Acl_Resource $resource = null, $privilege = null)
{
public function assert(
Mage_Admin_Model_Acl $acl,
Mage_Admin_Model_Acl_Role $role = null,
Mage_Admin_Model_Acl_Resource $resource = null,
$privilege = null
) {
return $this->_isCleanTime(time());
}

/**
* @param int $time
*/
protected function _isCleanTime($time)
{
// ...
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Admin/Model/Acl/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@

/**
* Acl resource
*
*
* @category Mage
* @package Mage_Admin
* @author Magento Core Team <core@magentocommerce.com>
*/
class Mage_Admin_Model_Acl_Resource extends Zend_Acl_Resource
class Mage_Admin_Model_Acl_Resource extends Zend_Acl_Resource
{

}
4 changes: 2 additions & 2 deletions app/code/core/Mage/Admin/Model/Acl/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@
* @package Mage_Admin
* @author Magento Core Team <core@magentocommerce.com>
*/
class Mage_Admin_Model_Acl_Role extends Mage_Core_Model_Abstract
class Mage_Admin_Model_Acl_Role extends Mage_Core_Model_Abstract
{
/**
* Initialize resource model
*
*
*/
protected function _construct()
{
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Admin/Model/Acl/Role/Generic.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@

/**
* User acl role
*
*
* @category Mage
* @package Mage_Admin
* @author Magento Core Team <core@magentocommerce.com>
*/
class Mage_Admin_Model_Acl_Role_Generic extends Zend_Acl_Role
class Mage_Admin_Model_Acl_Role_Generic extends Zend_Acl_Role
{

}
2 changes: 1 addition & 1 deletion app/code/core/Mage/Admin/Model/Acl/Role/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

/**
* Acl Group model
*
*
* @category Mage
* @package Mage_Admin
* @author Magento Core Team <core@magentocommerce.com>
Expand Down
10 changes: 5 additions & 5 deletions app/code/core/Mage/Admin/Model/Acl/Role/Registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@

/**
* Acl role registry
*
*
* @category Mage
* @package Mage_Admin
* @author Magento Core Team <core@magentocommerce.com>
*/
class Mage_Admin_Model_Acl_Role_Registry extends Zend_Acl_Role_Registry
class Mage_Admin_Model_Acl_Role_Registry extends Zend_Acl_Role_Registry
{
/**
* Add parent to the $role node
*
* @param Zend_Acl_Role_Interface|string $role
* @param array|Zend_Acl_Role_Interface|string $parents
* @return Mage_Auth_Model_Acl_Role_Registry
* @return $this
*/
function addParent($role, $parents)
public function addParent($role, $parents)
{
try {
if ($role instanceof Zend_Acl_Role_Interface) {
Expand All @@ -53,7 +53,7 @@ function addParent($role, $parents)
} catch (Zend_Acl_Role_Registry_Exception $e) {
throw new Zend_Acl_Role_Registry_Exception("Child Role id '$roleId' does not exist");
}

if (!is_array($parents)) {
$parents = array($parents);
}
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Admin/Model/Acl/Role/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@

/**
* User acl role
*
*
* @category Mage
* @package Mage_Admin
* @author Magento Core Team <core@magentocommerce.com>
*/
class Mage_Admin_Model_Acl_Role_User extends Mage_Admin_Model_Acl_Role_Generic
class Mage_Admin_Model_Acl_Role_User extends Mage_Admin_Model_Acl_Role_Generic
{

}
7 changes: 7 additions & 0 deletions app/code/core/Mage/Admin/Model/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@
/**
* Class Mage_Admin_Model_Block
*
* @method Mage_Admin_Model_Resource_Block _getResource()
* @method Mage_Admin_Model_Resource_Block getResource()
* @method Mage_Admin_Model_Resource_Block_Collection getCollection()
*
* @method string getBlockName()
* @method string getIsAllowed()
*
* @category Mage
* @package Mage_Adminhtml
* @author Magento Core Team <core@magentocommerce.com>
Expand Down
15 changes: 9 additions & 6 deletions app/code/core/Mage/Admin/Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __construct()
parent::__construct();
$this->setCacheId('adminhtml_acl_menu_config');

/* @var $adminhtmlConfig Varien_Simplexml_Config */
/* @var Varien_Simplexml_Config $adminhtmlConfig */
$adminhtmlConfig = Mage::app()->loadCache($this->getCacheId());
if ($adminhtmlConfig) {
$this->_adminhtmlConfig = new Varien_Simplexml_Config($adminhtmlConfig);
Expand All @@ -73,8 +73,11 @@ public function __construct()
}

if (Mage::app()->useCache('config')) {
Mage::app()->saveCache($adminhtmlConfig->getXmlString(), $this->getCacheId(),
array(Mage_Core_Model_Config::CACHE_TAG));
Mage::app()->saveCache(
$adminhtmlConfig->getXmlString(),
$this->getCacheId(),
array(Mage_Core_Model_Config::CACHE_TAG)
);
}
}
}
Expand Down Expand Up @@ -103,7 +106,7 @@ public function loadAclResources(Mage_Admin_Model_Acl $acl, $resource = null, $p

if (isset($resource->admin)) {
$children = $resource->admin;
} elseif (isset($resource->children)){
} elseif (isset($resource->children)) {
$children = $resource->children->children();
}

Expand All @@ -126,7 +129,7 @@ public function loadAclResources(Mage_Admin_Model_Acl $acl, $resource = null, $p
* Get acl assert config
*
* @param string $name
* @return Mage_Core_Model_Config_Element|boolean
* @return false|SimpleXMLElement|Varien_Simplexml_Element|Mage_Core_Model_Config_Element
*/
public function getAclAssert($name = '')
{
Expand All @@ -146,7 +149,7 @@ public function getAclAssert($name = '')
* Retrieve privilege set by name
*
* @param string $name
* @return Mage_Core_Model_Config_Element|boolean
* @return false|SimpleXMLElement|Varien_Simplexml_Element
*/
public function getAclPrivilegeSet($name = '')
{
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Admin/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ class Mage_Admin_Model_Observer
*/
public function actionPreDispatchAdmin($observer)
{
/** @var $session Mage_Admin_Model_Session */
/** @var Mage_Admin_Model_Session $session */
$session = Mage::getSingleton('admin/session');

/** @var $request Mage_Core_Controller_Request_Http */
/** @var Mage_Core_Controller_Request_Http $request */
$request = Mage::app()->getRequest();
$user = $session->getUser();

Expand Down
10 changes: 6 additions & 4 deletions app/code/core/Mage/Admin/Model/Redirectpolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@ public function __construct($parameters = array())
* @param string|null $alternativeUrl
* @return null|string
*/
public function getRedirectUrl(Mage_Admin_Model_User $user, Zend_Controller_Request_Http $request = null,
$alternativeUrl = null)
{
public function getRedirectUrl(
Mage_Admin_Model_User $user,
Zend_Controller_Request_Http $request = null,
$alternativeUrl = null
) {
if (empty($request)) {
return;
return null;
}
$countRequiredParams = ($this->_urlModel->useSecretKey()
&& $request->getParam(Mage_Adminhtml_Model_Url::SECRET_KEY_PARAM_NAME)) ? 1 : 0;
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Admin/Model/Resource/Acl.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ public function loadRules(Mage_Admin_Model_Acl $acl, array $rulesArr)
$assert = new $assertClass(unserialize($rule['assert_data']));
}
try {
if ( $rule['permission'] == 'allow' ) {
if ($rule['permission'] == 'allow') {
if ($resource === self::ACL_ALL_RULES) {
$acl->allow($role, null, $privileges, $assert);
}
$acl->allow($role, $resource, $privileges, $assert);
} else if ( $rule['permission'] == 'deny' ) {
} elseif ($rule['permission'] == 'deny') {
$acl->deny($role, $resource, $privileges, $assert);
}
} catch (Exception $e) {
Expand Down
7 changes: 2 additions & 5 deletions app/code/core/Mage/Admin/Model/Resource/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class Mage_Admin_Model_Resource_Block extends Mage_Core_Model_Resource_Db_Abstra

/**
* Define main table
*
*/
protected function _construct()
{
Expand Down Expand Up @@ -91,8 +90,7 @@ protected function _generateCache()
}

/**
* @param Mage_Core_Model_Abstract $object
* @return $this
* @inheritDoc
*/
protected function _afterSave(Mage_Core_Model_Abstract $object)
{
Expand All @@ -101,8 +99,7 @@ protected function _afterSave(Mage_Core_Model_Abstract $object)
}

/**
* @param Mage_Core_Model_Abstract $object
* @return $this
* @inheritDoc
*/
protected function _afterDelete(Mage_Core_Model_Abstract $object)
{
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Admin/Model/Resource/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ protected function _construct()
/**
* Process role before saving
*
* @param Mage_Core_Model_Abstract $object
* @param Mage_Core_Model_Abstract|Mage_Admin_Model_Role $object
* @return $this
*/
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
if ( !$object->getId() ) {
if (!$object->getId()) {
$object->setCreated($this->formatDate(true));
}
$object->setModified($this->formatDate(true));
Expand Down
Loading

0 comments on commit d3f64bf

Please sign in to comment.