@@ -45,8 +45,8 @@ discard block |
||
| 45 | 45 | $this->services = $e->getApplication()->getServiceManager(); |
| 46 | 46 | |
| 47 | 47 | $eventManager = $e->getApplication()->getEventManager(); |
| 48 | - $eventManager->attach(MvcEvent::EVENT_DISPATCH, [$this, 'onDispatch']); |
|
| 49 | - $eventManager->attach(MvcEvent::EVENT_RENDER, [$this, 'onRender']); |
|
| 48 | + $eventManager->attach(MvcEvent::EVENT_DISPATCH, [ $this, 'onDispatch' ]); |
|
| 49 | + $eventManager->attach(MvcEvent::EVENT_RENDER, [ $this, 'onRender' ]); |
|
| 50 | 50 | |
| 51 | 51 | $moduleRouteListener = new ModuleRouteListener(); |
| 52 | 52 | $moduleRouteListener->attach($eventManager); |
@@ -74,8 +74,8 @@ discard block |
||
| 74 | 74 | $controllerClass = get_class($controller); |
| 75 | 75 | $moduleNamespace = substr($controllerClass, 0, strpos($controllerClass, '\\')); |
| 76 | 76 | |
| 77 | - $fbMeta['title'] = 'Real Live Learn ZF2'; |
|
| 78 | - $fbMeta['description'] = ''; |
|
| 77 | + $fbMeta[ 'title' ] = 'Real Live Learn ZF2'; |
|
| 78 | + $fbMeta[ 'description' ] = ''; |
|
| 79 | 79 | |
| 80 | 80 | // set title prepend of module desc... |
| 81 | 81 | $moduleDetail = $this->services->get('Doctrine\ORM\EntityManager')->getRepository('Application\Entity\ModuleList')->findOneBy([ |
@@ -87,8 +87,8 @@ discard block |
||
| 87 | 87 | $title = $moduleDetail->getModuleDesc(); |
| 88 | 88 | $description = $moduleDetail->getModuleDesc(); |
| 89 | 89 | |
| 90 | - $fbMeta['title'] = $title.'-'.$fbMeta['title']; |
|
| 91 | - $fbMeta['description'] = $description.'-'.$fbMeta['description']; |
|
| 90 | + $fbMeta[ 'title' ] = $title.'-'.$fbMeta[ 'title' ]; |
|
| 91 | + $fbMeta[ 'description' ] = $description.'-'.$fbMeta[ 'description' ]; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | $e->getViewModel()->setVariable('fbMeta', $fbMeta); |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | if (!$e->getViewModel()->terminate()) { |
| 112 | 112 | $entityManager = $this->services->get('Doctrine\ORM\EntityManager'); |
| 113 | 113 | $e->getViewModel() |
| 114 | - ->setVariable('modules_list', $entityManager->getRepository('Application\Entity\ModuleList')->findBy([], ['id' => 'DESC'])); |
|
| 114 | + ->setVariable('modules_list', $entityManager->getRepository('Application\Entity\ModuleList')->findBy([ ], [ 'id' => 'DESC' ])); |
|
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | 117 | |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | foreach ($contributors as $i => $contributor) { |
| 98 | 98 | $message = sprintf(' Processing %d/%d', $i, $total); |
| 99 | 99 | $this->console->write($message); |
| 100 | - $this->httpClient->setUri("https://api.github.com/users/{$contributor['login']}"); |
|
| 100 | + $this->httpClient->setUri("https://api.github.com/users/{$contributor[ 'login' ]}"); |
|
| 101 | 101 | $response = $this->httpClient->send(); |
| 102 | 102 | if (!$response->isSuccess()) { |
| 103 | 103 | // report failure |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | } |
| 107 | 107 | $body = $response->getBody(); |
| 108 | 108 | $userInfo = json_decode($body, 1); |
| 109 | - $contributors[$i]['user_info'] = $userInfo; |
|
| 109 | + $contributors[ $i ][ 'user_info' ] = $userInfo; |
|
| 110 | 110 | $this->reportSuccess($width, strlen($message)); |
| 111 | 111 | } |
| 112 | 112 | |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | $this->console->writeLine(str_repeat('-', $width)); |
| 140 | 140 | $message = 'Writing file'; |
| 141 | 141 | $this->console->write($message, Color::BLUE); |
| 142 | - $path = $this->config['console']['contributors']['output']; |
|
| 142 | + $path = $this->config[ 'console' ][ 'contributors' ][ 'output' ]; |
|
| 143 | 143 | file_put_contents($path, serialize($contributors)); |
| 144 | 144 | $this->reportSuccess($width, strlen($message)); |
| 145 | 145 | $this->console->writeLine(sprintf('File written to %s', $path)); |
@@ -31,11 +31,11 @@ |
||
| 31 | 31 | public function createService(ServiceLocatorInterface $serviceLocator) |
| 32 | 32 | { |
| 33 | 33 | $services = $serviceLocator->getServiceLocator(); |
| 34 | - $moduleList = []; |
|
| 34 | + $moduleList = [ ]; |
|
| 35 | 35 | foreach ($services->get('Doctrine\ORM\EntityManager') |
| 36 | 36 | ->getRepository('Application\Entity\ModuleList') |
| 37 | 37 | ->findAll() as $module) { |
| 38 | - $moduleList[] = $module->getModuleName(); |
|
| 38 | + $moduleList[ ] = $module->getModuleName(); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | return new DownloadController($moduleList); |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | $services = $serviceLocator->getServiceLocator(); |
| 34 | 34 | |
| 35 | 35 | return new IndexController( |
| 36 | - $services->get('Doctrine\ORM\EntityManager')->getRepository('Application\Entity\ModuleList')->findBy([], ['id' => 'DESC']) |
|
| 36 | + $services->get('Doctrine\ORM\EntityManager')->getRepository('Application\Entity\ModuleList')->findBy([ ], [ 'id' => 'DESC' ]) |
|
| 37 | 37 | ); |
| 38 | 38 | } |
| 39 | 39 | } |
@@ -62,8 +62,8 @@ |
||
| 62 | 62 | |
| 63 | 63 | public function listresourcesandrightsAction() |
| 64 | 64 | { |
| 65 | - $resources = []; |
|
| 66 | - $rights = []; |
|
| 65 | + $resources = [ ]; |
|
| 66 | + $rights = [ ]; |
|
| 67 | 67 | |
| 68 | 68 | if ($this->request->isPost()) { |
| 69 | 69 | $roleId = $this->request->getPost('roleId', 0); |
@@ -45,12 +45,12 @@ discard block |
||
| 45 | 45 | $this->addResource(new Resource('AdminController')); |
| 46 | 46 | |
| 47 | 47 | $this->allow('Guest', 'HomeController', 'ViewHome'); |
| 48 | - $this->allow('Guest', 'UserController', ['ViewUser', 'RegisterUser']); |
|
| 48 | + $this->allow('Guest', 'UserController', [ 'ViewUser', 'RegisterUser' ]); |
|
| 49 | 49 | |
| 50 | 50 | $this->allow('User', 'UserController', 'EditUser'); |
| 51 | 51 | $this->deny('User', 'UserController', 'RegisterUser'); |
| 52 | 52 | |
| 53 | - $this->allow('Admin', 'AdminController', ['DeleteUser', 'AddUser']); |
|
| 53 | + $this->allow('Admin', 'AdminController', [ 'DeleteUser', 'AddUser' ]); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
@@ -62,23 +62,23 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function getRightLists($roleId = null) |
| 64 | 64 | { |
| 65 | - $rules = []; |
|
| 65 | + $rules = [ ]; |
|
| 66 | 66 | $currentRole = 'All'; |
| 67 | 67 | foreach ($this->getResources() as $resource) { |
| 68 | 68 | foreach ($this->getRoles() as $roleKey => $role) { |
| 69 | - $rules[] = $this->getRules(new Resource($resource), new Role($role)); |
|
| 69 | + $rules[ ] = $this->getRules(new Resource($resource), new Role($role)); |
|
| 70 | 70 | if ($roleId === $roleKey) { |
| 71 | 71 | $currentRole = $role; |
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - $rights = []; |
|
| 76 | + $rights = [ ]; |
|
| 77 | 77 | foreach ($rules as $rule) { |
| 78 | 78 | if (is_array($rule)) { |
| 79 | - foreach ($rule['byPrivilegeId'] as $right => $typeAndAssert) { |
|
| 79 | + foreach ($rule[ 'byPrivilegeId' ] as $right => $typeAndAssert) { |
|
| 80 | 80 | if (!in_array($right, $rights)) { |
| 81 | - $rights[] = $right; |
|
| 81 | + $rights[ ] = $right; |
|
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | } |
@@ -88,13 +88,13 @@ discard block |
||
| 88 | 88 | return $rights; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - $rightList = []; |
|
| 91 | + $rightList = [ ]; |
|
| 92 | 92 | foreach ($this->getResources() as $resource) { |
| 93 | 93 | foreach ($rights as $key => $right) { |
| 94 | 94 | if ($currentRole !== 'All' |
| 95 | 95 | && $this->isAllowed($currentRole, $resource, $right) && !in_array($right, $rightList) |
| 96 | 96 | ) { |
| 97 | - $rightList[] = $right; |
|
| 97 | + $rightList[ ] = $right; |
|
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | } |
@@ -119,13 +119,13 @@ discard block |
||
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - $resources = []; |
|
| 122 | + $resources = [ ]; |
|
| 123 | 123 | foreach ($this->getResources() as $resource) { |
| 124 | 124 | foreach ($this->getRightLists() as $right) { |
| 125 | 125 | if ($this->isAllowed($selectedRole, $resource, $right) |
| 126 | 126 | && !in_array($resource, $resources) |
| 127 | 127 | ) { |
| 128 | - $resources[] = $resource; |
|
| 128 | + $resources[ ] = $resource; |
|
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | } |
@@ -19,8 +19,8 @@ discard block |
||
| 19 | 19 | class IndexController extends AbstractActionController |
| 20 | 20 | { |
| 21 | 21 | protected $acceptCriteria = [ |
| 22 | - 'Zend\View\Model\JsonModel' => ['application/json'], |
|
| 23 | - 'Zend\View\Model\ViewModel' => ['text/html'], |
|
| 22 | + 'Zend\View\Model\JsonModel' => [ 'application/json' ], |
|
| 23 | + 'Zend\View\Model\ViewModel' => [ 'text/html' ], |
|
| 24 | 24 | ]; |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | public function indexAction() |
| 37 | 37 | { |
| 38 | - $result = ['result' => false,'message' => '']; |
|
| 38 | + $result = [ 'result' => false, 'message' => '' ]; |
|
| 39 | 39 | $viewModel = $this->acceptableviewmodelselector($this->acceptCriteria); |
| 40 | 40 | |
| 41 | 41 | $request = $this->getRequest(); |
@@ -45,9 +45,9 @@ discard block |
||
| 45 | 45 | $this->loginForm->setData($request->getPost()); |
| 46 | 46 | |
| 47 | 47 | if ($this->loginForm->isValid()) { |
| 48 | - $result = ['result' => true,'message' => 'Ajax request success']; |
|
| 48 | + $result = [ 'result' => true, 'message' => 'Ajax request success' ]; |
|
| 49 | 49 | } else { |
| 50 | - $result = ['result' => false,'message' => $this->loginForm->getMessages()]; |
|
| 50 | + $result = [ 'result' => false, 'message' => $this->loginForm->getMessages() ]; |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | $viewModel = new JsonModel(); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - $viewModel->setVariables(['form' => $this->loginForm, 'data' => $result]); |
|
| 58 | + $viewModel->setVariables([ 'form' => $this->loginForm, 'data' => $result ]); |
|
| 59 | 59 | |
| 60 | 60 | return $viewModel; |
| 61 | 61 | } |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | namespace LearnZF2Ajax\Model; |
| 11 | 11 | |
| 12 | -use Zend\InputFilter\Factory as InputFactory; // <-- Add this import |
|
| 12 | +use Zend\InputFilter\Factory as InputFactory; // <-- Add this import |
|
| 13 | 13 | use Zend\InputFilter\InputFilter; |
| 14 | 14 | use Zend\InputFilter\InputFilterAwareInterface; |
| 15 | 15 | use Zend\InputFilter\InputFilterInterface; |
@@ -22,8 +22,8 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | public function exchangeArray($data) |
| 24 | 24 | { |
| 25 | - $this->username = (isset($data['username'])) ? $data['username'] : null; |
|
| 26 | - $this->password = (isset($data['password'])) ? $data['password'] : null; |
|
| 25 | + $this->username = (isset($data[ 'username' ])) ? $data[ 'username' ] : null; |
|
| 26 | + $this->password = (isset($data[ 'password' ])) ? $data[ 'password' ] : null; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | public function setInputFilter(InputFilterInterface $inputFilter) |
@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | 'name' => 'username', |
| 42 | 42 | 'required' => true, |
| 43 | 43 | 'filters' => [ |
| 44 | - ['name' => 'StripTags'], |
|
| 45 | - ['name' => 'StringTrim'], |
|
| 44 | + [ 'name' => 'StripTags' ], |
|
| 45 | + [ 'name' => 'StringTrim' ], |
|
| 46 | 46 | ], |
| 47 | 47 | 'validators' => [ |
| 48 | 48 | [ |
@@ -66,8 +66,8 @@ discard block |
||
| 66 | 66 | 'name' => 'password', |
| 67 | 67 | 'required' => true, |
| 68 | 68 | 'filters' => [ |
| 69 | - ['name' => 'StripTags'], |
|
| 70 | - ['name' => 'StringTrim'], |
|
| 69 | + [ 'name' => 'StripTags' ], |
|
| 70 | + [ 'name' => 'StringTrim' ], |
|
| 71 | 71 | ], |
| 72 | 72 | 'validators' => [ |
| 73 | 73 | [ |
@@ -38,8 +38,8 @@ discard block |
||
| 38 | 38 | * @var array |
| 39 | 39 | */ |
| 40 | 40 | protected $acceptCriteria = [ |
| 41 | - 'Zend\View\Model\JsonModel' => ['application/json'], |
|
| 42 | - 'Zend\View\Model\ViewModel' => ['text/html'], |
|
| 41 | + 'Zend\View\Model\JsonModel' => [ 'application/json' ], |
|
| 42 | + 'Zend\View\Model\ViewModel' => [ 'text/html' ], |
|
| 43 | 43 | ]; |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | protected function uploadAction() |
| 88 | 88 | { |
| 89 | 89 | $request = $this->getRequest(); |
| 90 | - $data = []; |
|
| 90 | + $data = [ ]; |
|
| 91 | 91 | |
| 92 | 92 | if ($request->isXmlHttpRequest()) { |
| 93 | 93 | $data = $this->prepareImages(); |
@@ -112,8 +112,8 @@ discard block |
||
| 112 | 112 | $data = $request->getPost()->toArray(); |
| 113 | 113 | |
| 114 | 114 | if ($request->isXmlHttpRequest()) { |
| 115 | - if (is_file('public'.$data['img'])) { |
|
| 116 | - unlink('public'.$data['img']); |
|
| 115 | + if (is_file('public'.$data[ 'img' ])) { |
|
| 116 | + unlink('public'.$data[ 'img' ]); |
|
| 117 | 117 | $status = true; |
| 118 | 118 | } |
| 119 | 119 | } |
@@ -135,18 +135,18 @@ discard block |
||
| 135 | 135 | $dir = new \RecursiveDirectoryIterator('userfiles/', \FilesystemIterator::SKIP_DOTS); |
| 136 | 136 | $it = new \RecursiveIteratorIterator($dir, \RecursiveIteratorIterator::SELF_FIRST); |
| 137 | 137 | $it->setMaxDepth(50); |
| 138 | - $files = []; |
|
| 138 | + $files = [ ]; |
|
| 139 | 139 | $i = 0; |
| 140 | 140 | foreach ($it as $file) { |
| 141 | 141 | if ($file->isFile()) { |
| 142 | - $files[$i]['filelink'] = DIRECTORY_SEPARATOR.$file->getPath().DIRECTORY_SEPARATOR.$file->getFilename(); |
|
| 143 | - $files[$i]['filename'] = $file->getFilename(); |
|
| 142 | + $files[ $i ][ 'filelink' ] = DIRECTORY_SEPARATOR.$file->getPath().DIRECTORY_SEPARATOR.$file->getFilename(); |
|
| 143 | + $files[ $i ][ 'filename' ] = $file->getFilename(); |
|
| 144 | 144 | $i++; |
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | chdir(dirname(getcwd())); |
| 148 | 148 | $model = new JsonModel(); |
| 149 | - $model->setVariables(['files' => $files]); |
|
| 149 | + $model->setVariables([ 'files' => $files ]); |
|
| 150 | 150 | |
| 151 | 151 | return $model; |
| 152 | 152 | } |
@@ -160,14 +160,14 @@ discard block |
||
| 160 | 160 | { |
| 161 | 161 | $adapter = new Http(); |
| 162 | 162 | |
| 163 | - $size = new Size(['min' => '10kB', 'max' => '5MB','useByteString' => true]); |
|
| 164 | - $extension = new Extension(['jpg','gif','png','jpeg','bmp','webp','svg'], true); |
|
| 163 | + $size = new Size([ 'min' => '10kB', 'max' => '5MB', 'useByteString' => true ]); |
|
| 164 | + $extension = new Extension([ 'jpg', 'gif', 'png', 'jpeg', 'bmp', 'webp', 'svg' ], true); |
|
| 165 | 165 | |
| 166 | 166 | if (extension_loaded('fileinfo')) { |
| 167 | - $adapter->setValidators([new IsImage()]); |
|
| 167 | + $adapter->setValidators([ new IsImage() ]); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - $adapter->setValidators([$size, $extension]); |
|
| 170 | + $adapter->setValidators([ $size, $extension ]); |
|
| 171 | 171 | |
| 172 | 172 | $adapter->setDestination('public/userfiles/images/'); |
| 173 | 173 | |
@@ -181,20 +181,20 @@ discard block |
||
| 181 | 181 | */ |
| 182 | 182 | private function uploadFiles(Http $adapter) |
| 183 | 183 | { |
| 184 | - $uploadStatus = []; |
|
| 184 | + $uploadStatus = [ ]; |
|
| 185 | 185 | |
| 186 | 186 | foreach ($adapter->getFileInfo() as $key => $file) { |
| 187 | - if (!$adapter->isValid($file['name'])) { |
|
| 187 | + if (!$adapter->isValid($file[ 'name' ])) { |
|
| 188 | 188 | foreach ($adapter->getMessages() as $key => $msg) { |
| 189 | - $uploadStatus['errorFiles'][] = $file['name'].' '.strtolower($msg); |
|
| 189 | + $uploadStatus[ 'errorFiles' ][ ] = $file[ 'name' ].' '.strtolower($msg); |
|
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | // @codeCoverageIgnoreStart |
| 194 | - if (!$adapter->receive($file['name'])) { |
|
| 195 | - $uploadStatus['errorFiles'][] = $file['name'].' was not uploaded'; |
|
| 194 | + if (!$adapter->receive($file[ 'name' ])) { |
|
| 195 | + $uploadStatus[ 'errorFiles' ][ ] = $file[ 'name' ].' was not uploaded'; |
|
| 196 | 196 | } else { |
| 197 | - $uploadStatus['successFiles'][] = $file['name'].' was successfully uploaded'; |
|
| 197 | + $uploadStatus[ 'successFiles' ][ ] = $file[ 'name' ].' was successfully uploaded'; |
|
| 198 | 198 | } |
| 199 | 199 | // @codeCoverageIgnoreEnd |
| 200 | 200 | } |