2010-06-06 16:05:46 +02:00
|
|
|
<?php
|
2010-07-21 12:44:01 +02:00
|
|
|
/**
|
|
|
|
* @copyright Copyright (c) 2010, The volkszaehler.org project
|
2010-07-22 11:13:11 +02:00
|
|
|
* @package default
|
2010-07-21 12:44:01 +02:00
|
|
|
* @license http://www.opensource.org/licenses/gpl-license.php GNU Public License
|
2010-07-22 16:21:26 +02:00
|
|
|
*/
|
|
|
|
/*
|
2010-07-21 12:44:01 +02:00
|
|
|
* This file is part of volkzaehler.org
|
2010-06-06 16:05:46 +02:00
|
|
|
*
|
2010-07-21 12:44:01 +02:00
|
|
|
* volkzaehler.org 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 3 of the License, or
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* volkzaehler.org is distributed in the hope that it will be useful,
|
2010-06-06 16:05:46 +02:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2010-07-21 12:44:01 +02:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2010-06-06 16:05:46 +02:00
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2010-07-21 12:44:01 +02:00
|
|
|
* along with volkszaehler.org. If not, see <http://www.gnu.org/licenses/>.
|
2010-06-06 16:05:46 +02:00
|
|
|
*/
|
|
|
|
|
2010-07-18 17:12:00 +02:00
|
|
|
namespace Volkszaehler\Controller;
|
2010-06-07 21:48:49 +02:00
|
|
|
|
2010-07-21 12:44:01 +02:00
|
|
|
/**
|
2010-07-29 00:04:33 +02:00
|
|
|
* Controller superclass for all controllers
|
2010-07-21 12:44:01 +02:00
|
|
|
*
|
2010-07-22 11:13:11 +02:00
|
|
|
* @author Steffen Vogel <info@steffenvogel.de>
|
|
|
|
* @package default
|
2010-07-21 12:44:01 +02:00
|
|
|
*/
|
2010-07-09 23:50:20 +02:00
|
|
|
abstract class Controller {
|
2010-06-07 02:13:05 +02:00
|
|
|
protected $view;
|
2010-07-18 17:12:00 +02:00
|
|
|
protected $em;
|
2010-07-22 11:13:11 +02:00
|
|
|
|
2010-07-21 12:44:01 +02:00
|
|
|
/**
|
2010-07-29 00:04:33 +02:00
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* @param View $view
|
|
|
|
* @param EntityManager $em
|
2010-07-18 17:12:00 +02:00
|
|
|
*/
|
|
|
|
public function __construct(\Volkszaehler\View\View $view, \Doctrine\ORM\EntityManager $em) {
|
2010-06-07 02:13:05 +02:00
|
|
|
$this->view = $view;
|
2010-07-18 17:12:00 +02:00
|
|
|
$this->em = $em;
|
2010-06-06 16:05:46 +02:00
|
|
|
}
|
2010-07-22 11:13:11 +02:00
|
|
|
|
2010-07-18 17:12:00 +02:00
|
|
|
/**
|
2010-09-19 20:47:29 +02:00
|
|
|
* Run operation
|
2010-07-22 11:13:11 +02:00
|
|
|
*
|
2010-09-19 20:47:29 +02:00
|
|
|
* @param string $operation runs the operation if class method is available
|
2010-07-09 23:50:20 +02:00
|
|
|
*/
|
2010-09-22 23:18:08 +02:00
|
|
|
public function run($operation, array $identifiers = array()) {
|
2010-09-19 20:47:29 +02:00
|
|
|
if (!is_callable(array($this, $operation))) {
|
|
|
|
throw new \Exception('Invalid context operation: ' . $operation);
|
2010-07-18 17:12:00 +02:00
|
|
|
}
|
2010-07-22 11:13:11 +02:00
|
|
|
|
2010-09-22 23:18:08 +02:00
|
|
|
return call_user_func_array(array($this, $operation), $identifiers);
|
2010-06-07 21:48:49 +02:00
|
|
|
}
|
2010-06-06 16:05:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|