Permalink
Browse files

Cleanup & Coding Standard

  • Loading branch information...
1 parent 0216479 commit f4660e1e6d1ba0d162478b0c157197dba96f1492 @Vrtak-CZ Vrtak-CZ committed Feb 22, 2014
Showing with 952 additions and 1,433 deletions.
  1. +24 −31 app/Api/presenters/ComposerPresenter.php
  2. +32 −36 app/Api/presenters/GithubPresenter.php
  3. +3 −7 app/Manage/forms/AddAddonFormFactory.php
  4. +18 −29 app/Manage/forms/AddVersionForm.php
  5. +24 −28 app/Manage/forms/AddonForm.php
  6. +13 −21 app/Manage/forms/AddonFormFactory.php
  7. +17 −23 app/Manage/forms/EditAddonFormFactory.php
  8. +20 −31 app/Manage/forms/ImportAddonFormFactory.php
  9. +0 −1 app/Manage/forms/ReportFormFactory.php
  10. +20 −28 app/Manage/forms/VersionFormFactory.php
  11. +28 −48 app/Manage/presenters/AddonPresenter.php
  12. +28 −38 app/Manage/presenters/AdminPresenter.php
  13. +3 −11 app/Manage/presenters/BasePresenter.php
  14. +22 −28 app/Manage/presenters/VersionsPresenter.php
  15. +0 −1 app/bootstrap.php
  16. +5 −15 app/components/CategoriesControl.php
  17. +5 −17 app/components/SubMenuControl.php
  18. +2 −11 app/forms/BaseForm.php
  19. +7 −14 app/forms/EditPageFormFactory.php
  20. +3 −18 app/forms/FilterForm.php
  21. +5 −11 app/forms/Form.php
  22. +7 −15 app/forms/ReportFormFactory.php
  23. +0 −3 app/forms/SignInForm.php
  24. +13 −30 app/misc/HttpStreamRequest.php
  25. +1 −8 app/misc/HttpStreamRequestFactory.php
  26. +4 −3 app/misc/Portal.php
  27. +16 −27 app/model/Authenticator.php
  28. +4 −15 app/model/Authorizator.php
  29. +4 −8 app/model/DevelopmentUtils.php
  30. +7 −23 app/model/Entities/Addon.php
  31. +4 −22 app/model/Entities/AddonVersion.php
  32. +3 −12 app/model/Entities/Tag.php
  33. +61 −64 app/model/Facade/AddonManageFacade.php
  34. +3 −13 app/model/IAddonImporter.php
  35. +18 −31 app/model/Importers/GitHub/Repository.php
  36. +7 −7 app/model/Importers/GitHub/RepositoryFactory.php
  37. +22 −45 app/model/Importers/GitHubImporter.php
  38. +0 −11 app/model/Importers/GitHubImporterFactory.php
  39. +14 −20 app/model/Importers/RepositoryImporterManager.php
  40. +0 −7 app/model/PackageRouteHelper.php
  41. +5 −17 app/model/PackageRouteHelperCached.php
  42. +14 −16 app/model/RouterFactory.php
  43. +10 −20 app/model/Table.php
  44. +7 −12 app/model/Tables/AddonDownloads.php
  45. +5 −12 app/model/Tables/AddonReports.php
  46. +37 −40 app/model/Tables/AddonVersions.php
  47. +4 −14 app/model/Tables/AddonVotes.php
  48. +47 −90 app/model/Tables/Addons.php
  49. +10 −16 app/model/Tables/Pages.php
  50. +11 −28 app/model/Tables/Tags.php
  51. +10 −20 app/model/Tables/Users.php
  52. +4 −12 app/model/Tables/VersionDependencies.php
  53. +7 −14 app/model/Utils/Composer.php
  54. +22 −13 app/model/Utils/FormValidators.php
  55. +4 −9 app/model/Utils/Licenses.php
  56. +7 −17 app/model/Utils/Validators.php
  57. +15 −23 app/model/Utils/VersionParser.php
  58. +15 −10 app/model/VendorRouteHelper.php
  59. +4 −11 app/presenters/BaseListPresenter.php
  60. +42 −41 app/presenters/BasePresenter.php
  61. +39 −52 app/presenters/DetailPresenter.php
  62. +15 −9 app/presenters/ErrorPresenter.php
  63. +9 −10 app/presenters/HomepagePresenter.php
  64. +0 −9 app/presenters/ListPresenter.php
  65. +22 −17 app/presenters/PagePresenter.php
  66. +33 −24 app/presenters/SignPresenter.php
  67. +10 −9 app/presenters/SpecialPresenter.php
  68. +2 −7 app/view/HelperLoader.php
  69. +2 −1 app/view/ITextProcessor.php
  70. +7 −18 app/view/TextPreprocessor.php
  71. +8 −2 app/view/TextProcessors/MarkdownProcessor.php
  72. +2 −1 app/view/TextProcessors/Texy/AddonsConverter.php
  73. +42 −26 app/view/TextProcessors/Texy/Convertor.php
  74. +6 −1 app/view/TextProcessors/Texy/Link.php
  75. +8 −1 app/view/TextProcessors/TexyProcessor.php
