/**
  * Overwrite execute to override the default config file.
  *
  * If an alternative configuration file is provided we override the 'config'
  * element in the Dependency Injection Container with a new instance. This
  * new instance uses the phpdoc.tpl.xml as base configuration and applies
  * the given configuration on top of it.
  *
  * Also, upon providing a custom configuration file, is the current working
  * directory set to the directory containing the configuration file so that
  * all relative paths for directory and file selections (and more) is based
  * on that location.
  *
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $config_file = $input->getOption('config');
     if ($config_file && $config_file !== 'none') {
         $config_file = realpath($config_file);
         // all relative paths mentioned in the configuration file should
         // be relative to the configuration file.
         // This means that if we provide an alternate configuration file
         // that we need to go to that directory first so that paths can be
         // calculated from there.
         chdir(dirname($config_file));
     }
     if ($config_file) {
         $container = $this->getContainer();
         $container['config'] = $container->share(function () use($config_file) {
             $files = array(__DIR__ . '/../../../data/phpdoc.tpl.xml');
             if ($config_file !== 'none') {
                 $files[] = $config_file;
             }
             return \Zend\Config\Factory::fromFiles($files, true);
         });
         if (isset($container['config']->logging)) {
             $level = (string) $container['config']->logging->level;
             // null means the default is used
             $logPath = isset($container['config']->logging->paths->default) ? (string) $container['config']->logging->paths->default : null;
             // null means the default is used
             $debugPath = isset($container['config']->logging->paths->errors) ? (string) $container['config']->logging->paths->errors : null;
             $container->configureLogger($container['monolog'], $level, $logPath, $debugPath);
         }
     }
 }
Beispiel #2
0
 /**
  * Conexão padrão
  * @return \Zend\Db\Adapter\Adapter
  */
 public function getAdapter($adapterName = null)
 {
     self::$resultSetPrototype = new ResultSet();
     $config = ZendConfigFile::fromFile(GLOBAL_CONFIG_PATH . 'global.php');
     if (empty($adapterName)) {
         foreach ($config['db']['adapters'] as $keyAdapter => $valueAdapter) {
             if ($valueAdapter['default']) {
                 $adapterName = $keyAdapter;
             }
         }
     }
     if (isset($this->connAdapter[$adapterName]) and !empty($this->connAdapter[$adapterName]) and $this->connAdapter[$adapterName]->getDriver()->getConnection()->isConnected()) {
         return $this->connAdapter[$adapterName];
     } else {
         /* Verifica se tem multiplos adaptadores de conexão e instancia os mesmos */
         if (isset($config['db']['adapters']) and !empty($config['db']['adapters'])) {
             foreach ($config['db']['adapters'] as $key => $value) {
                 ${$key} = new \Zend\Db\Adapter\Adapter($value);
                 ${$key}->getDriver()->getConnection()->connect();
                 $this->connAdapter[$key] = ${$key};
             }
         } else {
             throw new \Exception('Dados de configuração não encontrados!');
         }
         return $this->connAdapter[$adapterName];
     }
 }
