本文整理汇总了PHP中Zend\Config\Factory::fromFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::fromFile方法的具体用法?PHP Factory::fromFile怎么用?PHP Factory::fromFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Config\Factory
的用法示例。
在下文中一共展示了Factory::fromFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAdapter
/**
* 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];
}
}
示例2: loadDbConfig
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;
}
示例3: __construct
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);
});
}
示例4: setUp
/**
* 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')));
}
示例5: testGetAdapterWithConfig
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));
*
*/
}
示例6: __construct
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);
}
示例7: update
/**
* Обновить запись.
* Метод 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;
}
示例8: __construct
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');
}
示例9: loadDefinitions
/**
* @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);
}
}
示例10: load
/**
*
* @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();
}
示例11: createService
/**
* 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;
}
示例12: setUp
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();
}
示例13: _validateJWT
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;
}
}
示例14: validate
/**
* @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;
}
示例15: testConfigurationCanConfigureCompiledDefinition
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'));
}