/**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     // get configuration for the given route
     $config = new sfRoutingConfigHandler();
     $routes = $config->evaluate($this->configuration->getConfigPaths('config/routing.yml'));
     if (!isset($routes[$arguments['route']])) {
         throw new sfCommandException(sprintf('The route "%s" does not exist.', $arguments['route']));
     }
     $routeOptions = $routes[$arguments['route']]->getOptions();
     if (!$routes[$arguments['route']] instanceof sfPropelRouteCollection) {
         throw new sfCommandException(sprintf('The route "%s" is not a Propel collection route.', $arguments['route']));
     }
     $module = $routeOptions['module'];
     $model = $routeOptions['model'];
     // execute the propel:generate-module task
     $task = new sfPropelGenerateModuleTask($this->dispatcher, $this->formatter);
     $task->setCommandApplication($this->commandApplication);
     $taskOptions = array('--theme=' . $options['theme'], '--env=' . $options['env'], '--route-prefix=' . $routeOptions['name'], '--with-propel-route');
     if ($routeOptions['with_show']) {
         $taskOptions[] = '--with-show';
     }
     if ($options['non-verbose-templates']) {
         $taskOptions[] = '--non-verbose-templates';
     }
     if (!is_null($options['singular'])) {
         $taskOptions[] = '--singular=' . $options['singular'];
     }
     if (!is_null($options['plural'])) {
         $taskOptions[] = '--plural=' . $options['plural'];
     }
     $this->logSection('app', sprintf('Generating module "%s" for model "%s"', $module, $model));
     return $task->run(array($arguments['application'], $module, $model), $taskOptions);
 }
Esempio n. 2
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);
            }
        }
    }
 /**
  * Получить роутинг для указанного приложения
  *
  * @param  string $appName - Название приложения
  * @return sfPatternRouting
  */
 public function getAppRouting($appName)
 {
     if (!isset($this->appRouting[$appName])) {
         $this->appRouting[$appName] = new sfPatternRouting(new sfEventDispatcher());
         $config = new sfRoutingConfigHandler();
         $routes = $config->evaluate(array(sfConfig::get('sf_apps_dir') . "/{$appName}/config/routing.yml"));
         $this->appRouting[$appName]->setRoutes($routes);
     }
     return $this->appRouting[$appName];
 }
 public function getStatisticsRouting()
 {
     if (!$this->aStatisticsRouting) {
         $this->aStatisticsRouting = new sfPatternRouting(new sfEventDispatcher());
         $config = new sfRoutingConfigHandler();
         $routes = $config->evaluate(array(sfConfig::get('sf_apps_dir') . '/statistics/config/routing.yml'));
         $this->aStatisticsRouting->setRoutes($routes);
     }
     return $this->aStatisticsRouting;
 }
 public static function getPostMailAddress($route, $params = array())
 {
     $configuration = sfContext::getInstance()->getConfiguration();
     $configPath = sfConfig::get('sf_plugins_dir') . '/opCommunityWikiPlugin/apps/mobile_mail_frontend/config/routing.yml';
     $routing = new opMailRouting(new sfEventDispatcher());
     $config = new sfRoutingConfigHandler();
     $routes = $config->evaluate(array($configPath));
     $routing->setRoutes(array_merge(sfContext::getInstance()->getRouting()->getRoutes(), $routes));
     return $routing->generate($route, $params);
 }
 /**
  * @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']);
 }
Esempio n. 7
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']);
 }
 protected function parse($configFiles)
 {
     $result = parent::parse($configFiles);
     $name = 'symfony_default_routes';
     $options = array('name' => $name);
     $result[$name] = array('opSymfonyDefaultRouteCollection', array($options));
     return $result;
 }
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     // get configuration for the given route
     $config = new sfRoutingConfigHandler();
     $routes = $config->evaluate($this->configuration->getConfigPaths('config/routing.yml'));
     if (!isset($routes[$arguments['route']])) {
         throw new sfCommandException(sprintf('The route "%s" does not exist.', $arguments['route']));
     }
     $routeOptions = $routes[$arguments['route']]->getOptions();
     if (!$routes[$arguments['route']] instanceof sfDoctrineRouteCollection) {
         throw new sfCommandException(sprintf('The route "%s" is not a Doctrine collection route.', $arguments['route']));
     }
     $module = $routeOptions['module'];
     $model = $routeOptions['model'];
     // execute the doctrine:generate-module task
     $task = new sfDoctrineGenerateModuleTask($this->dispatcher, $this->formatter);
     $task->setCommandApplication($this->commandApplication);
     $task->setConfiguration($this->configuration);
     $this->logSection('app', sprintf('Generating module "%s" for model "%s"', $module, $model));
     return $task->run(array($arguments['application'], $module, $model), array('theme' => $options['theme'], 'route-prefix' => $routeOptions['name'], 'with-doctrine-route' => true, 'with-show' => $routeOptions['with_show'], 'non-verbose-templates' => $options['non-verbose-templates'], 'singular' => $options['singular'], 'plural' => $options['plural'], 'actions-base-class' => $options['actions-base-class']));
 }
 protected function parse($configFiles)
 {
     $routes = parent::parse($configFiles);
     $new_routes = array();
     foreach ($routes as $name => $route) {
         $name = $this->app . '.' . $name;
         $new_routes[$name] = $route;
         $new_routes[$name][1][2]['sw_app'] = $this->app;
         $new_routes[$name][1][2]['sw_host'] = $this->host;
     }
     return $new_routes;
 }
 /**
  * Returns a route instance for a given route name.
  *
  * @static
  * @param  string                 $routeName     Name of the route
  * @param  sfProjectConfiguration $configuration Optionally pass a project configuration (i.e. when called from a task)
  *
  * @return sfRoute
  */
 public static function getRoute($routeName, sfProjectConfiguration $configuration = null)
 {
     if (is_null($configuration)) {
         $configuration = sfProjectConfiguration::getActive();
     }
     $routing = sfRoutingConfigHandler::getConfiguration($configuration->getConfigPaths('config/routing.yml'));
     if (!array_key_exists($routeName, $routing)) {
         throw new sfImageTransformExtraPluginConfigurationException('Route "' . $routeName . '" could not be found!');
     }
     $route = $routing[$routeName];
     return new $route['class']($route['url'], $route['param'], $route['requirements'], $route['options']);
 }
