Ejemplo n.º 1
0
 protected final function initialize()
 {
     parent::initialize();
     $this->container = new Pimple();
     $config_parsed = Yaml::parse($this->getConfigDir() . "/" . self::CONFIG_FILE_NAME);
     foreach ($config_parsed as $section => &$section_config) {
         if ($section === "http_scrap") {
             $section_config['next_scrapping_agent'] = function () use(&$section_config) {
                 // si existe entradas en el arreglo agents
                 if (isset($section_config['agents']) && count($section_config['agents'] > 0)) {
                     // si agent-swapping = TRUE
                     if ($section_config['agent_swapping']) {
                         // retorno uno aleatorio
                         $r = mt_rand(0, (int) count($section_config['agents']) - 1);
                         return $section_config['agents'][$r];
                     }
                     // sino el primero es el default
                     return $section_config['agents'][0];
                 }
                 // sino devuelve la entrada ultradefaul
                 return "WEB-BOT";
             };
         }
         $this->container[$section] = $section_config;
         $this->read_only_entries[] = $section;
     }
 }
Ejemplo n.º 2
0
 protected function initialize()
 {
     parent::initialize();
     $this->base_dir = realpath(__DIR__ . '/../..');
 }