public function play() { $this->_bootstrap(); $servicesDir = StringCommon::replaceKeyWords($this->_config["app"]["services_dir"]); $loader = new YamlFileLoader($this->_container, new FileLocator($servicesDir)); $this->loadFiles($loader); }
public function __construct($config) { if (isset($config["doctrine"])) { $dbParams = $config["doctrine"]["db_params"]; $paths = StringCommon::replaceKeyWords($config["doctrine"]["entity_paths"]); $isDevMode = $config["doctrine"]["is_dev_mode"]; $proxyDir = StringCommon::replaceKeyWords($config["doctrine"]["proxy_dir"]); $proxyNamespace = $config["doctrine"]["proxy_namespace"]; $applicationMode = Game::getInstance()->getApplicationMode(); if ($applicationMode == Game::DEVELOPMENT_MODE) { $cache = new \Doctrine\Common\Cache\ArrayCache(); } else { $cache = new \Doctrine\Common\Cache\ApcCache(); } $doctrineConfig = new Configuration(); $doctrineConfig->setMetadataCacheImpl($cache); $driverImpl = $doctrineConfig->newDefaultAnnotationDriver($paths); $doctrineConfig->setMetadataDriverImpl($driverImpl); $doctrineConfig->setQueryCacheImpl($cache); $doctrineConfig->setProxyDir($proxyDir); $doctrineConfig->setProxyNamespace($proxyNamespace); if ($applicationMode == Game::DEVELOPMENT_MODE) { $doctrineConfig->setAutoGenerateProxyClasses(true); } else { $doctrineConfig->setAutoGenerateProxyClasses(false); } $entityManager = EntityManager::create($dbParams, $doctrineConfig); Game::getInstance()->getContainer()->set("entity_manager", $entityManager); } else { throw new \RuntimeException("You need add Doctrine config in your res/config.yml"); } }
protected function routing() { $routesDir = StringCommon::replaceKeyWords($this->_config["router"]["routes_dir"]); $routesFile = $this->_config["router"]["routes_file"]; $loader = new YamlFileLoader(new FileLocator($routesDir)); $loader->load($routesFile); $context = new RequestContext(); $context->fromRequest(Request::createFromGlobals()); //$matcher = new UrlMatcher($collection, $context); $router = new Router($loader, $routesFile); $this->action($router, $context); }
<?php use Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper; use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper; use Likedimion\Tools\Helper\LikedimionCommandHelper; use Symfony\Component\Console\Helper\DialogHelper; /** * Created by PhpStorm. * User: maksim * Date: 30.11.13 * Time: 22:40 */ require __DIR__ . "/../index.php"; $cli = new \Symfony\Component\Console\Application('Likedimion CLI', \Likedimion\Game::getInstance()->getVersion()); $entityManager = \Likedimion\Game::getInstance()->getContainer()->get("entity_manager"); $config = \Likedimion\Game::getInstance()->getConfig(); $translationsHelper = new \Likedimion\Tools\Helper\TranslationHelper(); $translationsHelper->setLocale(\Likedimion\Common\StringCommon::replaceKeyWords($config["app"]["locale"])); $translationsHelper->load(); $helperSet = \Doctrine\ORM\Tools\Console\ConsoleRunner::createHelperSet($entityManager); $helperSet->set(new DialogHelper(), 'dialog'); $helperSet->set($translationsHelper, 'translations'); $helperSet->set(new LikedimionCommandHelper(), "helpers"); $cli->setHelperSet($helperSet); $cli->addCommands(array(new \Doctrine\DBAL\Migrations\Tools\Console\Command\DiffCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\ExecuteCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\MigrateCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\StatusCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\VersionCommand(), new \Likedimion\Tools\Command\AccountRegistrationCommand(), new \Likedimion\Tools\Command\AuthorisationCommand(), new \Likedimion\Tools\Command\PlayerCreateCommand(), new \Likedimion\Tools\Command\LoadDefaultDataCommand())); \Doctrine\ORM\Tools\Console\ConsoleRunner::addCommands($cli); $cli->run();