Esempio n. 12
0
 /**
  * @see sfConfigHandler
  */
 public static function getConfiguration(array $configFiles)
 {
     // merge two arrays but put custom routes at the beginning
     // so that they are matched first
     $systemRoutes = self::getDmConfiguration();
     $userRoutes = parent::getConfiguration($configFiles);
     foreach ($userRoutes as $key => $value) {
         if (array_key_exists($key, $systemRoutes)) {
             $systemRoutes[$key] = $value;
         } else {
             $systemRoutes = array_reverse($systemRoutes, true);
             $systemRoutes[$key] = $value;
             $systemRoutes = array_reverse($systemRoutes, true);
         }
     }
     return $systemRoutes;
 }
 protected function getRouteFromName($name)
 {
     $config = new sfRoutingConfigHandler();
     $routes = $config->evaluate($this->configuration->getConfigPaths('config/routing.yml'));
     if (isset($routes[$name])) {
         return $routes[$name];
     }
     return false;
 }
 /**
  * Initialize routing
  *
  * @return sfRouting A sfRouting instance
  */
 protected function initializeRouting()
 {
     $config = $this->getFactoryConfiguration();
     $params = array_merge($config['routing']['param'], array('load_configuration' => false, 'logging' => false));
     $handler = new sfRoutingConfigHandler();
     $routes = $handler->evaluate($this->configuration->getConfigPaths('config/routing.yml'));
     $routing = new $config['routing']['class']($this->dispatcher, null, $params);
     $routing->setRoutes($routes);
     $this->dispatcher->notify(new sfEvent($routing, 'routing.load_configuration'));
     return $routing;
 }
 /**
  * @see sfConfigHandler
  */
 public static function getConfiguration(array $configFiles)
 {
     return array_merge(self::getDmConfiguration(), parent::getConfiguration($configFiles));
 }
Esempio n. 16
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;
 }
Esempio n. 17
0
function op_mail_to($route, $params = array(), $name = '', $options = array(), $default_value = array())
{
    $configuration = sfContext::getInstance()->getConfiguration();
    $configPath = '/mobile_mail_frontend/config/routing.yml';
    $files = array_merge(array(sfConfig::get('sf_apps_dir') . $configPath), $configuration->globEnablePlugin('/apps' . $configPath));
    $user = sfContext::getInstance()->getUser();
    if (sfConfig::get('op_is_mail_address_contain_hash') && $user->hasCredential('SNSMember')) {
        $params['hash'] = $user->getMember()->getMailAddressHash();
    }
    $routing = new opMailRouting(new sfEventDispatcher());
    $config = new sfRoutingConfigHandler();
    $routes = $config->evaluate($files);
    $routing->setRoutes(array_merge(sfContext::getInstance()->getRouting()->getRoutes(), $routes));
    return mail_to($routing->generate($route, $params), $name, $options, $default_value);
}
 /**
  * @see sfRoutingConfigHandler
  */
 protected function parse($configFiles)
 {
     return array_map(array($this, 'filterRoute'), parent::parse($configFiles));
 }
Esempio n. 19
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;
 }