示例#1
0
    protected function execute($arguments = array(), $options = array())
    {
        $configuration = ProjectConfiguration::getApplicationConfiguration($options['application'], $options['env'], true);
        $databaseManager = new sfDatabaseManager($this->configuration);
        $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
        $oBilling = new BillingClass();
        $oBilling->puserDailyPayment();
        $q = Doctrine_Query::create()->from('BalanceUser bu')->innerJoin('bu.User u')->where('bu.payable > 0')->andWhere('bu.was_paid = 0')->andWhere('u.active = 1')->andWhere('u.utype = "puser"')->groupBy('bu.id_user')->execute();
        $frontendRouting = new sfPatternRouting(new sfEventDispatcher());
        $config = new sfRoutingConfigHandler();
        $routes = $config->evaluate(array(sfConfig::get('sf_apps_dir') . '/frontend/config/routing.yml'));
        $frontendRouting->setRoutes($routes);
        foreach ($q as $rec) {
            if (!preg_match('/^R[0-9]{12}$/', $rec->getUser()->getAccountNumber())) {
                $email = $rec->getUser()->getEmail();
                $url = 'http://read2read.ru' . $frontendRouting->generate('profile_p_invoice', array(), true);
                $message = $this->getMailer()->compose(sfConfig::get('app_r2r_noreply_email'), $email, 'Read2Read - Напоминание о заполнении номера кошелька', <<<EOF
Вы зарегистрировались на сайте Read2Read.ru и на вашем счету имеется сумма положенная
к выплате в следующем платежном периоде. Для получения этих средств перейдите на сайт
Read2Read.ru и заполните номер кошелька. Ссылка для перехода: {$url}
EOF
);
                $this->getMailer()->send($message);
            }
        }
    }
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     // get routes
     $config = new sfRoutingConfigHandler();
     $routes = $config->evaluate($this->configuration->getConfigPaths('config/routing.yml'));
     $routing = new sfPatternRouting($this->dispatcher);
     $routing->setRoutes($routes);
     $this->dispatcher->notify(new sfEvent($routing, 'routing.load_configuration'));
     $this->routes = $routing->getRoutes();
     // display
     $arguments['name'] ? $this->outputRoute($arguments['application'], $arguments['name']) : $this->outputRoutes($arguments['application']);
 }
示例#3
0
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     // get routes
     $config = sfFactoryConfigHandler::getConfiguration($this->configuration->getConfigPaths('config/factories.yml'));
     $params = array_merge($config['routing']['param'], array('load_configuration' => false, 'logging' => false));
     $config = new sfRoutingConfigHandler();
     $routes = $config->evaluate($this->configuration->getConfigPaths('config/routing.yml'));
     $routing = new sfPatternRouting($this->dispatcher, null, $params);
     $routing->setRoutes($routes);
     $this->dispatcher->notify(new sfEvent($routing, 'routing.load_configuration'));
     $this->routes = $routing->getRoutes();
     // display
     $arguments['name'] ? $this->outputRoute($arguments['application'], $arguments['name']) : $this->outputRoutes($arguments['application']);
 }
 /**
  * Executes this configuration handler
  * 
  * @param   array   $configFiles    An array of absolute filesystem path to a configuration file
  * @return  string  Data to be written to a cache file
  * @see     sfRoutingConfigHandler::execute()
  */
 public function execute($configFiles)
 {
     $options = $this->getOptions();
     unset($options['cache']);
     $data = array();
     $modules = sfConfig::get('sf_enabled_modules');
     $dir = sfConfig::get('sf_app_module_dir');
     foreach ($this->parse($configFiles) as $name => $routeConfig) {
         $r = new ReflectionClass($routeConfig[0]);
         $routes = $r->newInstanceArgs($routeConfig[1]);
         if ($routes instanceof sfRouteCollection) {
             $collOptions = $routes->getOptions();
             if (isset($collOptions['module']) && !in_array($collOptions['module'], $modules) && !is_readable($dir . '/' . $collOptions['module'])) {
                 continue;
             }
         } else {
             $routes = array($name => $routes);
         }
         foreach (sfPatternRouting::flattenRoutes($routes) as $name => $route) {
             $route->setDefaultOptions($options);
             $data[] = sprintf('$this->routes[\'%s\'] = unserialize(\'%s\');', $name, serialize($route));
         }
     }
     return sprintf("<?php\n// auto-generated by dinRoutingConfigHandler\n// date: %s\n%s\n", date('Y/m/d H:i:s'), implode("\n", $data));
 }
 /**
  * @see sfPatternRouting
  */
 public function parse($url)
 {
     try {
         return parent::parse($url);
     } catch (sfError404Exception $e) {
         return false;
     }
 }
 public function __construct(\sfEventDispatcher $dispatcher, \sfCache $cache = null, $options = array())
 {
     parent::__construct($dispatcher, $cache, $options);
     if (!$this->options['context']['host'] && array_key_exists('cli_context', $this->options)) {
         // without host we are on cli
         foreach ($this->options['cli_context'] as $key => $value) {
             $this->options['context'][$key] = $value;
         }
     }
 }
