Access config in Model

58 views
Skip to first unread message

sach...@tekdi.net

unread,
Mar 18, 2014, 5:55:11 AM3/18/14
to joomla-dev...@googlegroups.com
Hello Everyone,

I'm new in Joomla framework. In Joomla Framework I want to access config file in the model file. 

I have tried it by following ways, but I'm not able to access it. 

1. $this->getApplication()->config->get();
2. $this->getContainer()->config->get();

And one more question is, how to access getApplication(function in Model file?

Michael Babker

unread,
Mar 18, 2014, 12:59:41 PM3/18/14
to joomla-dev...@googlegroups.com
You would need to pass in the config data when you instantiate your model class.  There isn't a getApplication() method in our models nor is it recommended your model has access to your DI container.  You could do this by passing a Registry object in with your config data attached to it.
--
Framework source code: https://github.com/joomla/joomla-framework
Visit http://developer.joomla.org for more information about developing with Joomla!
---
You received this message because you are subscribed to the Google Groups "Joomla! Framework Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-frame...@googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-framework.


--
- Michael

Please pardon any errors, this message was sent from my iPhone.

piotr_cz

unread,
Mar 18, 2014, 3:15:38 PM3/18/14
to joomla-dev...@googlegroups.com
I think you can pass required configuration options to the model from the Controller.
It should have access to config trough the Container and it's initializing new models, so



On Tuesday, March 18, 2014 5:59:41 PM UTC+1, Michael Babker wrote:
You would need to pass in the config data when you instantiate your model class.  There isn't a getApplication() method in our models nor is it recommended your model has access to your DI container.  You could do this by passing a Registry object in with your config data attached to it.

On Tuesday, March 18, 2014, <sach...@tekdi.net> wrote:
Hello Everyone,

I'm new in Joomla framework. In Joomla Framework I want to access config file in the model file. 

I have tried it by following ways, but I'm not able to access it. 

1. $this->getApplication()->config->get();
2. $this->getContainer()->config->get();

And one more question is, how to access getApplication(function in Model file?

--
Framework source code: https://github.com/joomla/joomla-framework
Visit http://developer.joomla.org for more information about developing with Joomla!
---
You received this message because you are subscribed to the Google Groups "Joomla! Framework Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-framework+unsub...@googlegroups.com.

Ganesh Kumar

unread,
Oct 24, 2014, 4:35:11 PM10/24/14
to joomla-dev...@googlegroups.com
Try
$this->getApplication()->getConfig()->get();
Reply all
Reply to author
Forward
0 new messages