/** * Sets a callback, which should be used to create webservice method names for given php methods. * * @param callback $callback */ public static function setCreateMethodNameCallback($callback) { if (!is_callable($callback)) { throw new InvalidArgumentException(); } self::$createMethodNameCallback = $callback; }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { $databaseManager = new sfDatabaseManager($this->configuration); if ($this->isPropelPluginActive()) { $this->loadPropelPeerClasses(); } $app = $arguments['application']; $env = $options['environment']; $dbg = $options['enabledebug']; $file = $arguments['name']; $url = $arguments['url']; $this->buildControllerFile($file, $app, $env, $dbg); $gen = new ckWsdlGenerator(new ckWsdlGeneratorContext($file, $url, null, $env == self::DEFAULT_ENVIRONMENT)); WSMethod::setCreateMethodNameCallback(array($this, 'generateWSMethodName')); $handler_methods = array(); foreach ($this->getModules() as $module) { if ($this->loadModuleClassFile($module)) { $yml = $this->loadModuleConfigFile($module); if (!isset($yml[$env]) || !is_array($yml[$env])) { $yml[$env] = array(); } $class = new ReflectionAnnotatedClass($module . 'Actions'); foreach ($class->getMethods(ReflectionMethod::IS_PUBLIC) as $method) { try { extract($this->getModuleAndAction($method)); } catch (InvalidArgumentException $e) { continue; } if (!$gen->addMethod($method)) { continue; } $name = $method->getAnnotation('WSMethod')->getName(); $result = isset($yml[$env][$action]['result']) ? $yml[$env][$action]['result'] : array('class' => 'ckPropertyResultAdapter', 'param' => array('property' => 'result')); $yml[$env][$action] = array('parameter' => array(), 'result' => $result); $handler_methods[$name] = array('module' => $module, 'action' => $action, 'parameter' => array()); foreach (ckDocBlockParser::parseParameters($method->getDocComment()) as $param) { $yml[$env][$action]['parameter'][] = $handler_methods[$name]['parameter'][] = $param['name']; } } if (!empty($yml[$env])) { $this->saveModuleConfigFile($module, $yml); } } } $this->buildHandlerFile($file); $this->buildBaseHandlerFile($file, $handler_methods); $file = sprintf('%s/%s.wsdl', sfConfig::get('sf_web_dir'), $file); $gen->save($file); $this->logSection('file+', $file); }