Beispiel #3
0
 private function loadDbConfig()
 {
     $dbConfigLocal = \Zend\Config\Factory::fromFile(__DIR__ . '/../../../../../config/autoload/local.php')['db'];
     $dbConfigGlobal = \Zend\Config\Factory::fromFile(__DIR__ . '/../../../../../config/autoload/global.php')['db'];
     $dbConfig = array_merge($dbConfigLocal, $dbConfigGlobal);
     return $dbConfig;
 }
 /**
  * Process the command
  *
  * @return integer
  */
 public function processCommandTask()
 {
     // load autoload configuration from project
     $config = ConfigFactory::fromFiles(glob($this->params->projectConfigDir . '/autoload/{,*.}{global,development,local}.php', GLOB_BRACE));
     // check for db config
     if (empty($config) || !isset($config['db'])) {
         $this->console->writeFailLine('task_crud_check_db_connection_no_config');
         return 1;
     }
     // create db adapter instance
     try {
         $dbAdapter = new Adapter($config['db']);
     } catch (InvalidArgumentException $e) {
         $this->console->writeFailLine('task_crud_check_db_connection_config_inconsistent');
         return 1;
     }
     // connect to database
     try {
         $connection = $dbAdapter->getDriver()->getConnection()->connect();
     } catch (RuntimeException $e) {
         $this->console->writeFailLine('task_crud_check_db_connection_failed');
         return 1;
     }
     $this->params->dbAdapter = $dbAdapter;
     return 0;
 }
 public function __construct()
 {
     /* Acesso o arquivo de configuração global */
     $this->globalConfig = \Zend\Config\Factory::fromFile(GLOBAL_CONFIG_PATH . 'global.php');
     $this->getViewModel();
     $this->globalRoute = $this->getSessionAdapter('globalRoute');
     $this->module = $this->sessionAdapter->moduleName;
     $this->controller = $this->sessionAdapter->controllerName;
     $this->action = $this->sessionAdapter->actionName;
     //$this->image = $this->globalConfig['image'];
     $this->assign('linkDefault', LINK_DEFAULT);
     $this->assign('linkModule', LINK_DEFAULT . $this->module . '/');
     $this->assign('linkController', LINK_DEFAULT . $this->module . '/' . strtolower($this->controller));
     $this->assign('linkAction', LINK_DEFAULT . $this->module . '/' . strtolower($this->controller) . '/' . strtolower($this->action));
     $this->assign('urlDefault', URL_DEFAULT);
     $this->assign('urlUpload', URL_UPLOAD);
     $this->assign('urlStatic', URL_STATIC);
     $this->assign('publicPath', PUBLIC_PATH);
     $this->assign('baseModule', $this->module);
     $this->assign('baseController', $this->controller);
     $this->assign('baseAction', $this->action);
     $this->assign('langDefault', $this->sessionAdapter->language);
     /* Tratamento das variáveis padrões de modulo, controlador e action */
     $eventManager = $this->getEventManager();
     $eventManager->attach(\Zend\Mvc\MvcEvent::EVENT_DISPATCH, function (\Zend\Mvc\MvcEvent $e) {
         $this->processHelpers($e);
     });
 }
 /**
  * Prepares the environment before running a test
  *
  */
 protected function setUp()
 {
     $cwd = __DIR__;
     // read navigation config
     $this->_files = $cwd . '/_files';
     $config = ConfigFactory::fromFile($this->_files . '/navigation.xml', true);
     // setup containers from config
     $this->_nav1 = new Navigation($config->get('nav_test1'));
     $this->_nav2 = new Navigation($config->get('nav_test2'));
     // setup view
     $view = new PhpRenderer();
     $view->resolver()->addPath($cwd . '/_files/mvc/views');
     // create helper
     $this->_helper = new $this->_helperName();
     $this->_helper->setView($view);
     // set nav1 in helper as default
     $this->_helper->setContainer($this->_nav1);
     // setup service manager
     $smConfig = array('modules' => array(), 'module_listener_options' => array('config_cache_enabled' => false, 'cache_dir' => 'data/cache', 'module_paths' => array(), 'extra_config' => array('service_manager' => array('factories' => array('Config' => function () use($config) {
         return array('navigation' => array('default' => $config->get('nav_test1')));
     })))));
     $sm = $this->serviceManager = new ServiceManager(new ServiceManagerConfig());
     $sm->setService('ApplicationConfig', $smConfig);
     $sm->get('ModuleManager')->loadModules();
     $sm->get('Application')->bootstrap();
     $sm->setFactory('Navigation', 'Zend\\Navigation\\Service\\DefaultNavigationFactory');
     $sm->setService('nav1', $this->_nav1);
     $sm->setService('nav2', $this->_nav2);
     $app = $this->serviceManager->get('Application');
     $app->getMvcEvent()->setRouteMatch(new RouteMatch(array('controller' => 'post', 'action' => 'view', 'id' => '1337')));
 }
