Exemplo n.º 1
0
	public function testConfiguration () {
		Configuration::setOption("test", "value");
		
		$this->assertEquals(Configuration::getOption("test"), "value");
		
		/* Test for the default value of bool false */
		$this->assertEquals(Configuration::getOption("test2"), false);
		
		/* Test for an user-specified default value */
		$this->assertEquals(Configuration::getOption("test2", "default"), "default");
		
		
	}
Exemplo n.º 2
0
	/**
	 * Ensures that the image cache dir exists.
	 */
	public function ensureCachedirExists () {
		if (!is_dir(Configuration::getOption("partkeepr.images.cache"))) {
			mkdir(Configuration::getOption("partkeepr.images.cache"), 0777, true);	
		}
	}
Exemplo n.º 3
0
	/**
	 * Returns the path to the file. May be overridden by
	 * subclasses.
	 *
	 * @param none
 	 * @return string The path to the file
	 */
	public function getFilePath () {
		return Configuration::getOption("partkeepr.files.path").$this->getType()."/";
	}
Exemplo n.º 4
0
<?php
namespace de\RaumZeitLabor\PartKeepr;

use de\RaumZeitLabor\PartKeepr\Util\Configuration;

Configuration::setOption("partkeepr.database.username", "partkeepr");
Configuration::setOption("partkeepr.database.password", "partkeepr");
Configuration::setOption("partkeepr.database.hostname", "localhost");
Configuration::setOption("partkeepr.database.dbname", "partkeepr");
Configuration::setOption("partkeepr.database.driver", "pdo_mysql");

Configuration::setOption("partkeepr.database.echo_sql_log", false);

Configuration::setOption("partkeepr.files.path", __DIR__."/data/files/");
Configuration::setOption("partkeepr.images.path", __DIR__."/data/images/");
Configuration::setOption("partkeepr.images.cache", Configuration::getOption("partkeepr.images.path")."cache/");
Exemplo n.º 5
0
	/**
	 * Initializes the doctrine framework and
	 * sets all required configuration options.
	 * 
	 * @param none
	 * @return nothing
	 */
	public static function initializeDoctrine () {
		
		
		$config = new Configuration;
		
		$driverImpl = $config->newDefaultAnnotationDriver(
			array(__DIR__)
			//array(__DIR__."/Session")
			
			);
		$config->setMetadataDriverImpl($driverImpl);
		
		$connectionOptions = array(
		    'driver' => 	PartKeeprConfiguration::getOption("partkeepr.database.driver","pdo_mysql"),
			'dbname' => 	PartKeeprConfiguration::getOption("partkeepr.database.dbname", "partkeepr"),
			'user' => 		PartKeeprConfiguration::getOption("partkeepr.database.username", "partkeepr"),
			'password' => 	PartKeeprConfiguration::getOption("partkeepr.database.password", "partkeepr"),
			'host' => 		PartKeeprConfiguration::getOption("partkeepr.database.hostname", "localhost")
		);
		
		$cache = new \Doctrine\Common\Cache\ApcCache();
		$config->setMetadataCacheImpl($cache);

		$config->setQueryCacheImpl($cache);
		
		$config->setProxyDir(dirname(dirname(dirname(__DIR__))) . '/Proxies');
		$config->setProxyNamespace('Proxies');
		$config->setEntityNamespaces(self::getEntityClasses());
		$config->setAutoGenerateProxyClasses(false);
		
		if (PartKeeprConfiguration::getOption("partkeepr.database.echo_sql_log", false) === true) {
			$logger = new \Doctrine\DBAL\Logging\EchoSQLLogger();
			$config->setSQLLogger($logger);
		}
		
		self::$entityManager = EntityManager::create($connectionOptions, $config);
	}