示例#7
0
 /**
  * Disable cache when the request contain a "_" paremeter
  * This parameter is set randomly by jQuery to avoid browser cache
  * Cache it quickly leads to thousands cache entries
  */
 public function findRoute($url)
 {
     if ($this->cache && (strpos($this->options['context']['request_uri'], '?_=') || strpos($this->options['context']['request_uri'], '&_='))) {
         // remember the cache and disable it
         $cache = $this->cache;
         $this->cache = null;
         // get the result without cache
         $result = parent::findRoute($url);
         // restore the cache
         $this->cache = $cache;
         return $result;
     } else {
         return parent::findRoute($url);
     }
 }
 /**
  * Executes this configuration handler.
  *
  * @param array $configFiles An array of absolute filesystem path to a configuration file
  *
  * @return string Data to be written to a cache file
  *
  * @throws sfConfigurationException If a requested configuration file does not exist or is not readable
  * @throws sfParseException         If a requested configuration file is improperly formatted
  */
 public function execute($configFiles)
 {
     $options = $this->getOptions();
     unset($options['cache']);
     $data = array();
     foreach ($this->parse($configFiles) as $name => $routeConfig) {
         $r = new ReflectionClass($routeConfig[0]);
         $route = $r->newInstanceArgs($routeConfig[1]);
         $routes = $route instanceof sfRouteCollection ? $route : array($name => $route);
         foreach (sfPatternRouting::flattenRoutes($routes) as $name => $route) {
             $route->setDefaultOptions($options);
             $data[] = sprintf('$this->routes[\'%s\'] = %s;', $name, var_export(serialize($route), true));
         }
     }
     return sprintf("<?php\n" . "// auto-generated by sfRoutingConfigHandler\n" . "// date: %s\n%s\n", date('Y/m/d H:i:s'), implode("\n", $data));
 }
 /**
  * Executes this configuration handler.
  *
  * @param array $configFiles An array of absolute filesystem path to a configuration file
  *
  * @return string Data to be written to a cache file
  *
  * @throws sfConfigurationException If a requested configuration file does not exist or is not readable
  * @throws sfParseException         If a requested configuration file is improperly formatted
  */
 public function execute($configFiles)
 {
     $config = sfFactoryConfigHandler::getConfiguration(sfContext::getInstance()->getConfiguration()->getConfigPaths('config/factories.yml'));
     $options = $config['routing']['param'];
     unset($options['cache']);
     $data = array();
     foreach ($this->parse($configFiles) as $name => $routeConfig) {
         $r = new ReflectionClass($routeConfig[0]);
         $route = $r->newInstanceArgs($routeConfig[1]);
         $routes = $route instanceof sfRouteCollection ? $route : array($name => $route);
         foreach (sfPatternRouting::flattenRoutes($routes) as $name => $route) {
             $route->setDefaultOptions($options);
             $data[] = sprintf('$map[\'%s\'] = new %s(%s, %s, %s, %s);', $name, get_class($route), var_export($route->getPattern(), true), var_export($route->getDefaults(), true), var_export($route->getRequirements(), true), var_export($route->getOptions(), true));
             $data[] = sprintf('$map[\'%s\']->setCompiledData(%s);', $name, var_export($route->getCompiledData(), true));
         }
     }
     return sprintf("<?php\n" . "// auto-generated by sfRoutingConfigHandler\n" . "// date: %s\n\$map = array();\n%s\nreturn \$map;\n", date('Y/m/d H:i:s'), implode("\n", $data));
 }
示例#10
0
 public function parse($url)
 {
     $parameters = parent::parse($url);
     unset($parameters['_sf_route']);
     return $parameters;
 }