Beispiel #7
0
 public function testGetAdapterWithConfig()
 {
     $httptest = new HttpClientTest();
     // Nirvanix adapter
     $nirvanixConfig = ConfigFactory::fromFile(realpath(dirname(__FILE__) . '/_files/config/nirvanix.ini'), true);
     $nirvanixConfig = $nirvanixConfig->toArray();
     $nirvanixConfig[Nirvanix::HTTP_ADAPTER] = $httptest;
     $doc = new \DOMDocument('1.0', 'utf-8');
     $root = $doc->createElement('Response');
     $responseCode = $doc->createElement('ResponseCode', 0);
     $sessionTok = $doc->createElement('SessionToken', '54592180-7060-4D4B-BC74-2566F4B2F943');
     $root->appendChild($responseCode);
     $root->appendChild($sessionTok);
     $doc->appendChild($root);
     $body = $doc->saveXML();
     $resp = HttpResponse::fromString("HTTP/1.1 200 OK\nContent-type: text/xml;charset=UTF-8\nDate: 0\n\n" . $body);
     $httptest->setResponse($resp);
     $nirvanixAdapter = Factory::getAdapter($nirvanixConfig);
     $this->assertEquals('Zend\\Cloud\\StorageService\\Adapter\\Nirvanix', get_class($nirvanixAdapter));
     // S3 adapter
     $s3Config = ConfigFactory::fromFile(realpath(dirname(__FILE__) . '/_files/config/s3.ini'), true);
     $s3Adapter = Factory::getAdapter($s3Config);
     $this->assertEquals('Zend\\Cloud\\StorageService\\Adapter\\S3', get_class($s3Adapter));
     // file system adapter
     $fileSystemConfig = ConfigFactory::fromFile(realpath(dirname(__FILE__) . '/_files/config/filesystem.ini'), true);
     $fileSystemAdapter = Factory::getAdapter($fileSystemConfig);
     $this->assertEquals('Zend\\Cloud\\StorageService\\Adapter\\FileSystem', get_class($fileSystemAdapter));
     // Azure adapter
     /*
             $azureConfig    = ConfigFactory::fromFile(realpath(dirname(__FILE__) . '/_files/config/windowsazure.ini'), true);
             $azureConfig    = $azureConfig->toArray();
             $azureContainer = $azureConfig[WindowsAzure::CONTAINER];
             $azureConfig[WindowsAzure::HTTP_ADAPTER] = $httptest;
             $q = "?";
     
             $doc = new \DOMDocument('1.0', 'utf-8');
             $root = $doc->createElement('EnumerationResults');
             $acctName = $doc->createAttribute('AccountName');
             $acctName->value = 'http://myaccount.blob.core.windows.net';
             $root->appendChild($acctName);
             $maxResults     = $doc->createElement('MaxResults', 1);
             $containers     = $doc->createElement('Containers');
             $container      = $doc->createElement('Container');
             $containerName  = $doc->createElement('Name', $azureContainer);
             $container->appendChild($containerName);
             $containers->appendChild($container);
             $root->appendChild($maxResults);
             $root->appendChild($containers);
             $doc->appendChild($root);
             $body = $doc->saveXML();
     
             $resp = HttpResponse::fromString("HTTP/1.1 200 OK\nContent-type: text/xml;charset=UTF-8\nx-ms-request-id: 0\n\n".$body);
     
             $httptest->setResponse($resp);
             $azureAdapter = Factory::getAdapter($azureConfig);
             $this->assertEquals('Zend\Cloud\StorageService\Adapter\WindowsAzure', get_class($azureAdapter));
     *
     */
 }
 public function getSlimInstance()
 {
     $configPaths = sprintf('%s/config/{,*.}{global,%s,secret}.php', APPLICATION_PATH, SLIM_MODE);
     $config = ConfigFactory::fromFiles(glob($configPaths, GLOB_BRACE));
     $app = new Slim($config);
     // TODO: Include app.php file
     return $app;
 }
