Beispiel #1
0
 protected function determineClassAndMethod($classMethod)
 {
     try {
         return parent::determineClassAndMethod($classMethod);
     } catch (\InvalidArgumentException $e) {
         $classNamePrefix = $this->config('controller.class_prefix');
         if ($classNamePrefix && substr($classNamePrefix, -strlen($classNamePrefix) !== '\\')) {
             $classNamePrefix .= '\\';
         }
         $classNameSuffix = $this->config('controller.class_suffix') ?: '';
         $methodNameSuffix = $this->config('controller.method_suffix');
         if (is_null($methodNameSuffix)) {
             $methodNameSuffix = 'Action';
         }
         $realClassMethod = $classMethod;
         if (strpos($realClassMethod, '\\') !== 0) {
             $realClassMethod = $classNamePrefix . $classMethod;
         }
         if (preg_match('/^([a-zA-Z0-9\\\\_]+):([a-zA-Z0-9_]+):([a-zA-Z0-9_]+)$/', $realClassMethod, $match)) {
             $className = $match[1] . '\\Controller\\' . $match[2] . $classNameSuffix;
             $methodName = $match[3] . $methodNameSuffix;
         } else {
             throw new \InvalidArgumentException("Malformed class action for '{$classMethod}'. Use 'className:methodName' format.");
         }
         return array($className, $methodName);
     }
 }
Beispiel #2
0
define('PROTOCOL', $protocol);
define('HTTP_ROOT', $protocol . $_SERVER['HTTP_HOST']);
define('LOCAL_ROOT', __DIR__);
define('HTTP_MEDIA_DIR', HTTP_ROOT . '/media');
define('LOCAL_MEDIA_DIR', LOCAL_ROOT . '/web/media');
define('CONFIG_FILE', LOCAL_ROOT . '/app/config/parameters.yml');
define('SRC_FOLDER', LOCAL_ROOT . '/src');
// set locale to german
$newLocale = setlocale(LC_TIME, 'de_CH.UTF-8', 'de_CH');
// prevent PHP from sending conflicting cache expiration headers with the HTTP response
session_cache_limiter(false);
session_start();
// enable this for log writing to file
$logWriter = new LogWriter(fopen(__DIR__ . '/app/log/cms.log', 'a'));
$config = \rmatil\cms\Handler\ConfigurationHandler::readConfiguration(CONFIG_FILE);
$app = new Slim(array('debug' => true, 'log.level' => \Slim\Log::DEBUG, 'log.enabled' => true, 'controller.class_prefix' => 'rmatil\\cms\\Controller', 'controller.class_suffix' => 'Controller', 'controller.method_suffix' => 'Action', 'controller.template_suffix' => 'php', 'log.writer' => $logWriter, 'templates.path' => LOCAL_ROOT . '/web/templates/' . $config[\rmatil\cms\Constants\ConfigurationNames::TEMPLATE][\rmatil\cms\Constants\ConfigurationNames::TEMPLATE_PATH], 'view' => new \Slim\Views\Twig()));
$view = $app->view();
$view->parserOptions = array('debug' => true, 'cache' => __DIR__ . '/app/cache');
$view->parserExtensions = array(new \Slim\Views\TwigExtension(), new \Twig_Extension_Debug());
// Add JMS Serializer to app
$app->container->singleton('serializer', function () {
    $namingStrategy = new \JMS\Serializer\Naming\CamelCaseNamingStrategy();
    return SerializerBuilder::create()->addDefaultDeserializationVisitors()->addDefaultSerializationVisitors()->setSerializationVisitor('json', new \rmatil\cms\Serializer\JsonSerializationVisitor($namingStrategy))->build();
});
HandlerSingleton::setEntityManager($entityManager);
$thumbnailHandler = HandlerSingleton::getThumbnailHandler();
$fileHandler = HandlerSingleton::getFileHandler(HTTP_MEDIA_DIR, LOCAL_MEDIA_DIR);
$registrationHandler = HandlerSingleton::getRegistrationHandler($config['mail']['use']);
$databaseHandler = HandlerSingleton::getDatabaseHandler();
$loginHandler = HandlerSingleton::getLoginHandler(array('^\\/authenticate' => array('ROLE_SUPER_ADMIN', 'ROLE_ANONYMOUS'), '^\\/api\\/.*' => array('ROLE_SUPER_ADMIN')));
// Add Doctrine Entity Manager to app
Beispiel #3
0
 public function __construct()
 {
     parent::__construct();
     $this->response()->header("Access-Control-Allow-Origin", "*");
     $this->response()->header("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
     $this->response()->header("Access-Control-Allow-Headers", "Origin, Content-Type, Accept, Authorization, X-Requested-With");
     $this->parseConfig();
     $this->setDefaultView();
     $this->parseMiddlewares();
     $this->parseRouting();
     $this->run();
 }