本文整理汇总了PHP中ConfigManager::bind方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigManager::bind方法的具体用法?PHP ConfigManager::bind怎么用?PHP ConfigManager::bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigManager
的用法示例。
在下文中一共展示了ConfigManager::bind方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initialize
protected function initialize()
{
$this->config = ConfigManager::bind();
// setting limit time
set_time_limit($this->config['webbot']['time_limit']);
$this->container = new Pimple();
// initializing persistence
$config = $this->config;
if ($config['general']['persistence']['use_database']) {
if (!isset($config['general']['persistence']['connections'])) {
throw new ConfigurationAccessException(101);
}
if (!is_array($config['general']['persistence']['connections']) || count($config['general']['persistence']['connections']) < 1) {
throw new ConfigurationAccessException(102);
}
$connections = $config['general']['persistence']['connections'];
// initializing ActiveRecord
ActiveRecord\Config::initialize(function ($cfg) use($connections, $config) {
$cfg->set_model_directory($config->getBaseDir() . '/' . $config['general']['persistence']['models_dir']);
$cfg->set_connections($connections);
// assigning as default conection the first one
$default_con_index = array_shift(array_keys($connections));
$cfg->set_default_connection($default_con_index);
});
}
$this->loadStartups();
}
示例2: initialize
/**
* For initial settings purposes
*/
protected function initialize($options)
{
$this->config = ConfigManager::bind();
$this->event_dispatcher = EventDispatcher::bind();
$this->primary_url_target = $options['url_target'];
$this->instance_identifier = $options['instance_identifier'];
$this->stop_condition_adquired = FALSE;
$this->event_dispatcher->connect('context.webbot_injected', array($this, 'ContextWebbotInjectedEventHandler'));
//$this->event_dispatcher->connect('webbot.stop_condition_adquired', array($this, 'WebbotStopConditionAdquiredEventHandler'));
}
示例3: initialize
public function initialize($options = array())
{
$this->config = ConfigManager::bind();
$this->event_dispatcher = EventDisPatcher::bind();
if (!isset($this->config['general']['logging']['time_format'])) {
throw new StratosException(106, array('parameter' => 'time_format'));
}
if (!isset($this->config['general']['logging']['default_format'])) {
throw new StratosException(106, array('parameter' => 'default_format'));
}
$this->time_format = $this->config['general']['logging']['time_format'];
$this->format = $this->config['general']['logging']['default_format'];
$this->event_dispatcher->connect('application.log', array($this, 'ApplicationLogEventHandler'));
}
示例4: initialize
protected function initialize()
{
$config = ConfigManager::bind();
$this->error_map_file = $config->getBaseDir() . '/' . $config['general']['error_handling']['error_map_file'];
if (!file_exists($this->error_map_file)) {
throw new MissingErrorMapFileException();
}
try {
$this->exception_messages_map = Yaml::parse($this->error_map_file);
} catch (ParseException $e) {
throw new ErrorMapFileFormatException();
}
if (!is_array($this->exception_messages_map)) {
throw new ErrorMapFileFormatException();
}
}
示例5: __construct
/**
* Constructs the base system exception.
*
* @param $previous Previous exception.
*/
public function __construct($code = -1, $message_params = array(), $previous = NULL)
{
$message = NULL;
if ($code !== -1) {
$params = array_keys($message_params);
foreach ($params as &$param) {
$param = '%' . $param . '%';
}
$escaped_params = array_combine($params, $message_params);
$message = strtr(ErrorMapper::mapExceptionCode($code), $escaped_params);
}
//$message = ($code !== -1)?call_user_func_array('sprintf', array_merge((array)ErrorMapper::mapExceptionCode($code), $message_params)):NULL;
parent::__construct($message, $code, $previous);
$config = ConfigManager::bind();
if ($config['general']['error_handling']['exception_logging']) {
$this->notifyException();
}
}
示例6: initialize
/**
* Initializes this logger.
*
* @param sfEventDispatcher $dispatcher A sfEventDispatcher instance
* @param array $options An array of options.
*/
public function initialize($options = array())
{
parent::initialize($options);
if (!isset($options['file_name'])) {
throw new StartupInitParamsExceptionException(get_class($this), 'file_name');
}
// if (!isset($options['u_file_name']))
// {
// throw new StartupInitParamsExceptionException(get_class($this), 'u_file_name');
// }
if (!isset($options['format'])) {
throw new StartupInitParamsExceptionException(get_class($this), 'format');
}
if (!isset($options['inner_format'])) {
throw new StartupInitParamsExceptionException(get_class($this), 'inner_format');
}
$this->format = $options['format'];
$this->inner_format = $options['inner_format'];
$this->file_name = ConfigManager::bind()->getBaseDir() . '/log/' . $options['file_name'];
$this->u_file_name = ConfigManager::bind()->getBaseDir() . '/log/' . $options['u_file_name'];
$this->event_dispatcher->connect('application.log_exception', array($this, 'ApplicationLogExceptionEventHandler'));
}
示例7: scrapHttp
/**
* This function returns a web page (HTML only) for a web page through
* the execution of a simple HTTP GET request.
* All HTTP redirects are automatically followed.
*
* @param string $target The target file (to download).
* @param string $referer The server referer variable.
* @param string $method Defines request HTTP method; HEAD, GET or POST
* @param string $data_array A keyed array, containing query string
* @param type $include_header
* @return type
*/
public static function scrapHttp($target, $referer, $method, $data_array, $include_header)
{
$config = ConfigManager::bind();
# Initialize PHP/CURL handle
$ch = curl_init();
# Prcess data, if presented
if (is_array($data_array)) {
# Convert data array into a query string (ie animal=dog&sport=baseball)
foreach ($data_array as $key => $value) {
if (strlen(trim($value)) > 0) {
$temp_string[] = $key . "=" . urlencode($value);
} else {
$temp_string[] = $key;
}
}
$query_string = join('&', $temp_string);
}
# HEAD method configuration
if ($method == self::HEAD_METHOD) {
curl_setopt($ch, CURLOPT_HEADER, TRUE);
// Http head
curl_setopt($ch, CURLOPT_NOBODY, TRUE);
// No Return body
} else {
# GET method configuration
if ($method == self::GET_METHOD) {
if (isset($query_string)) {
$target = $target . "?" . $query_string;
}
curl_setopt($ch, CURLOPT_HTTPGET, TRUE);
curl_setopt($ch, CURLOPT_POST, FALSE);
}
# POST method configuration
if ($method == self::POST_METHOD) {
if (isset($query_string)) {
curl_setopt($ch, CURLOPT_POSTFIELDS, $query_string);
}
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_HTTPGET, FALSE);
}
curl_setopt($ch, CURLOPT_HEADER, $include_header);
// Include head as needed
curl_setopt($ch, CURLOPT_NOBODY, FALSE);
// Return body
}
# Enable Proxy Use
if ($config['http_scrap']['use_proxy']) {
curl_setopt($ch, CURLOPT_PROXY, $config['http_scrap']['proxy']['ip']);
curl_setopt($ch, CURLOPT_PROXYPORT, $config['http_scrap']['proxy']['port']);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $config['http_scrap']['proxy']['user'] . ":" . $config['http_scrap']['proxy']['passwd']);
curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_ANYSAFE);
switch ($config['http_scrap']['proxy']['type']) {
case 'HTTP':
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
break;
case 'SOCKS4':
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
break;
case 'SOCKS5':
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
break;
default:
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
break;
}
}
curl_setopt($ch, CURLOPT_COOKIEJAR, $config['http_scrap']['cookie_file']);
// Cookie management.
curl_setopt($ch, CURLOPT_COOKIEFILE, $config['http_scrap']['cookie_file']);
curl_setopt($ch, CURLOPT_TIMEOUT, $config['http_scrap']['curl_timeout']);
// Timeout
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent = $config['http_scrap']['next_scrapping_agent']());
// Webbot name
curl_setopt($ch, CURLOPT_URL, $target);
// Target site
curl_setopt($ch, CURLOPT_REFERER, $referer);
// Referer value
curl_setopt($ch, CURLOPT_VERBOSE, $config['http_scrap']['verbose_scrapping']);
// Minimize logs
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
// No certificate
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $config['http_scrap']['accept_redirects']);
// Follow redirects
curl_setopt($ch, CURLOPT_MAXREDIRS, $config['http_scrap']['max_redirects']);
// Limit redirections to four
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
// Return in string
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
//.........这里部分代码省略.........
示例8: ContextWebbotInjectedEventHandler
/**
* Listens to context.webbot_injected events.
*
* @param sfEvent $event An sfEvent instance
*/
public function ContextWebbotInjectedEventHandler(Event $event)
{
$context = $event->getSender();
$this->file_name = ConfigManager::bind()->getBaseDir() . '/log/' . $context['webbot']->getFingerPrint() . '.log';
}