Beispiel #9
0
 public function __construct($moduleName, $controllerName = null, $actionName = null)
 {
     $this->moduleName = $moduleName;
     $this->controllerName = $controllerName;
     $this->actionName = $actionName;
     $themeConfigPath = MODULES_PATH . ucfirst($moduleName) . DS . 'config' . DS . 'theme.config.ini';
     $this->loadConfig = \Zend\Config\Factory::fromFile($themeConfigPath);
 }
Beispiel #10
0
 /**
  * Обновить запись.
  * Метод PUT для RESTfull.
  */
 public function update($id, $data)
 {
     $result = new JsonModel();
     $lincutConfigPath = $_SERVER["DOCUMENT_ROOT"] . "/lincut.config.php";
     // Создаем в памяти новый конфигурационный файл с новыми настройками
     $lincutConfigNew = new Config(array(), true);
     $lincutConfigNew->lincut = array();
     $lincutConfigNew->lincut->wkhtmltopdf = array();
     $lincutConfigNew->lincut->restriction = array();
     if (array_key_exists("wkhtmltopdf_path", $data)) {
         $lincutConfigNew->lincut->wkhtmltopdf->path = $data["wkhtmltopdf_path"];
     }
     if (array_key_exists("restriction_mode", $data)) {
         $lincutConfigNew->lincut->restriction->mode = $data["restriction_mode"];
     }
     if (array_key_exists("restriction_up_time", $data)) {
         $lincutConfigNew->lincut->restriction->uptime = $data["restriction_up_time"];
     }
     if (array_key_exists("restriction_up_count", $data)) {
         $lincutConfigNew->lincut->restriction->upcount = $data["restriction_up_count"];
     }
     if (array_key_exists("saw", $data)) {
         $lincutConfigNew->lincut->saw = $data["saw"];
     }
     if (array_key_exists("waste", $data)) {
         $lincutConfigNew->lincut->waste = $data["waste"];
     }
     $dbwcad = "db/wcad";
     $lincutConfigNew->db = array();
     $lincutConfigNew->db->adapters = array();
     $lincutConfigNew->db->adapters->{$dbwcad} = array();
     if (array_key_exists("db_wcad_servername", $data)) {
         $lincutConfigNew->db->adapters->{$dbwcad}->servername = $data["db_wcad_servername"];
     }
     if (array_key_exists("db_wcad_database", $data)) {
         $lincutConfigNew->db->adapters->{$dbwcad}->database = $data["db_wcad_database"];
     }
     if (array_key_exists("db_wcad_username", $data)) {
         $lincutConfigNew->db->adapters->{$dbwcad}->username = $data["db_wcad_username"];
     }
     if (array_key_exists("db_wcad_password", $data)) {
         $lincutConfigNew->db->adapters->{$dbwcad}->password = $data["db_wcad_password"];
     }
     // Открываем существующий файл настроек, если он имеется в наличии
     $lincutConfig = array();
     if (is_file($lincutConfigPath)) {
         $lincutConfig = \Zend\Config\Factory::fromFile($lincutConfigPath);
     }
     $lincutConfig = new Config($lincutConfig, true);
     $lincutConfig->merge($lincutConfigNew);
     // Сохраняем настройки
     $writer = new \Zend\Config\Writer\PhpArray();
     $writer->toFile($lincutConfigPath, $lincutConfig);
     // Возвращаем результат операции
     $result->success = true;
     return $result;
 }
