예제 #1
0
 /**
  * Throw not found class exception
  * @return void
  */
 private function throwClassNotFoundException($dirname)
 {
     $subdirectory = str_replace($this->getPathBase() . DIRECTORY_SEPARATOR . 'web', '', $dirname);
     $subdirectory = empty($subdirectory) ? 'Index' : $subdirectory;
     $subdirectories = explode(DIRECTORY_SEPARATOR, $subdirectory);
     $suffix = join("", array_map("ucwords", $subdirectories));
     $modulesPath = PlainConfig::getInstance()->getModulesDirectories();
     foreach ($modulesPath as $modulePath) {
         $moduleFiles = scandir($modulePath . DIRECTORY_SEPARATOR . 'Controllers');
         if (!in_array("Default{$suffix}Controller.php", $moduleFiles)) {
             continue;
         }
         $defaultCall = "Application\\Modulo\\Controllers\\Default{$suffix}Controller";
         $reflectionModule = new \ReflectionClass($defaultCall);
         if ($reflectionModule->hasMethod('indexAction')) {
             $defaultClass = new $defaultCall();
             return $defaultClass->{'indexAction'}($this, PlainHttpResponse::getInstance());
         }
     }
     $actionName = PlainHttpRequest::getInstance()->getAction() ? PlainHttpRequest::getInstance()->getAction()->__toString() : 'notFound';
     $class = new PlainNotFoundActionController();
     $class->{$actionName . 'Action'}($this, PlainHttpResponse::getInstance());
     return;
 }
예제 #2
0
<?php

namespace Web\admin;

require_once "../../Library/PlainMVC/Core/Autoload.php";
use Library\PlainMVC\Core\View\PlainHttpRequest;
/**
 * Front Controller application
 * @author Hélio Costa e Silva <*****@*****.**>
 * @package \web
 * @version January, 17 2010
 */
PlainHttpRequest::getInstance()->dispatch(dirname(__FILE__));
예제 #3
0
}
$config = new Configuration();
$config->setMetadataCacheImpl($cache);
## Doctrine Metadata configuration
// Annotation
$driverImpl = $config->newDefaultAnnotationDriver(Core\PlainConfig::getInstance()->getApplicationDirectory());
// Yaml files
//$driver = new YamlDriver(array(dirname(__FILE__) . '/../schema/'));
//$config->setMetadataDriverImpl($driver);
// XML files
//$driver = new \Doctrine\ORM\Mapping\Driver\XmlDriver(array('/path/to/xmlfiles'));
//$config->setMetadataDriverImpl($driver);
$config->setMetadataDriverImpl($driverImpl);
$config->setQueryCacheImpl($cache);
$config->setProxyDir(Core\PlainConfig::getInstance()->getApplicationDirectory());
$config->setProxyNamespace(View\PlainHttpRequest::getInstance()->getNamespaceFor(Core\PlainConfig::getInstance()->getApplicationDirectory()));
if ($settings['type'] != "production") {
    $config->setAutoGenerateProxyClasses(true);
} else {
    $config->setAutoGenerateProxyClasses(false);
}
$connectionOptions = array('driver' => $settings['database']['driver'], 'host' => $settings['database']['host'], 'dbname' => $settings['database']['dbname'], 'user' => $settings['database']['user'], 'password' => $settings['database']['pass']);
class DoctrineConfig
{
    private static $em;
    public function __construct($connectionOptions, $config)
    {
        if (!self::$em instanceof \Doctrine\ORM\EntityManager) {
            self::$em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);
        }
    }