示例#11
0
 public static function retrieveAPIList($isWithI18n = true)
 {
     $result = array();
     $context = sfContext::getInstance();
     $config = new sfRoutingConfigHandler();
     $currentApp = sfConfig::get('sf_app');
     $i18n = $context->getI18n();
     sfConfig::set('sf_app', 'api');
     $routing = new sfPatternRouting($context->getEventDispatcher());
     $routing->setRoutes($config->evaluate($context->getConfiguration()->getConfigPaths('config/routing.yml')));
     sfConfig::set('sf_app', $currentApp);
     $context->getEventDispatcher()->notify(new sfEvent($routing, 'routing.load_configuration'));
     $routes = $routing->getRoutes();
     foreach ($routes as $route) {
         if ($route instanceof opAPIRouteInterface) {
             $caption = $route->getAPICaption();
             if ($isWithI18n) {
                 $caption = $i18n->__($caption, null, 'api');
             }
             $result[$route->getAPIName()] = $caption;
         }
     }
     return $result;
 }
 protected function getAppRouting($application)
 {
     if (isset($this->appRoutings[$application])) {
         return $this->appRoutings[$application];
     }
     $context = sfContext::getInstance();
     $configuration = $context->getConfiguration();
     $config = new opRoutingConfigHandler();
     $currentApp = sfConfig::get('sf_app');
     sfConfig::set('sf_app', $application);
     $configuration->setAppDir(sfConfig::get('sf_apps_dir') . DIRECTORY_SEPARATOR . $application);
     $settings = sfDefineEnvironmentConfigHandler::getConfiguration($configuration->getConfigPaths('config/settings.yml'));
     $isNoScriptName = !empty($settings['.settings']['no_script_name']);
     $options = $context->getRouting()->getOptions();
     $url = sfConfig::get('op_base_url');
     if ('http://example.com' !== $url) {
         $parts = parse_url($url);
         $parts['path'] = isset($parts['path']) ? $parts['path'] : '/';
         $parts['host'] = isset($parts['host']) ? $parts['host'] : '';
         $options['context'] = array('prefix' => $this->getAppScriptName($application, sfConfig::get('sf_environment'), $parts['path'], $isNoScriptName), 'host' => $parts['host']);
     }
     $routing = new sfPatternRouting($context->getEventDispatcher(), null, $options);
     $routing->setRoutes($config->evaluate($configuration->getConfigPaths('config/routing.yml')));
     $context->getEventDispatcher()->notify(new sfEvent($routing, 'routing.load_configuration'));
     sfConfig::set('sf_app', $currentApp);
     $configuration->setAppDir(sfConfig::get('sf_apps_dir') . DIRECTORY_SEPARATOR . $currentApp);
     $this->appRoutings[$application] = $routing;
     return $this->appRoutings[$application];
 }
 public function getDynamicRouteThatMatchesUrl($url)
 {
     return parent::getRouteThatMatchesUrl($url);
 }
 public function generate($name, $params = array(), $absolute = false)
 {
     return sfConfig::get('app_vkontakte_enable_append_get_params') ? parent::generate($name, $params, $absolute) . '?' . $_SERVER['QUERY_STRING'] : parent::generate($name, $params, $absolute);
 }
 protected function getAppRouting($application)
 {
     if (isset($this->appRoutings[$application])) {
         return $this->appRoutings[$application];
     }
     $context = sfContext::getInstance();
     $configuration = $context->getConfiguration();
     $config = new opRoutingConfigHandler();
     $currentApp = sfConfig::get('sf_app');
     sfConfig::set('sf_app', $application);
     $configuration->setAppDir(sfConfig::get('sf_apps_dir') . DIRECTORY_SEPARATOR . $application);
     $settings = sfDefineEnvironmentConfigHandler::getConfiguration($configuration->getConfigPaths('config/settings.yml'));
     $isNoScriptName = !empty($settings['.settings']['no_script_name']);
     $options = $context->getRouting()->getOptions();
     if ($options['context']['is_secure']) {
         $sslBaseUrls = sfConfig::get('op_ssl_base_url');
         $url = $sslBaseUrls[$application];
         $isDefault = 'https://example.com' === $url;
     } else {
         $url = sfConfig::get('op_base_url');
         $isDefault = 'http://example.com' === $url;
     }
     if (!$isDefault) {
         $parts = parse_url($url);
         $parts['path'] = isset($parts['path']) ? $parts['path'] : '';
         $options['context']['prefix'] = $this->getAppScriptName($application, sfConfig::get('sf_environment'), $parts['path'], $isNoScriptName);
         if (isset($parts['host'])) {
             $options['context']['host'] = $parts['host'];
             if (isset($parts['port'])) {
                 $options['context']['host'] .= ':' . $parts['port'];
             }
         }
     } else {
         $path = preg_replace('#/[^/]+\\.php$#', '', $options['context']['prefix']);
         $options['context']['prefix'] = $this->getAppScriptName($application, sfConfig::get('sf_environment'), $path, $isNoScriptName);
     }
     $routing = new sfPatternRouting($context->getEventDispatcher(), null, $options);
     $routing->setRoutes($config->evaluate($configuration->getConfigPaths('config/routing.yml')));
     $context->getEventDispatcher()->notify(new sfEvent($routing, 'routing.load_configuration'));
     sfConfig::set('sf_app', $currentApp);
     $configuration->setAppDir(sfConfig::get('sf_apps_dir') . DIRECTORY_SEPARATOR . $currentApp);
     $this->appRoutings[$application] = $routing;
     return $this->appRoutings[$application];
 }
示例#16
0
 protected function deriveFrontendRoute($parameters)
 {
     $authorization_key = $this->user->getEmailAuthorizationKey();
     $frontend_app_location = rtrim(ProjectConfiguration::getFrontendAppLocation(), '/');
     $frontendRouting = new sfPatternRouting(new sfEventDispatcher());
     $config = new sfRoutingConfigHandler();
     $routes = $config->evaluate(array(sfConfig::get('sf_apps_dir') . '/frontend/config/routing.yml'));
     $frontendRouting->setRoutes($routes);
     $frontend_route = $frontend_app_location . $frontendRouting->generate('sf_guard_verify', array('key' => $authorization_key));
     return $frontend_route;
 }