Beispiel #11
0
 public function __construct()
 {
     $config = Factory::fromFile('config/config.php', true);
     $db_info = $config->get($config->get('ACTIVE_DB'));
     $this->dbhost = $db_info->get('host');
     $this->dbuser = $db_info->get('user');
     $this->dbpass = $db_info->get('password');
     $this->dbname = $db_info->get('name');
 }
 /**
  * @return array
  */
 private function loadDefinitions()
 {
     $xmlTransferDefinitions = $this->finder->getXmlTransferDefinitionFiles();
     foreach ($xmlTransferDefinitions as $xmlTransferDefinition) {
         $bundle = $this->getBundleFromPathName($xmlTransferDefinition->getFilename());
         $containingBundle = $this->getContainingBundleFromPathName($xmlTransferDefinition->getPathname());
         $definition = Factory::fromFile($xmlTransferDefinition->getPathname(), true)->toArray();
         $this->addDefinition($definition, $bundle, $containingBundle);
     }
 }
Beispiel #13
0
 /**
  * 
  * @param string $filename
  * @return array
  */
 public static function load($filename)
 {
     $config = new ZendConfig(Factory::fromFile($filename), true);
     $variables = isset($config[self::VARIABLES_KEY]) ? $config[self::VARIABLES_KEY]->toArray() : array();
     $processorChain = new ProcessorChain();
     $processorChain->add(new Constant(false, 'const(', ')'));
     $processorChain->add(new Env('env(', ')'));
     $processorChain->add(new CallableProperty($variables));
     $processorChain->add(new Interpolator($variables));
     return $processorChain->process($config)->toArray();
 }
Beispiel #14
0
 protected function setUp()
 {
     $this->select = new Sql\Select();
     $this->select->from('test');
     $this->testCollection = range(1, 101);
     $this->paginator = new Paginator\Paginator(new Paginator\Adapter\ArrayAdapter($this->testCollection));
     $this->config = Config\Factory::fromFile(__DIR__ . '/_files/config.xml', true);
     $this->cache = CacheFactory::adapterFactory('memory', array('memory_limit' => 0));
     Paginator\Paginator::setCache($this->cache);
     $this->_restorePaginatorDefaults();
 }
 /**
  * Creates service.
  * 
  * @param ServiceLocatorInterface $serviceLocator
  * @return \Zend\ModuleManager\ModuleManager
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $applicationConfig = $serviceLocator->get('ApplicationConfig');
     $moduleManager = parent::createService($serviceLocator);
     if (empty($applicationConfig['tayo_module_file']) === false) {
         $extraModules = Factory::fromFile($applicationConfig['tayo_module_file']);
         $modules = $moduleManager->getModules();
         $moduleManager->setModules(array_merge($modules, $extraModules));
     }
     return $moduleManager;
 }
 /**
  * Overwrite execute to override the default config file.
  *
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  *
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $config_file = $input->getOption('config');
     if ($config_file) {
         $this->container['config'] = $this->container->share(function () use($config_file) {
             $files = array(__DIR__ . '/../../../data/phpdoc.tpl.xml');
             if ($config_file !== 'none') {
                 $files[] = $config_file;
             }
             return \Zend\Config\Factory::fromFiles($files, true);
         });
     }
 }
Beispiel #17
0
 private static function _validateJWT($jwt)
 {
     try {
         $config = Factory::fromFile('config/config.php', true);
         $secretKey = base64_decode($config->get('JWT')->get('key'));
         $signingAlgorithm = $config->get('JWT')->get('algorithm');
         $token = JWT::decode($jwt, $secretKey, array($signingAlgorithm));
         /* perhaps checks required to see if token->data even exists*/
         self::$uid = $token->data->uid;
         self::$tid = $token->data->tid;
         return $token->data->scope;
     } catch (Exception $e) {
         throw $e;
     }
 }