@@ -2,42 +2,35 @@
namespace NetteAddons\Api;
-use NetteAddons\Model\Addon,
- NetteAddons\Model\AddonVersion,
- NetteAddons\Model\Addons,
- NetteAddons\Model\AddonDownloads,
- NetteAddons\Model\AddonVersions,
- NetteAddons\Model\Utils\Composer;
+use NetteAddons\Model\Addon;
+use NetteAddons\Model\Addons;
+use NetteAddons\Model\AddonVersion;
+use NetteAddons\Model\AddonVersions;
+use NetteAddons\Model\AddonDownloads;
+use NetteAddons\Model\Utils\Composer;
-
-/**
- * @author Jan Marek
- * @author Jan Tvrdík
- * @author Jan Dolecek <juzna.cz@gmail.com>
- * @author Patrik Votoček
- */
final class ComposerPresenter extends \NetteAddons\BasePresenter
{
- /**
- * @var \NetteAddons\Model\Addons
- * @inject
- */
+ /** @var \NetteAddons\Model\Addons */
public $addons;
- /**
- * @var \NetteAddons\Model\AddonDownloads
- * @inject
- */
+ /** @var \NetteAddons\Model\AddonDownloads */
public $addonDownloads;
- /**
- * @var \NetteAddons\Model\AddonVersions
- * @inject
- */
+ /** @var \NetteAddons\Model\AddonVersions */
public $addonVersions;
+ public function __construct(Addons $addons, AddonDownloads $addonDownloads, AddonVersions $addonVersions)
+ {
+ parent::__construct();
+
+ $this->addons = $addons;
+ $this->addonDownloads = $addonDownloads;
+ $this->addonVersions = $addonVersions;
+ }
+
@JanTvrdik

JanTvrdik Feb 22, 2014

Collaborator

Co máš proti @inject anotacím? =)

@Vrtak-CZ

Vrtak-CZ Feb 22, 2014

Collaborator

patří imho pouze do abstraktních presenterů

@Majkl578

Majkl578 Feb 22, 2014

Collaborator

To je imho dost nesmyslné omezení.

