[GH-ISSUE #261] Get config variables in site module #223

Closed
opened 2026-02-25 21:34:29 +03:00 by kerem · 4 comments
Owner

Originally created by @Yamakasi on GitHub (Feb 9, 2018).
Original GitHub issue: https://github.com/cypht-org/cypht/issues/261

What is the best way to get the config-variables in the site module ?

I guess it need to be something like this:

private $config;
private $name;

/**
 * @param Hm_Config $config site config object
 */
public function __construct($config) {
    $this->name = $config->get('parameter', false);
    $this->config = $config;
}
Originally created by @Yamakasi on GitHub (Feb 9, 2018). Original GitHub issue: https://github.com/cypht-org/cypht/issues/261 What is the best way to get the config-variables in the site module ? I guess it need to be something like this: private $config; private $name; /** * @param Hm_Config $config site config object */ public function __construct($config) { $this->name = $config->get('parameter', false); $this->config = $config; }
kerem 2026-02-25 21:34:29 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@jasonmunro commented on GitHub (Feb 9, 2018):

You have not provided enough context to answer your question. The code you posted appears to be object properties and a constructor that takes the config object as an argument, however there is no class definition, and no information about where this object would be instantiated from, which is required to know if the config object is in scope to be used as an argument.

<!-- gh-comment-id:364490763 --> @jasonmunro commented on GitHub (Feb 9, 2018): You have not provided enough context to answer your question. The code you posted appears to be object properties and a constructor that takes the config object as an argument, however there is no class definition, and no information about where this object would be instantiated from, which is required to know if the config object is in scope to be used as an argument.
Author
Owner

@Yamakasi commented on GitHub (Feb 9, 2018):

It'sclearly not in scope so I'm trying to find some reference in the code and found that way in the code when the config needs to be loaded.

Normally, or mostly, you simply do a $foo = new Class() you want but because of all the Extending/Inheriting this is a little bit confusing what the best and preferred way is.

<!-- gh-comment-id:364497154 --> @Yamakasi commented on GitHub (Feb 9, 2018): It'sclearly not in scope so I'm trying to find some reference in the code and found that way in the code when the config needs to be loaded. Normally, or mostly, you simply do a $foo = new Class() you want but because of all the Extending/Inheriting this is a little bit confusing what the best and preferred way is.
Author
Owner

@jasonmunro commented on GitHub (Feb 9, 2018):

The config object is in scope inside the session class as $this->site_config, and from inside handler modules as $this->config. It is not possible to access it from a generic context. So if your class is extending the session or auth classes in the site module set, it's already present as $this->site_config.

<!-- gh-comment-id:364502091 --> @jasonmunro commented on GitHub (Feb 9, 2018): The config object is in scope inside the session class as $this->site_config, and from inside handler modules as $this->config. It is not possible to access it from a generic context. So if your class is extending the session or auth classes in the site module set, it's already present as $this->site_config.
Author
Owner

@Yamakasi commented on GitHub (Feb 9, 2018):

Yes fixed, it's already present indeed.

Thanks!

<!-- gh-comment-id:364575775 --> @Yamakasi commented on GitHub (Feb 9, 2018): Yes fixed, it's already present indeed. Thanks!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/cypht#223
No description provided.