Commit e6479c24 authored by Andreas Wolf's avatar Andreas Wolf Committed by Thomas Löffler

[CLEANUP] Reformat sources according to PSR-2

Change-Id: I1e052aac90bd198b2d0e061b497b6a0ef7b747e3
Reviewed-on: https://review.typo3.org/50611Reviewed-by: Thomas Löffler's avatarThomas Löffler <loeffler@spooner-web.de>
Tested-by: Thomas Löffler's avatarThomas Löffler <loeffler@spooner-web.de>
parent 630e3d3b
This diff is collapsed.
This diff is collapsed.
<?php
/*******************************************************************
* Copyright notice
*
* (c) 2011 Kai Vogel <kai.vogel@speedprogs.de>, Speedprogs.de
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
******************************************************************/
/**
* Abstract controller
*/
abstract class Tx_TerFe2_Controller_AbstractTerBasedController extends Tx_TerFe2_Controller_AbstractController {
/**
* @var array
*/
protected $frontendUser = array();
/**
* @var Tx_TerFe2_Service_Ter
*/
protected $terConnection;
/**
* @var array
*/
protected $terSettings = array();
/**
* @var array
*/
protected $terAccount = array();
/**
* Initialize action
*
* @return void
*/
public function initializeAction() {
parent::initializeAction();
$this->frontendUser = (!empty($GLOBALS['TSFE']->fe_user->user) ? $GLOBALS['TSFE']->fe_user->user : array());
$this->terSettings = (!empty($this->settings['terConnection']) ? $this->settings['terConnection'] : array());
$this->terAccount = $this->getTerAccount();
$this->terConnection = $this->getTerConnection();
}
/**
* Initializes the view, add login state to template variables
*
* @return void
*/
public function initializeView() {
$this->view->assign('loggedIn', FALSE);
if (!empty($this->frontendUser)) {
$this->view->assign('loggedIn', TRUE);
$this->view->assign('userName', $this->frontendUser['username']);
$this->view->assign('userId', $this->frontendUser['uid']);
}
}
/**
* Returns the account data from current frontend user
*
* @return array Frontend user account data
*/
protected function getTerAccount() {
$username = $this->frontendUser['username'];
$password = $this->frontendUser['password'];
if (!empty($this->terSettings['username']) && !empty($this->terSettings['password'])) {
$username = $this->terSettings['username'];
$password = $this->terSettings['password'];
}
return array(
'username' => $username,
'password' => $password,
);
}
/**
* Create a connection to the TER server
*
* @return Tx_TerFe2_Service_Ter The TER connection
*/
protected function getTerConnection() {
// Check the wsdl uri
if (empty($this->terSettings['wsdl'])) {
throw new Exception('No wsdl set to connect to TER server');
}
// Create connection
$wsdl = $this->terSettings['wsdl'];
return $this->objectManager->get('Tx_TerFe2_Service_Ter', $wsdl, $this->terAccount['username'], $this->terAccount['password']);
}
}
/*******************************************************************
* Copyright notice
*
* (c) 2011 Kai Vogel <kai.vogel@speedprogs.de>, Speedprogs.de
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
******************************************************************/
/**
* Abstract controller
*/
abstract class Tx_TerFe2_Controller_AbstractTerBasedController extends Tx_TerFe2_Controller_AbstractController
{
/**
* @var array
*/
protected $frontendUser = array();
/**
* @var Tx_TerFe2_Service_Ter
*/
protected $terConnection;
/**
* @var array
*/
protected $terSettings = array();
/**
* @var array
*/
protected $terAccount = array();
/**
* Initialize action
*
* @return void
*/
public function initializeAction()
{
parent::initializeAction();
$this->frontendUser = (!empty($GLOBALS['TSFE']->fe_user->user) ? $GLOBALS['TSFE']->fe_user->user : array());
$this->terSettings = (!empty($this->settings['terConnection']) ? $this->settings['terConnection'] : array());
$this->terAccount = $this->getTerAccount();
$this->terConnection = $this->getTerConnection();
}
/**
* Initializes the view, add login state to template variables
*
* @return void
*/
public function initializeView()
{
$this->view->assign('loggedIn', FALSE);
if (!empty($this->frontendUser)) {
$this->view->assign('loggedIn', TRUE);
$this->view->assign('userName', $this->frontendUser['username']);
$this->view->assign('userId', $this->frontendUser['uid']);
}
}
/**
* Returns the account data from current frontend user
*
* @return array Frontend user account data
*/
protected function getTerAccount()
{
$username = $this->frontendUser['username'];
$password = $this->frontendUser['password'];
if (!empty($this->terSettings['username']) && !empty($this->terSettings['password'])) {
$username = $this->terSettings['username'];
$password = $this->terSettings['password'];
}
return array(
'username' => $username,
'password' => $password,
);
}
/**
* Create a connection to the TER server
*
* @return Tx_TerFe2_Service_Ter The TER connection
*/
protected function getTerConnection()
{
// Check the wsdl uri
if (empty($this->terSettings['wsdl'])) {
throw new Exception('No wsdl set to connect to TER server');
}
// Create connection
$wsdl = $this->terSettings['wsdl'];
return $this->objectManager->get('Tx_TerFe2_Service_Ter', $wsdl, $this->terAccount['username'], $this->terAccount['password']);
}
}
?>
\ No newline at end of file
<?php
/*******************************************************************
* Copyright notice
*
* (c) 2011 Kai Vogel <kai.vogel@speedprogs.de>, Speedprogs.de
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
******************************************************************/
/*******************************************************************
* Copyright notice
*
* (c) 2011 Kai Vogel <kai.vogel@speedprogs.de>, Speedprogs.de
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
******************************************************************/
/**
* Controller for the author object
*/
class Tx_TerFe2_Controller_AuthorController extends Tx_TerFe2_Controller_AbstractController {
/**
* Controller for the author object
*/
class Tx_TerFe2_Controller_AuthorController extends Tx_TerFe2_Controller_AbstractController
{
/**
* @var Tx_TerFe2_Domain_Repository_AuthorRepository
*/
protected $authorRepository;
/**
* @var Tx_TerFe2_Domain_Repository_AuthorRepository
*/
protected $authorRepository;
/**
* @var Tx_TerFe2_Domain_Repository_ExtensionRepository
*/
protected $extensionRepository;
/**
* @var Tx_TerFe2_Domain_Repository_ExtensionRepository
*/
protected $extensionRepository;
/**
* Initializes the controller
*
* @return void
*/
protected function initializeController() {
$this->authorRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_AuthorRepository');
$this->extensionRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_ExtensionRepository');
}
/**
* Initializes the controller
*
* @return void
*/
protected function initializeController()
{
$this->authorRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_AuthorRepository');
$this->extensionRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_ExtensionRepository');
}
/**
* List action, displays all authors
*
* @return void
*/
public function listAction() {
$this->view->assign('authors', $this->authorRepository->findAll());
}
/**
* List action, displays all authors
*
* @return void
*/
public function listAction()
{
$this->view->assign('authors', $this->authorRepository->findAll());
}
/**
* Action that displays a single author
*
* @param Tx_TerFe2_Domain_Model_Author $author The author to display
* @return void
*/
public function showAction(Tx_TerFe2_Domain_Model_Author $author) {
$this->view->assign('author', $author);
$authorExtensions = $this->extensionRepository->findByAuthor($author);
$this->view->assign('authorExtensions', $authorExtensions);
}
/**
* Action that displays a single author
*
* @param Tx_TerFe2_Domain_Model_Author $author The author to display
* @return void
*/
public function showAction(Tx_TerFe2_Domain_Model_Author $author)
{
$this->view->assign('author', $author);
$authorExtensions = $this->extensionRepository->findByAuthor($author);
$this->view->assign('authorExtensions', $authorExtensions);
}
/**
* Displays a form to edit an existing author
*
* @param Tx_TerFe2_Domain_Model_Author $author The author to display
* @return void
* @dontvalidate $author
*/
public function editAction(Tx_TerFe2_Domain_Model_Author $author) {
$this->view->assign('author', $author);
}
/**
* Displays a form to edit an existing author
*
* @param Tx_TerFe2_Domain_Model_Author $author The author to display
* @return void
* @dontvalidate $author
*/
public function editAction(Tx_TerFe2_Domain_Model_Author $author)
{
$this->view->assign('author', $author);
}
/**
* Updates an existing author
*
* @param Tx_TerFe2_Domain_Model_Author $author Author to update
* @return void
*/
public function updateAction(Tx_TerFe2_Domain_Model_Author $author) {
$this->authorRepository->update($author);
$this->redirectWithMessage($this->translate('msg.author_updated'), 'list');
}
/**
* Updates an existing author
*
* @param Tx_TerFe2_Domain_Model_Author $author Author to update
* @return void
*/
public function updateAction(Tx_TerFe2_Domain_Model_Author $author)
{
$this->authorRepository->update($author);
$this->redirectWithMessage($this->translate('msg.author_updated'), 'list');
}
}
}
?>
\ No newline at end of file
<?php
/*******************************************************************
* Copyright notice
*
* (c) 2011 Kai Vogel <kai.vogel@speedprogs.de>, Speedprogs.de
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
******************************************************************/
/**
* Controller for the category object
*/
class Tx_TerFe2_Controller_CategoryController extends Tx_TerFe2_Controller_AbstractController {
/**
* @var Tx_TerFe2_Domain_Repository_CategoryRepository
*/
protected $categoryRepository;
/**
* @var Tx_TerFe2_Domain_Repository_ExtensionRepository
*/
protected $extensionRepository;
/**
* Initializes the controller
*
* @return void
*/
protected function initializeController() {
$this->categoryRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_CategoryRepository');
$this->extensionRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_ExtensionRepository');
}
/**
* List action, displays all categories
*
* @return void
*/
public function listAction() {
$this->view->assign('categories', $this->categoryRepository->findAll());
}
/**
* Action that displays a single category
*
* @param Tx_TerFe2_Domain_Model_Category $category The category to display
* @return void
*/
public function showAction(Tx_TerFe2_Domain_Model_Category $category) {
$this->view->assign('category', $category);
$categoryExtensions = $this->extensionRepository->findByCategory($category);
$this->view->assign('categoryExtensions', $categoryExtensions);
}
/**
* Displays a form for creating a new category
*
* @param Tx_TerFe2_Domain_Model_Category $newCategory New category object
* @return void
* @dontvalidate $newCategory
*/
public function newAction(Tx_TerFe2_Domain_Model_Category $newCategory = NULL) {
$this->view->assign('newCategory', $newCategory);
}
/**
* Creates a new category
*
* @param Tx_TerFe2_Domain_Model_Category $newCategory New category object
* @return void
*/
public function createAction(Tx_TerFe2_Domain_Model_Category $newCategory) {
$this->categoryRepository->add($newCategory);
$this->redirectWithMessage($this->translate('msg.category_created'), 'list');
}
/**
* Displays a form to edit an existing category
*
* @param Tx_TerFe2_Domain_Model_Category $category The category to display
* @return void
* @dontvalidate $category
*/
public function editAction(Tx_TerFe2_Domain_Model_Category $category) {
$this->view->assign('category', $category);
}
/**
* Updates an existing category
*
* @param Tx_TerFe2_Domain_Model_Category $category Category to update
* @return void
*/
public function updateAction(Tx_TerFe2_Domain_Model_Category $category) {
$this->categoryRepository->update($category);
$this->redirectWithMessage($this->translate('msg.category_updated'), 'list');
}
/**
* Deletes an existing category
*
* @param Tx_TerFe2_Domain_Model_Category $category The category to delete
* @return void
*/
public function deleteAction(Tx_TerFe2_Domain_Model_Category $category) {
$this->categoryRepository->remove($category);
$this->redirectWithMessage($this->translate('msg.category_deleted'), 'list');
}
}
/*******************************************************************
* Copyright notice
*
* (c) 2011 Kai Vogel <kai.vogel@speedprogs.de>, Speedprogs.de
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
******************************************************************/
/**
* Controller for the category object
*/
class Tx_TerFe2_Controller_CategoryController extends Tx_TerFe2_Controller_AbstractController
{
/**
* @var Tx_TerFe2_Domain_Repository_CategoryRepository
*/
protected $categoryRepository;
/**
* @var Tx_TerFe2_Domain_Repository_ExtensionRepository
*/
protected $extensionRepository;
/**
* Initializes the controller
*
* @return void
*/
protected function initializeController()
{
$this->categoryRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_CategoryRepository');
$this->extensionRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_ExtensionRepository');
}
/**
* List action, displays all categories
*
* @return void
*/
public function listAction()
{
$this->view->assign('categories', $this->categoryRepository->findAll());
}
/**
* Action that displays a single category
*
* @param Tx_TerFe2_Domain_Model_Category $category The category to display
* @return void
*/
public function showAction(Tx_TerFe2_Domain_Model_Category $category)
{
$this->view->assign('category', $category);
$categoryExtensions = $this->extensionRepository->findByCategory($category);
$this->view->assign('categoryExtensions', $categoryExtensions);
}
/**
* Displays a form for creating a new category
*
* @param Tx_TerFe2_Domain_Model_Category $newCategory New category object
* @return void
* @dontvalidate $newCategory
*/
public function newAction(Tx_TerFe2_Domain_Model_Category $newCategory = NULL)
{
$this->view->assign('newCategory', $newCategory);
}
/**
* Creates a new category
*
* @param Tx_TerFe2_Domain_Model_Category $newCategory New category object
* @return void
*/
public function createAction(Tx_TerFe2_Domain_Model_Category $newCategory)
{
$this->categoryRepository->add($newCategory);
$this->redirectWithMessage($this->translate('msg.category_created'), 'list');
}
/**
* Displays a form to edit an existing category
*
* @param Tx_TerFe2_Domain_Model_Category $category The category to display
* @return void
* @dontvalidate $category