Beispiel #18
0
 protected function setUp()
 {
     if (!extension_loaded('pdo_sqlite')) {
         $this->markTestSkipped('Pdo_Sqlite extension is not loaded');
     }
     $this->_adapter = new \Zend\Db\Adapter\Pdo\Sqlite(array('dbname' => __DIR__ . '/_files/test.sqlite'));
     $this->_query = $this->_adapter->select()->from('test');
     $this->_testCollection = range(1, 101);
     $this->_paginator = Paginator\Paginator::factory($this->_testCollection);
     $this->_config = Config\Factory::fromFile(__DIR__ . '/_files/config.xml', true);
     $this->_cache = CacheFactory::factory(array('adapter' => array('name' => 'filesystem', 'options' => array('ttl' => 3600, 'cache_dir' => $this->_getTmpDir())), 'plugins' => array(array('name' => 'serializer', 'options' => array('serializer' => 'php_serialize')))));
     $this->_cache->clear(CacheAdapter::MATCH_ALL);
     Paginator\Paginator::setCache($this->_cache);
     $this->_restorePaginatorDefaults();
 }
Beispiel #19
0
 public function testGetAdapterWithConfig()
 {
     // SQS adapter
     $sqsConfig = ConfigFactory::fromFile(realpath(dirname(__FILE__) . '/_files/config/sqs.ini'), true);
     $sqsAdapter = Factory::getAdapter($sqsConfig);
     $this->assertEquals('Zend\\Cloud\\QueueService\\Adapter\\Sqs', get_class($sqsAdapter));
     // Zend queue adapter
     $zqConfig = ConfigFactory::fromFile(realpath(dirname(__FILE__) . '/_files/config/zendqueue.ini'), true);
     $zq = Factory::getAdapter($zqConfig);
     $this->assertEquals('Zend\\Cloud\\QueueService\\Adapter\\ZendQueue', get_class($zq));
     // Azure adapter
     //$azureConfig = ConfigFactory::fromFile(realpath(dirname(__FILE__) . '/_files/config/windowsazure.ini'), true);
     //$azureAdapter = Factory::getAdapter($azureConfig);
     //$this->assertEquals('Zend\Cloud\QueueService\Adapter\WindowsAzure', get_class($azureAdapter));
 }
Beispiel #20
0
 public function testConfigurationCanConfigureCompiledDefinition()
 {
     $config = ConfigFactory::fromFile(__DIR__ . '/_files/sample.php', true);
     $config = new Configuration($config->di);
     $di = new Di();
     $di->configure($config);
     $definition = $di->definitions()->getDefinitionByType('Zend\\Di\\Definition\\ArrayDefinition');
     $this->assertInstanceOf('Zend\\Di\\Definition\\ArrayDefinition', $definition);
     $this->assertTrue($di->definitions()->hasClass('My\\DbAdapter'));
     $this->assertTrue($di->definitions()->hasClass('My\\EntityA'));
     $this->assertTrue($di->definitions()->hasClass('My\\Mapper'));
     $this->assertTrue($di->definitions()->hasClass('My\\RepositoryA'));
     $this->assertTrue($di->definitions()->hasClass('My\\RepositoryB'));
     $this->assertFalse($di->definitions()->hasClass('My\\Foo'));
 }
Beispiel #21
0
 protected function setUp()
 {
     if (!extension_loaded('pdo_sqlite')) {
         $this->markTestSkipped('Pdo_Sqlite extension is not loaded');
     }
     $this->_adapter = new \Zend\Db\Adapter\Pdo\Sqlite(array('dbname' => __DIR__ . '/_files/test.sqlite'));
     $this->_query = $this->_adapter->select()->from('test');
     $this->_testCollection = range(1, 101);
     $this->_paginator = Paginator\Paginator::factory($this->_testCollection);
     $this->_config = Config\Factory::fromFile(__DIR__ . '/_files/config.xml', true);
     $this->_cache = CacheFactory::adapterFactory('memory', array('memory_limit' => 0));
     $this->_cache->clear(CacheAdapter::MATCH_ALL);
     Paginator\Paginator::setCache($this->_cache);
     $this->_restorePaginatorDefaults();
 }
