Magento - Use config value inside module config file - magento

Is it possible to use a config value inside another modules config file - in much the same way you can grab a config file using getStoreConfig().
If so, how?

No. All the (static) config XML files are read from the filesystem before any config values are retrieved from the database.

Yes, it's possible. You can get any value from any of your xml files (all of them - config.xml, admin.xml etc are merged into one) like this:
$config = Mage::getConfig()->getNode('global/sales/order/statuses');
Zend_Debug::dump($config);

Related

google deployment manager, can you import files in jinja template that you call directly with --template?

https://cloud.google.com/deployment-manager/docs/configuration/templates/create-basic-template
I can deploy a template directly like this: gcloud deployment-manager deployments create a-single-vm --template vm_template.jinja
But what if that template depends on other files that need to be imported? If using a --config file you can define import in that file and call the template as a resource. But you cant pass parameter/properties to a config file. I want to call a template directly to pass --properties via the command line but that template also needs to import other files.
EDIT: What I needed was a top level jinja template instead of a config. My confusion was that you cant use imports in a jinja template without a schema file- it was failing and I thought it wasnt supported. So the solution was just swap out the config with a jinja template (with schema file) and then I can use --properies
Maybe you can try importing the dependent files into your config file as follows:
imports:
- path: vm-template.jinja
- path: vm-template-2.jinja
# In the resources section below, the properties of the resources are replaced
# with the names of the templates.
resources:
- name: vm-1
type: vm-template.jinja
- name: vm-2
type: vm-template-2.jinja
and Set Arbitrary Metadata insito create a special variable that you can pass and might use in other applications outside of Deployment Manager:
properties:
size:
type: integer
default: 2
description: Number of Mongo Slaves
variable-x: ultra-secret-sauce
More info about gcloud deployment-manager deployments create optional flags and example can be found here.
More info about passing properties using a Schema can be found here
Hope it helps

Loading multiple config file from spring cloud config server

Hey I got to know how to check properties in config server i.e. http://{Config server URL}:{Port}/{ServiceID}/{Profile}
Right now I am facing a problem where I've to read multiple properties file from cloud config server. Ex: Right now I've to read properties file(huge file) from a single property file i.e. employee.properties
I don't want huge list of properties file in single folder. like
employee-dev.properties
employee-dit.properties
employee-sit.properties
employee-uat.properties
employee-preprod.properties
employee-prod.properties
customers-dev.properties
customers-dit.properties
customers-sit.properties
customers-uat.properties
customers-preprod.properties
customers-prod.properties
.
.
.
and soo on.
My requirement is I need to maitain a list of properties file and config server will provide me these values. like :
**{env}/employee.properties**
**{env}/customers.properties**
Here env could be any environment like dit, sit, prod etc.
Hope I'll get answer here.
If you don't want to have all properties files in an only folder, so you need to add this configuration on config server properties file.
1. Match all options
spring.cloud.config.server.native.searchLocations = [classpath:/, classpath:/config, classpath:/config/{application}, classpath:/config/{application}/{profile}]
2. Match only /application-name/application-name-profile.properties
spring.cloud.config.server.native.searchLocations = classpath:config/{application}
Then you'll have matched based on application name folder for example.
resources/config/application-name/application-name-properties.

How does Chef include files generated on runtime as a template source

Using Chef recipe, I am first generating a .erb file dynamically based on inputs from a CSV file and then I want to use that .erb file as a template source. But unfortunately the changes made (in .erb file) are not considered while the recipe is converging the resources. I also tried to use lazy evaluation but not able to figure out how to use it for the template source.
Quoting the template documentation:
source Ruby Types: String, Array
The location of a template file. By default, the chef-client looks for
a template file in the /templates directory of a cookbook. When the
local property is set to true, use to specify the path to a template
on the local node. This property may also be used to distribute
specific files to specific platforms. See “File Specificity” below for
more information. Default value: the name of the resource block. See
“Syntax” section above for more information.)
And
local
Ruby Types: TrueClass, FalseClass
Load a template from a local path. By default, the chef-client loads
templates from a cookbook’s /templates directory. When this property
is set to true, use the source property to specify the path to a
template on the local node. Default value: false.
so what you can do is:
# generate the local .erb file let's say source.erb
template "/path/to/file" do
source "/path/to/source.erb"
local true
end
Your question sounds like and XY problem, reading a csv file to make a template sounds counter-productive and could probably be done with attributes and taking advantage of the variable attribute of template resource.
Assuming you know how to capture the values from the CSV file as a local variable in the recipe.
Examples:
csv_hostname
csv_fqdn
Here is what you do to create a template with lazy loading attributes. The following example creates a config file.
example.erb file
# Dynamically generated by awesome Chef so don't alter by hand.
HOSTNAME=<% #host_name %>
FQDN=<% #fqdn %>
recipe.rb file
template 'path\to\example.config' do
source 'example.erb'
variables(
lazy {
:host_name => csv_hostname,
:fqdn => csv_fqdn
})
end
If you need it to run at compile time, add the action to the block.
template 'xxx' do
# blah blah
end.run_action(:create)

Laravel location of created files

I'm attempting to modify a text file stored on the server using Larvel's File::put(filelocation,filecontents)
but I can't figure out what location this is relative to on the server. If I have a file "somestuff.json" within my LaravelApp/public folder, what location string do I use for a parameter to File::put() ?
File name for File::methods() is not relative you have to give the full file path:
File::put('/var/www/LaravelApp/public/somestuff.json', $filecontents);
But Laravel has some helpers to help you with this:
File::put(public_path().'/somestuff.json', $filecontents);
Also:
base_path(); // the base of your application LaravelApp/
app_path(); // Your LaravelApp/app
They are all in the file vendor/laravel/framework/src/Illuminate/Support/helpers.php.

How can I change config file path in Codeigniter?

I use Codeigniter framework , and you know when I try to load a config file then use it
I do something like that :
$this->load->config('myconfig', TRUE);
myconfig.php file is located inside application folder ( application/config/myconfig.php)
and use it like this :
$this->config->item('get_item', 'myconfig')
My question is : how can I change the location of myconfig file and use it properly ?
I want to put the config file(s) in out folder like this :
mysite -> system(folder)
mysite -> user_guide(folder)
mysite -> myConfigFiles(folder)
mysite -> myConfigFiles(folder) / myconfig.php
I need to do something like this :
$this->load->config(base_url.'myConfigFiles/myconfig', TRUE);
any help ?
Yes - it is possible to do this. The loader will accept ../../relative/paths. You can use a path relative from the default config directory (an absolute path will not work).
So let's say you have this structure (had a hard time following your description):
mysite
application
config <-- default directory
system
myConfigFiles
myconfig.php
You can just do this:
$this->load->config('../../myConfigFiles/myconfig', TRUE);
This works for pretty much everything - views, libraries, models, etc.
Note that with the introduction of the ENVIRONMENT constant in version 2.0.1, you can automatically check for config files within the config directory in another directory that matches the name of the current environment. This is really intended to be a convenience method for loading different files depending on if you are in production or development. I'm not 100% sure what your goals are, but this additional knowledge may also help you achieve them, or it may be totally irrelevant.
Really not sure WHY you would want to do this (and I wouldn't recommend it), but since all config files are is regular PHP files you can put a config file in the standard location that loads your extra config files. As an example:
mysite -> application -> config -> myconfigloader.php
then in myconfigloader.php put this:
<?php
require_once(APPPATH.'../myConfigFiles/myconfig.php');
So once you do
$this->load->config('myconfigloader', TRUE);
It will load everything in your myconfig.php file. Let me know if that works for you.

Resources