diff --git a/config/application.config.php b/config/application.config.php index d7347b92..b16a84e3 100644 --- a/config/application.config.php +++ b/config/application.config.php @@ -27,7 +27,7 @@ 'ScnSocialAuth', 'EdpGithub', 'Application', - 'User', + 'User', 'EdpModuleLayouts', 'ZfModule', 'EdpMarkdown', diff --git a/config/autoload/zfcuser.global.php b/config/autoload/zfcuser.global.php index 5afe1b67..93008c8c 100644 --- a/config/autoload/zfcuser.global.php +++ b/config/autoload/zfcuser.global.php @@ -126,11 +126,11 @@ //'use_redirect_parameter_if_present' => true, /** - * Sets the view template for the user login widget - * - * Default value: 'zfc-user/user/login.phtml' + * Sets the view template for the user login widget + * + * Default value: 'zfc-user/user/login.phtml' * Accepted values: string path to a view script - */ + */ //'user_login_widget_view_template' => 'zfc-user/user/login.phtml', /** diff --git a/config/constants.php b/config/constants.php index eb3e8dd7..3550de32 100644 --- a/config/constants.php +++ b/config/constants.php @@ -1,2 +1,2 @@ createEntry(); $entry->setTitle($module->getName()); - if($module->getDescription() == '') { + if ($module->getDescription() == '') { $moduleDescription = "No Description available"; } else { $moduleDescription = $module->getDescription(); @@ -75,5 +75,4 @@ public function feedAction() return $feedmodel; } - } diff --git a/module/User/Module.php b/module/User/Module.php index 84f7e559..bd6b092c 100644 --- a/module/User/Module.php +++ b/module/User/Module.php @@ -13,7 +13,7 @@ public function bootstrap(ModuleManager $moduleManager, ApplicationInterface $ap $em = $app->getEventManager()->getSharedManager(); $sm = $app->getServiceManager(); - $em->attach('ScnSocialAuth\Authentication\Adapter\HybridAuth','githubToLocalUser', function ($e) { + $em->attach('ScnSocialAuth\Authentication\Adapter\HybridAuth', 'githubToLocalUser', function ($e) { $localUser = $e->getTarget(); $userProfile = $e->getParam('userProfile'); $nickname = substr( @@ -28,12 +28,12 @@ public function bootstrap(ModuleManager $moduleManager, ApplicationInterface $ap $hybridAuth = $sm->get('HybridAuth'); $adapter = $hybridAuth->getAdapter('github'); - if($adapter->isUserConnected()) { + if ($adapter->isUserConnected()) { $token = $adapter->getAccessToken(); $client = $e->getTarget(); $client->authenticate('url_token', $token['access_token']); } - } ); + }); } public function getServiceConfig() diff --git a/module/User/src/User/Mapper/User.php b/module/User/src/User/Mapper/User.php index 6d6766ec..39c6c49b 100644 --- a/module/User/src/User/Mapper/User.php +++ b/module/User/src/User/Mapper/User.php @@ -6,17 +6,17 @@ class User extends ZfcUserMapper { - public function findAll($limit= null, $orderBy = null, $sort = 'ASC') + public function findAll($limit = null, $orderBy = null, $sort = 'ASC') { $sql = $this->getSql(); $select = $sql->select() ->from($this->tableName); - if($orderBy) { + if ($orderBy) { $select->order($orderBy . ' ' . $sort); } - if($limit) { + if ($limit) { $select->limit($limit); } diff --git a/module/User/src/User/View/Helper/NewUsers.php b/module/User/src/User/View/Helper/NewUsers.php index 2f2546af..d33cbe1f 100644 --- a/module/User/src/User/View/Helper/NewUsers.php +++ b/module/User/src/User/View/Helper/NewUsers.php @@ -68,5 +68,4 @@ public function setServiceLocator(ServiceLocatorInterface $serviceLocator) $this->serviceLocator = $serviceLocator; return $this; } - } diff --git a/module/User/src/User/View/Helper/UserRepositories.php b/module/User/src/User/View/Helper/UserRepositories.php index 957233a2..0c0910aa 100644 --- a/module/User/src/User/View/Helper/UserRepositories.php +++ b/module/User/src/User/View/Helper/UserRepositories.php @@ -46,24 +46,24 @@ public function __invoke($options = array()) $repositories = array(); $ownerRepos = $client->api('current_user')->repos(array('type' =>'owner')); - foreach($ownerRepos as $repo) { - if(!$repo->fork) { + foreach ($ownerRepos as $repo) { + if (!$repo->fork) { $repositories[] = $repo; } } $memberRepos = $client->api('current_user')->repos(array('type' =>'member')); - foreach($memberRepos as $repo) { + foreach ($memberRepos as $repo) { $repositories[] = $repo; } $mapper = $sl->get('application_module_mapper'); - foreach($repositories as $key => $repo) { - if($repo->fork) { + foreach ($repositories as $key => $repo) { + if ($repo->fork) { unset($repositories[$key]); } else { $module = $mapper->findByName($repo->name); - if($module) { + if ($module) { unset($repositories[$key]); } else { $em = $client->getHttpClient()->getEventManager(); @@ -71,7 +71,7 @@ public function __invoke($options = array()) $em->detachAggregate($errorListener); $module = $client->api('repos')->content($repo->full_name, 'Module.php'); $response = $client->getHttpClient()->getResponse(); - if(!$response->isSuccess()){ + if (!$response->isSuccess()) { unset($repositories[$key]); } $em->attachAggregate($errorListener); diff --git a/module/ZfModule/Module.php b/module/ZfModule/Module.php index 092d9474..2c453147 100644 --- a/module/ZfModule/Module.php +++ b/module/ZfModule/Module.php @@ -24,7 +24,7 @@ public function getAutoloaderConfig() 'Zend\Loader\StandardAutoloader' => array( 'namespaces' => array( // if we're in a namespace deeper than one level we need to fix the \ in the path - __NAMESPACE__ => __DIR__ . '/src/' . str_replace('\\', '/' , __NAMESPACE__), + __NAMESPACE__ => __DIR__ . '/src/' . str_replace('\\', '/', __NAMESPACE__), ), ), ); diff --git a/module/ZfModule/src/ZfModule/Controller/IndexController.php b/module/ZfModule/src/ZfModule/Controller/IndexController.php index 27a01ba7..daf79b60 100644 --- a/module/ZfModule/src/ZfModule/Controller/IndexController.php +++ b/module/ZfModule/src/ZfModule/Controller/IndexController.php @@ -20,7 +20,7 @@ public function viewAction() //check if module is existing in database otherwise return 404 page $result = $mapper->findByName($module); - if(!$result) { + if (!$result) { $this->getResponse()->setStatusCode(404); return; } @@ -34,7 +34,7 @@ public function viewAction() $repository = json_decode($client->api('repos')->show($vendor, $module)); $httpClient = $client->getHttpClient(); $response= $httpClient->getResponse(); - if($response->getStatusCode() == 304 && $cache->hasItem($cacheKey)) { + if ($response->getStatusCode() == 304 && $cache->hasItem($cacheKey)) { return $cache->getItem($cacheKey); } @@ -42,20 +42,20 @@ public function viewAction() $readme = json_decode($readme); $repository = json_decode($client->api('repos')->show($vendor, $module)); - try{ + try { $license = $client->api('repos')->content($vendor, $module, 'LICENSE'); $license = json_decode($license); $license = base64_decode($license->content); - } catch(\Exception $e) { + } catch (\Exception $e) { $license = 'No license file found for this Module'; } - try{ + try { $composerJson = $client->api('repos')->content($vendor, $module, 'composer.json'); $composerConf = json_decode($composerJson); $composerConf = base64_decode($composerConf->content); $composerConf = json_decode($composerConf, true); - } catch(\Exception $e) { + } catch (\Exception $e) { $composerConf = 'No composer.json file found for this Module'; } @@ -68,7 +68,7 @@ public function viewAction() 'license' => $license, )); - $cache->setItem($cacheKey , $viewModel); + $cache->setItem($cacheKey, $viewModel); return $viewModel; } @@ -178,7 +178,7 @@ public function addAction() } $request = $this->getRequest(); - if($request->isPost()) { + if ($request->isPost()) { $repo = $request->getPost()->get('repo'); $owner = $request->getPost()->get('owner'); @@ -186,7 +186,7 @@ public function addAction() $repository = $sm->get('EdpGithub\Client')->api('repos')->show($owner, $repo); $repository = json_decode($repository); - if(!($repository instanceof \stdClass)) { + if (!($repository instanceof \stdClass)) { throw new Exception\RuntimeException( 'Not able to fetch the repository from github due to an unknown error.', 500 @@ -194,8 +194,8 @@ public function addAction() } $service = $this->getModuleService(); - if(!$repository->fork && $repository->permissions->push) { - if($service->isModule($repository)) { + if (!$repository->fork && $repository->permissions->push) { + if ($service->isModule($repository)) { $module = $service->register($repository); $this->flashMessenger()->addMessage($module->getName() .' has been added to ZF Modules'); } else { @@ -204,7 +204,7 @@ public function addAction() 403 ); } - }else { + } else { throw new Exception\UnexpectedValueException( 'You have no permission to add this module. The reason might be that you are' . 'neither the owner nor a collaborator of this repository.', @@ -244,7 +244,7 @@ public function removeAction() } $request = $this->getRequest(); - if($request->isPost()) { + if ($request->isPost()) { $repo = $request->getPost()->get('repo'); $owner = $request->getPost()->get('owner'); @@ -252,17 +252,17 @@ public function removeAction() $repository = $sm->get('EdpGithub\Client')->api('repos')->show($owner, $repo); $repository = json_decode($repository); - if(!$repository instanceof \stdClass) { + if (!$repository instanceof \stdClass) { throw new Exception\RuntimeException( 'Not able to fetch the repository from github due to an unknown error.', 500 ); } - if(!$repository->fork && $repository->permissions->push) { + if (!$repository->fork && $repository->permissions->push) { $mapper = $sm->get('zfmodule_mapper_module'); $module = $mapper->findByUrl($repository->html_url); - if($module instanceof \ZfModule\Entity\Module) { + if ($module instanceof \ZfModule\Entity\Module) { $module = $mapper->delete($module); $this->flashMessenger()->addMessage($repository->name .' has been removed from ZF Modules'); } else { @@ -271,7 +271,7 @@ public function removeAction() 403 ); } - }else { + } else { throw new Exception\UnexpectedValueException( 'You have no permission to add this module. The reason might be that you are' . 'neither the owner nor a collaborator of this repository.', diff --git a/module/ZfModule/src/ZfModule/Mapper/Exception/ExceptionInterface.php b/module/ZfModule/src/ZfModule/Mapper/Exception/ExceptionInterface.php index 957502bd..abd250d3 100644 --- a/module/ZfModule/src/ZfModule/Mapper/Exception/ExceptionInterface.php +++ b/module/ZfModule/src/ZfModule/Mapper/Exception/ExceptionInterface.php @@ -5,4 +5,6 @@ use ZfcBase\Mapper\Exception\ExceptionInterface as Exception; interface ExceptionInterface extends Exception -{} +{ + +} diff --git a/module/ZfModule/src/ZfModule/Mapper/Exception/InvalidArgumentException.php b/module/ZfModule/src/ZfModule/Mapper/Exception/InvalidArgumentException.php index 1717cbcc..793ce542 100644 --- a/module/ZfModule/src/ZfModule/Mapper/Exception/InvalidArgumentException.php +++ b/module/ZfModule/src/ZfModule/Mapper/Exception/InvalidArgumentException.php @@ -3,4 +3,6 @@ namespace ZfModule\Mapper\Exception; class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface -{} +{ + +} diff --git a/module/ZfModule/src/ZfModule/Mapper/Exception/RuntimeException.php b/module/ZfModule/src/ZfModule/Mapper/Exception/RuntimeException.php index 8a38b38e..66fb3c8e 100644 --- a/module/ZfModule/src/ZfModule/Mapper/Exception/RuntimeException.php +++ b/module/ZfModule/src/ZfModule/Mapper/Exception/RuntimeException.php @@ -3,4 +3,6 @@ namespace ZfModule\Mapper\Exception; class RuntimeException extends \RuntimeException implements ExceptionInterface -{} +{ + +} diff --git a/module/ZfModule/src/ZfModule/Mapper/Module.php b/module/ZfModule/src/ZfModule/Mapper/Module.php index 46d4f0a9..a0a901b3 100644 --- a/module/ZfModule/src/ZfModule/Mapper/Module.php +++ b/module/ZfModule/src/ZfModule/Mapper/Module.php @@ -15,11 +15,11 @@ public function pagination($page, $limit, $query = null, $orderBy = null, $sort { $select = $this->getSelect(); - if($orderBy) { + if ($orderBy) { $select->order($orderBy . ' ' . $sort); } - if(null !== $query) { + if (null !== $query) { $spec = function ($where) use ($query) { $where->like('name', '%'.$query.'%')->or->like('description', '%'.$query.'%'); }; @@ -38,15 +38,15 @@ public function pagination($page, $limit, $query = null, $orderBy = null, $sort return $paginator; } - public function findAll($limit= null, $orderBy = null, $sort = 'ASC') + public function findAll($limit = null, $orderBy = null, $sort = 'ASC') { $select = $this->getSelect(); - if($orderBy) { + if ($orderBy) { $select->order($orderBy . ' ' . $sort); } - if($limit) { + if ($limit) { $select->limit($limit); } @@ -59,11 +59,11 @@ public function findByLike($query, $limit = null, $orderBy = null, $sort = 'ASC' { $select = $this->getSelect(); - if($orderBy) { + if ($orderBy) { $select->order($orderBy . ' ' . $sort); } - if($limit) { + if ($limit) { $select->limit($limit); } @@ -77,15 +77,15 @@ public function findByLike($query, $limit = null, $orderBy = null, $sort = 'ASC' return $entity; } - public function findByOwner($owner, $limit= null, $orderBy = null, $sort = 'ASC') + public function findByOwner($owner, $limit = null, $orderBy = null, $sort = 'ASC') { $select = $this->getSelect(); - if($orderBy) { + if ($orderBy) { $select->order($orderBy . ' ' . $sort); } - if($limit) { + if ($limit) { $select->limit($limit); } diff --git a/module/ZfModule/src/ZfModule/Service/Module.php b/module/ZfModule/src/ZfModule/Service/Module.php index b9c1b924..61a20adc 100644 --- a/module/ZfModule/src/ZfModule/Service/Module.php +++ b/module/ZfModule/src/ZfModule/Service/Module.php @@ -3,7 +3,7 @@ namespace ZfModule\Service; use Zend\ServiceManager\ServiceLocatorAwareInterface; -use Zend\ServiceManager\ServiceLocatorInterface;; +use Zend\ServiceManager\ServiceLocatorInterface; use Zend\Stdlib\Hydrator\ClassMethods; use ZfcBase\EventManager\EventProvider; use ZfModule\Mapper\ModuleInterface as ModuleMapperInterface; @@ -33,7 +33,7 @@ public function register($data) $url = $data->html_url; $module = $this->getModuleMapper()->findByUrl($url); $update = true; - if(!$module) { + if (!$module) { $module = new \ZfModule\Entity\Module; $update = false; } @@ -45,7 +45,7 @@ public function register($data) $module->setOwner($owner->login); $module->setPhotoUrl($owner->avatar_url); - if($update) { + if ($update) { $this->getModuleMapper()->update($module); } else { $this->getModuleMapper()->insert($module); @@ -65,6 +65,9 @@ public function isModule($repo) $sm = $this->getServiceLocator(); $client = $sm->get('EdpGithub\Client'); + if (!json_decode($module) instanceof \stdClass) { + return false; + } $query = 'repo:' . $repo->owner->login . '/' . $repo->name . ' filename:Module.php "class Module"'; $response = $client->getHttpClient()->request('search/code?q=' . $query); $result = json_decode($response->getbody(), true); diff --git a/module/ZfModule/src/ZfModule/View/Helper/ListModule.php b/module/ZfModule/src/ZfModule/View/Helper/ListModule.php index 47bae896..b1bcef0a 100644 --- a/module/ZfModule/src/ZfModule/View/Helper/ListModule.php +++ b/module/ZfModule/src/ZfModule/View/Helper/ListModule.php @@ -37,17 +37,17 @@ public function __invoke($options = null) $modules = array(); //limit modules to only user modules - if($user) { + if ($user) { $client = $sl->get('EdpGithub\Client'); $repos = $client->api('current_user')->repos(array('type' =>'all', 'per_page' => 100)); $modules = array(); - foreach($repos as $repo) { - if(!$repo->fork && $repo->permissions->push) { + foreach ($repos as $repo) { + if (!$repo->fork && $repo->permissions->push) { $module = $mapper->findByName($repo->name); - if($module) { - $modules[] = $module; + if ($module) { + $modules[] = $module; } } } diff --git a/module/ZfModule/src/ZfModule/View/Helper/TotalModules.php b/module/ZfModule/src/ZfModule/View/Helper/TotalModules.php index 3a61e919..f0f12801 100644 --- a/module/ZfModule/src/ZfModule/View/Helper/TotalModules.php +++ b/module/ZfModule/src/ZfModule/View/Helper/TotalModules.php @@ -53,5 +53,4 @@ public function setServiceLocator(ServiceLocatorInterface $serviceLocator) $this->serviceLocator = $serviceLocator; return $this; } - } diff --git a/module/ZfModule/test/ZfModuleTest/Bootstrap.php b/module/ZfModule/test/ZfModuleTest/Bootstrap.php index 38b14d99..4f3cb705 100644 --- a/module/ZfModule/test/ZfModuleTest/Bootstrap.php +++ b/module/ZfModule/test/ZfModuleTest/Bootstrap.php @@ -31,9 +31,9 @@ public static function init() $zf2ModulePaths[] = $path; } - if(isset($testConfig['module_listener_options']['module_paths'])) { + if (isset($testConfig['module_listener_options']['module_paths'])) { $modulePaths = $testConfig['module_listener_options']['module_paths']; - foreach($modulePaths as $modulePath) { + foreach ($modulePaths as $modulePath) { if (($path = static::findParentPath($modulePath)) !== $zf2ModulePaths[0]) { $zf2ModulePaths[] = $path; } @@ -98,7 +98,9 @@ protected static function findParentPath($path) $previousDir = '.'; while (!is_dir($dir . '/' . $path)) { $dir = dirname($dir); - if ($previousDir === $dir) return false; + if ($previousDir === $dir) { + return false; + } $previousDir = $dir; } return $dir . '/' . $path; diff --git a/module/ZfModule/test/ZfModuleTest/Entity/ModuleTest.php b/module/ZfModule/test/ZfModuleTest/Entity/ModuleTest.php index e0abde8d..67989001 100644 --- a/module/ZfModule/test/ZfModuleTest/Entity/ModuleTest.php +++ b/module/ZfModule/test/ZfModuleTest/Entity/ModuleTest.php @@ -75,6 +75,4 @@ public function testSetPhotoUrl() $this->assertEquals('http://www.example.com/photo.jpg', $this->module->getPhotoUrl()); } - - } diff --git a/public/index.php b/public/index.php index 51758625..f8d668ce 100644 --- a/public/index.php +++ b/public/index.php @@ -18,4 +18,4 @@ } // Run the application! -Zend\Mvc\Application::init($appConfig)->run(); \ No newline at end of file +Zend\Mvc\Application::init($appConfig)->run();