Beispiel #22
0
 /**
  * @param array $options
  *
  * @return bool
  */
 public function validate(array $options)
 {
     $files = $this->finder->getXmlTransferDefinitionFiles();
     $result = true;
     foreach ($files as $key => $file) {
         if ($options['bundle'] && strpos($file, '/Shared/' . $options['bundle'] . '/Transfer/') === false) {
             continue;
         }
         $definition = Factory::fromFile($file->getPathname(), true)->toArray();
         $definition = $this->normalize($definition);
         $bundle = $this->getBundleFromPathName($file->getFilename());
         $result = $result & $this->validateDefinition($bundle, $definition, $options);
     }
     return (bool) $result;
 }
Beispiel #23
0
 protected function setUp()
 {
     if (!extension_loaded('pdo_sqlite')) {
         $this->markTestSkipped('Pdo_Sqlite extension is not loaded');
     }
     $this->_adapter = new DbAdapter\Adapter(array('driver' => 'Pdo_Sqlite', 'database' => __DIR__ . '/_files/test.sqlite'));
     $this->_query = new Sql\Select();
     $this->_query->from('test');
     $this->_testCollection = range(1, 101);
     $this->_paginator = Paginator\Paginator::factory($this->_testCollection);
     $this->_config = Config\Factory::fromFile(__DIR__ . '/_files/config.xml', true);
     $this->_cache = CacheFactory::adapterFactory('memory', array('memory_limit' => 0));
     Paginator\Paginator::setCache($this->_cache);
     $this->_restorePaginatorDefaults();
 }