public function renderPackages()
{
@@ -46,29 +39,29 @@ public function renderPackages()
$packagesJson = Composer::createPackagesJson($addons);
$packagesJson->notify = str_replace(
- 'placeholder', '%package%',
+ 'placeholder',
+ '%package%',
$this->link('//downloadNotify', array('package' => 'placeholder'))
);
$this->sendJson($packagesJson);
}
-
/**
* Called when composer installs a package to increase counters.
*
* @link http://getcomposer.org/doc/05-repositories.md#notify
+ *
* @param string
*/
public function actionDownloadNotify($package)
{
- $post = $this->getRequest()->post;
+ $post = $this->getRequest()->getPost();
if (!isset($post['version'])) {
$this->error('Invalid request.');
}
$version = (string) $post['version'];
-
if (!$addonRow = $this->addons->findOneByComposerFullName($package)) {
$this->error('Package not found.');
}
@@ -81,7 +74,7 @@ public function actionDownloadNotify($package)
));
if (!$versionRow) {
- $this->error("Version of package not found.");
+ $this->error('Version of package not found.');
}
$version = AddonVersion::fromActiveRow($versionRow);
@@ -93,6 +86,6 @@ public function actionDownloadNotify($package)
$this->getHttpRequest()->getHeader('user-agent')
);
- $this->sendJson(array('status' => "success"));
+ $this->sendJson(array('status' => 'success'));
}
}
@@ -2,56 +2,52 @@
namespace NetteAddons\Api;
-use Nette\Utils\Json,
- NetteAddons\Model\Addon,
- NetteAddons\Model\Addons,
- NetteAddons\Model\Users,
- NetteAddons\Model\Facade\AddonManageFacade,
- NetteAddons\Model\Importers\GitHubImporter,
- NetteAddons\Model\Importers\RepositoryImporterManager;
-
-
-
-/**
- * GitHub API
- *
- * @author Jan Dolecek <juzna.cz@gmail.com>
- * @author Patrik Votoček
- */
+use Nette\Utils\Json;
+use Nette\Http\IResponse;
+use NetteAddons\Model\Addon;
+use NetteAddons\Model\Addons;
+use NetteAddons\Model\Users;
+use NetteAddons\Model\Facade\AddonManageFacade;
+use NetteAddons\Model\Importers\GitHubImporter;
+use NetteAddons\Model\Importers\RepositoryImporterManager;
+
+
final class GithubPresenter extends \NetteAddons\BasePresenter
{
- /**
- * @var \NetteAddons\Model\Facade\AddonManageFacade
- * @inject
- */
+ /** @var \NetteAddons\Model\Facade\AddonManageFacade */
public $manager;
- /**
- * @var \NetteAddons\Model\Importers\RepositoryImporterManager
- * @inject
- */
+ /** @var \NetteAddons\Model\Importers\RepositoryImporterManager */
public $importerManager;
- /**
- * @var \NetteAddons\Model\Users
- * @inject
- */
+ /** @var \NetteAddons\Model\Users */
public $users;
- /**
- * @var \NetteAddons\Model\Addons
- * @inject
- */
+ /** @var \NetteAddons\Model\Addons */
public $addons;
+ public function __construct(
+ AddonManageFacade $manager,
+ RepositoryImporterManager $importerManager,
+ Users $users,
+ Addons $addons
+ ) {
@hrach

hrach Feb 22, 2014

Contributor

a přesně proto mám rád injekt anotace, abych se vyhnul temto problemum. toto proste z principu nema pekny coding-style reseni a tot oje to horsi...

@Vrtak-CZ

Vrtak-CZ Feb 22, 2014

Collaborator

Pro mně to je znamení toho že je potřeba refactoring aby se snížil počet závyslostí :-)

@hrach

hrach Feb 22, 2014

Contributor

naprosto souhlasim, osobne mam zkusenost, ze si to uvedomuji i z @injectu.

+ parent::__construct();
+
+ $this->manager = $manager;
+ $this->importerManager = $importerManager;
+ $this->users = $users;
+ $this->addons = $addons;
+ }
+
/**
* Post receive hook, updates addon info
*/
public function actionPostReceive()
{
- $post = $this->getRequest()->post;
+ $post = $this->getRequest()->getPost();
if (!isset($post['payload'], $post['username'], $post['apiToken'])) {
$this->error('Invalid request.');
}
@@ -61,7 +57,7 @@ public function actionPostReceive()
try {
$payload = Json::decode($post['payload']);
if (!isset($payload->repository->url)) {
- $response->setCode(400); // Bad Request
+ $response->setCode(IResponse::S400_BAD_REQUEST);
$this->sendJson(array(
'status' => 'error',
'message' => 'Missing or invalid payload',
@@ -76,15 +72,15 @@ public function actionPostReceive()
$user = $this->users->findOneByName($username);
if (!$user || $user->apiToken !== $token) {
- $response->setCode(403); // Forbidden
+ $response->setCode(IResponse::S403_FORBIDDEN);
$this->sendJson(array(
'status' => 'error',
'message' => 'Invalid credentials'
));
}
if (!GitHubImporter::isValid($payload->repository->url)) {
- $response->setCode(400); // Bad Request
+ $response->setCode(IResponse::S400_BAD_REQUEST);
$this->sendJson(array(
'status' => 'error',
'message' => 'Could not parse payload repository URL'
@@ -2,21 +2,18 @@
namespace NetteAddons\Manage\Forms;
-use Nette\Utils\Strings,
- Nette\Security\IIdentity;
+use Nette\Utils\Strings;
+use Nette\Security\IIdentity;
/**
* Form for new addon registration. When importing from GitHub, most of the fields should be prefilled.
* The license input won't be visible when composer.json is available.
- *
- * @author Patrik Votoček
*/
class AddAddonFormFactory extends AddonFormFactory
{
-
/**
- * @param IIdentity
+ * @param \Nette\Security\IIdentity
* @param string
* @return AddonForm
*/
@@ -38,5 +35,4 @@ public function create(IIdentity $user, $token)
return $form;
}
-
}
@@ -2,20 +2,15 @@
namespace NetteAddons\Manage\Forms;
-use Nette\Security\IIdentity,
- NetteAddons\Model\Addon,
- NetteAddons\Model\AddonVersions,
- NetteAddons\Model\Utils\VersionParser,
- NetteAddons\Model\Utils\Licenses,
- NetteAddons\Model\Utils\FormValidators,
- NetteAddons\Model\Facade\AddonManageFacade;
-
-
-/**
- * Form for addon version creation.
- *
- * @author Patrik Votoček
- */
+use Nette\Security\IIdentity;
+use NetteAddons\Model\Addon;
+use NetteAddons\Model\AddonVersions;
+use NetteAddons\Model\Utils\VersionParser;
+use NetteAddons\Model\Utils\Licenses;
+use NetteAddons\Model\Utils\FormValidators;
+use NetteAddons\Model\Facade\AddonManageFacade;
+
+
class AddVersionFormFactory extends \Nette\Object
{
/** @var \NetteAddons\Model\Facade\AddonManageFacade */
@@ -37,16 +32,13 @@ class AddVersionFormFactory extends \Nette\Object
protected $addon;
-
- /**
- * @param \NetteAddons\Model\Facade\AddonManageFacade
- * @param \NetteAddons\Model\Utils\VersionParser
- * @param \NetteAddons\Model\Utils\FormValidators
- * @param \NetteAddons\Model\Utils\Licenses
- * @param \NetteAddons\Model\AddonVersions
- */
- public function __construct(AddonManageFacade $manager, VersionParser $versionParser, FormValidators $validators, Licenses $licenses, AddonVersions $model)
- {
+ public function __construct(
+ AddonManageFacade $manager,
+ VersionParser $versionParser,
+ FormValidators $validators,
+ Licenses $licenses,
+ AddonVersions $model
+ ) {
$this->model = $model;
$this->manager = $manager;
$this->versionParser = $versionParser;
@@ -55,10 +47,9 @@ public function __construct(AddonManageFacade $manager, VersionParser $versionPa
}
-
/**
- * @param Addon
- * @param IIdentity
+ * @param \NetteAddons\Model\Addon
+ * @param \Nette\Security\IIdentity
* @param string
* @return VersionForm
*/
@@ -77,7 +68,6 @@ public function create(Addon $addon, IIdentity $user, $token)
try {
$version = $manager->addVersionFromValues($addon, $values, $user, $versionParser);
-
} catch (\NetteAddons\IOException $e) {
$form['archive']->addError('Uploading file failed.');
return;
@@ -89,7 +79,6 @@ public function create(Addon $addon, IIdentity $user, $token)
} catch (\NetteAddons\DuplicateEntryException $e) {
$form['version']->addError(sprintf("Version '%s' already exists.", $version->version));
}
-
} else {
$manager->storeAddon($values->token, $addon);
}
Oops, something went wrong.

0 comments on commit f4660e1

Please sign in to comment.