protected function initialize()
 {
     $config = $this->environment->getConfig();
     $logger = null;
     $uploads = wp_upload_dir();
     if (!is_writable($uploads['basedir'])) {
         $this->alerts[] = sprintf('<div class="error">
                 <p>You need to make your "%s" directory writable.</p>
             </div>', $uploads['basedir']);
         $config->set('uploads_rw', false);
     }
     /* Create the plugin directories if they are does not exists yet. */
     $this->initFilesystem();
     /* Initialize cache null-adapter by default */
     $cacheAdapter = new Rsc_Cache_Dummy();
     /* Initialize the log system first. */
     if (null !== ($logDir = $config->get('plugin_log', null))) {
         if (is_dir($logDir) && is_writable($logDir)) {
             $logger = new Rsc_Logger($logDir);
             $this->environment->setLogger($logger);
         }
     }
     /* If it's a production environment and cache directory is OK */
     if ($config->isEnvironment(Rsc_Environment::ENV_PRODUCTION) && null !== ($cacheDir = $config->get('plugin_cache', null))) {
         if (is_dir($cacheDir) && is_writable($cacheDir)) {
             $cacheAdapter = new Rsc_Cache_Filesystem($cacheDir);
         } else {
             if ($logger) {
                 $logger->error('Cache directory "{dir}" is not writable or does not exists.', array('dir' => realpath($cacheDir)));
             }
         }
     }
     $this->environment->setCacheAdapter($cacheAdapter);
 }