Beispiel #24
0
 private function _validateJWT($jwt, $endpoint)
 {
     try {
         $config = Factory::fromFile('config/config.php', true);
         $secretKey = base64_decode($config->get('JWT')->get('key'));
         $signingAlgorithm = base64_decode($config->get('JWT')->get('algorithm'));
         $token = JWT::decode($jwt, $secretKey, array('HS512'));
         /* Only available scope is Stomper. Expand from this point to create other Scopes */
         /* Create scope class that handles checks of token as well as possible scopes */
         $this->uid = $token->data->uid;
         $this->tid = $token->data->tid;
         return $token->data->scope == "Stomper";
     } catch (Exception $e) {
         return false;
     }
 }
 /**
  * @param string|\Zend\Config\Config|array $config
  * @return array|null|\Zend\Config\Config
  * @throws \Zend\Navigation\Exception\InvalidArgumentException
  */
 protected function getPagesFromConfig($config = null)
 {
     if (is_string($config)) {
         if (file_exists($config)) {
             $config = Config\Factory::fromFile($config);
         } else {
             throw new Exception\InvalidArgumentException(sprintf('Config was a string but file "%s" does not exist', $config));
         }
     } elseif ($config instanceof Config\Config) {
         $config = $config->toArray();
     } elseif (!is_array($config)) {
         throw new Exception\InvalidArgumentException('
             Invalid input, expected array, filename, or Zend\\Config object');
     }
     return $config;
 }
 /**
  * @throws \ErrorException
  *
  * @return array
  */
 public function getNavigation()
 {
     try {
         $navigationDefinition = Factory::fromFile($this->rootNavigationFile, true);
     } catch (\Exception $e) {
         $navigationDefinition = new Config([]);
     }
     foreach ($this->navigationSchemaFinder->getSchemaFiles() as $moduleNavigationFile) {
         if (!file_exists($moduleNavigationFile->getPathname())) {
             throw new ErrorException('Navigation-File does not exist: ' . $moduleNavigationFile);
         }
         $configFromFile = Factory::fromFile($moduleNavigationFile->getPathname(), true);
         $navigationDefinition->merge($configFromFile);
     }
     return $navigationDefinition->toArray();
 }
 public function testConfigurationCanConfigureBuilderDefinitionFromIni()
 {
     $this->markTestIncomplete('Builder not updated to new DI yet');
     $ini = ConfigFactory::fromFile(__DIR__ . '/_files/sample.ini', true)->get('section-b');
     $config = new Configuration($ini->di);
     $di = new Di($config);
     $definition = $di->getDefinition();
     $this->assertTrue($definition->hasClass('My\\DbAdapter'));
     $this->assertEquals('__construct', $definition->getInstantiator('My\\DbAdapter'));
     $this->assertEquals(array('username' => null, 'password' => null), $definition->getInjectionMethodParameters('My\\DbAdapter', '__construct'));
     $this->assertTrue($definition->hasClass('My\\Mapper'));
     $this->assertEquals('__construct', $definition->getInstantiator('My\\Mapper'));
     $this->assertEquals(array('dbAdapter' => 'My\\DbAdapter'), $definition->getInjectionMethodParameters('My\\Mapper', '__construct'));
     $this->assertTrue($definition->hasClass('My\\Repository'));
     $this->assertEquals('__construct', $definition->getInstantiator('My\\Repository'));
     $this->assertEquals(array('mapper' => 'My\\Mapper'), $definition->getInjectionMethodParameters('My\\Repository', '__construct'));
 }
 public function testBuilderCanBuildFromArray()
 {
     $ini = ConfigFactory::fromFile(__DIR__ . '/../_files/sample.ini');
     $iniAsArray = $ini['section-b'];
     $definitionArray = $iniAsArray['di']['definitions'][1];
     unset($definitionArray['class']);
     $definition = new BuilderDefinition();
     $definition->createClassesFromArray($definitionArray);
     $this->assertTrue($definition->hasClass('My\\DbAdapter'));
     $this->assertEquals('__construct', $definition->getInstantiator('My\\DbAdapter'));
     $this->assertEquals(array('My\\DbAdapter::__construct:0' => array('username', null, true, null), 'My\\DbAdapter::__construct:1' => array('password', null, true, null)), $definition->getMethodParameters('My\\DbAdapter', '__construct'));
     $this->assertTrue($definition->hasClass('My\\Mapper'));
     $this->assertEquals('__construct', $definition->getInstantiator('My\\Mapper'));
     $this->assertEquals(array('My\\Mapper::__construct:0' => array('dbAdapter', 'My\\DbAdapter', true, null)), $definition->getMethodParameters('My\\Mapper', '__construct'));
     $this->assertTrue($definition->hasClass('My\\Repository'));
     $this->assertEquals('__construct', $definition->getInstantiator('My\\Repository'));
     $this->assertEquals(array('My\\Repository::__construct:0' => array('mapper', 'My\\Mapper', true, null)), $definition->getMethodParameters('My\\Repository', '__construct'));
 }
Beispiel #29
0
 /**
  * Prepares the environment before running a test
  *
  */
 protected function setUp()
 {
     $cwd = __DIR__;
     // read navigation config
     $this->_files = $cwd . '/_files';
     $config = ConfigFactory::fromFile($this->_files . '/navigation.xml', true);
     // setup containers from config
     $this->_nav1 = new Navigation($config->get('nav_test1'));
     $this->_nav2 = new Navigation($config->get('nav_test2'));
     // setup view
     $view = new PhpRenderer();
     $view->resolver()->addPath($cwd . '/_files/mvc/views');
     // create helper
     $this->_helper = new $this->_helperName();
     $this->_helper->setView($view);
     // set nav1 in helper as default
     $this->_helper->setContainer($this->_nav1);
 }
 /**
  * Retrieve the config of sphinxsearch node
  *
  * @param string|null $file
  * @return Config
  */
 protected function getConfig($file = null)
 {
     // Config
     $appConfig = $this->getServiceLocator()->get('Config');
     if (!isset($appConfig['sphinxsearch'])) {
         throw new \InvalidArgumentException('Config not found with name: "sphinxsearch"');
     } else {
         $config = new Config($appConfig['sphinxsearch'], true);
         // defaults
         if (!is_null($file)) {
             $fileConfig = Factory::fromFile($file, true);
             if (!isset($fileConfig['sphinxsearch'])) {
                 throw new \InvalidArgumentException('Config not found with name: "sphinxsearch"');
             }
             $config->merge($fileConfig['sphinxsearch']);
         }
     }
     return $config;
 }