Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #6255 from edenduong/code_standard_demarcation_upd…
Browse files Browse the repository at this point in the history
…ate_magento2

Update Code - DocBlock Standard
  • Loading branch information
dobooth authored Feb 13, 2020
2 parents 6116b91 + 72c7a50 commit fd99639
Showing 1 changed file with 56 additions and 27 deletions.
83 changes: 56 additions & 27 deletions src/guides/v2.3/coding-standards/docblock-standard-general.md
Original file line number Diff line number Diff line change
Expand Up @@ -441,36 +441,65 @@ For example:
**Throwing Exception Implicitly:**

```php
/**
* Recursively delete directory from storage
*
* @param string $path Target dir
* @return void
* @throws Mage_Core_Exception when directories cannot be deleted
*/
public function deleteDirectory($path)
{
// prevent accidental root directory deleting
$rootCmp = rtrim($this->getHelper()->getStorageRoot(), DS);
$pathCmp = rtrim($path, DS);

if ($rootCmp == $pathCmp) {
Mage::throwException(Mage::helper('Mage_Cms_Helper_Data')->__('Cannot delete root directory %s.', $path));
}

$io = new Varien_Io_File();
/**
* Perform login process
*
* @param string $username
* @param string $password
* @return void
* @throws \Magento\Framework\Exception\AuthenticationException
*/
public function login($username, $password)
{
if (empty($username) || empty($password)) {
self::throwException(
__(
'The account sign-in was incorrect or your account is disabled temporarily. '
. 'Please wait and try again later.'
)
);
}

if (Mage::helper('Mage_Core_Helper_File_Storage_Database')->checkDbUsage()) {
Mage::getModel('Mage_Core_Model_File_Storage_Directory_Database')->deleteDirectory($path);
}
if (!$io->rmdir($path, true)) {
Mage::throwException(Mage::helper('Mage_Cms_Helper_Data')->__('Cannot delete directory %s.', $path));
}
try {
$this->_initCredentialStorage();
$this->getCredentialStorage()->login($username, $password);
if ($this->getCredentialStorage()->getId()) {
$this->getAuthStorage()->setUser($this->getCredentialStorage());
$this->getAuthStorage()->processLogin();

$this->_eventManager->dispatch(
'backend_auth_user_login_success',
['user' => $this->getCredentialStorage()]
);
}

if (strpos($pathCmp, $rootCmp) === 0) {
$io->rmdir($this->getThumbnailRoot() . DS . ltrim(substr($pathCmp, strlen($rootCmp)), '\\/'), true);
if (!$this->getAuthStorage()->getUser()) {
self::throwException(
__(
'The account sign-in was incorrect or your account is disabled temporarily. '
. 'Please wait and try again later.'
)
);
}
} catch (PluginAuthenticationException $e) {
$this->_eventManager->dispatch(
'backend_auth_user_login_failed',
['user_name' => $username, 'exception' => $e]
);
throw $e;
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->_eventManager->dispatch(
'backend_auth_user_login_failed',
['user_name' => $username, 'exception' => $e]
);
self::throwException(
__(
$e->getMessage()? : 'The account sign-in was incorrect or your account is disabled temporarily. '
. 'Please wait and try again later.'
)
);
}
}
}
```

#### @return tag {#return}
Expand Down

0 comments on commit fd99639

Please sign in to comment.