/**
  * Creates a new operation with from a given annotated php method.
  *
  * @param ReflectionAnnotatedMethod $method An annotated php method
  *
  * @return ckWsdlOperation An operation, which's input corresponds to the parameters and which's output
  *                         corresponds to the return value of the given php method.
  */
 public static function create(ReflectionAnnotatedMethod $method)
 {
     $name = $method->getAnnotation('WSMethod')->getName();
     $result = new ckWsdlOperation();
     $result->setName($name);
     $params = ckDocBlockParser::parseParameters($method->getDocComment());
     $return = ckDocBlockParser::parseReturn($method->getDocComment());
     $headers = $method->getAllAnnotations('WSHeader');
     $result->input = new ckWsdlMessage($name . 'Request');
     $result->output = new ckWsdlMessage($name . 'Response');
     foreach ($headers as $header) {
         $type = ckXsdType::get($header->type);
         $type->setName($header->name);
         ckXsdType::set($header->name, $type);
         ckXsdType::set($header->type, null);
         $result->input->addPart(new ckWsdlPart($header->name, $type, true));
         $result->output->addPart(new ckWsdlPart($header->name, $type, true));
     }
     foreach ($params as $param) {
         $type = ckXsdType::get($param['type']);
         $result->input->addPart(new ckWsdlPart($param['name'], $type));
     }
     if (!empty($return)) {
         $type = ckXsdType::get($return['type']);
         $result->output->addPart(new ckWsdlPart('result', $type));
     }
     return $result;
 }
 public function addMethod($name, ReflectionMethod $method)
 {
     if (!$this->getCheckEnablement() || ckDocBlockParser::hasDocTag($method->getDocComment(), self::ENABLEMENT_DOCTAG)) {
         $this->methods[$name] = $method;
         return true;
     } else {
         return false;
     }
 }
 public static function create($name)
 {
     $reflectClass = new ReflectionClass($name);
     $result = new ckXsdComplexType($name, ckXsdNamespace::get('tns'));
     foreach ($reflectClass->getProperties() as $property) {
         $type = ckDocBlockParser::parseProperty($property->getDocComment());
         if (!empty($type)) {
             $result->addElement(new ckXsdComplexTypeElement($property->getName(), ckXsdType::get($type['type'])));
         }
     }
     return $result;
 }
 /**
  * (non-PHPdoc)
  * @see strategy/ckAbstractPropertyStrategy#getProperties()
  */
 public function getProperties()
 {
     $properties = array();
     foreach ($this->getClass()->getProperties() as $property) {
         if (!$property->isPublic() || $property->isStatic()) {
             continue;
         }
         $type = ckDocBlockParser::parseProperty($property->getDocComment());
         if (isset($type['type'])) {
             $properties[] = array('name' => $property->getName(), 'type' => $type['type']);
         }
     }
     return $properties;
 }
 /**
  * (non-PHPdoc)
  * @see strategy/ckAbstractPropertyStrategy#getProperties()
  */
 public function getProperties()
 {
     $properties = array();
     foreach ($this->getClass()->getMethods() as $method) {
         if (!$method->isPublic() || $method->isStatic() || !$this->isGetterName($method->getName())) {
             continue;
         }
         $return = ckDocBlockParser::parseReturn($method->getDocComment());
         if (empty($return)) {
             continue;
         }
         $properties[] = array('name' => $this->getPropertyName($method->getName()), 'type' => $return['type']);
     }
     return $properties;
 }
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $app = $arguments['application'];
     $env = $options['environment'];
     $dbg = $options['debug'];
     $file = $arguments['name'];
     $url = $arguments['url'];
     $url = ckString::endsWith($url, '/') ? $url : $url . '/';
     $controller_name = $file . '.php';
     $controller_path = sprintf('%s/%s', sfConfig::get('sf_web_dir'), $controller_name);
     $this->getFilesystem()->remove($controller_path);
     $this->getFilesystem()->copy(sfConfig::get('sf_symfony_lib_dir') . self::CONTROLLER_TEMPLATE_PATH, $controller_path);
     $this->getFilesystem()->replaceTokens($controller_path, '##', '##', array('APP_NAME' => $app, 'ENVIRONMENT' => $env, 'IS_DEBUG' => $dbg ? 'true' : 'false'));
     $finder = sfFinder::type('directory')->name('*')->relative()->maxdepth(0);
     $gen = new ckWsdlGenerator($file, $url, $url . $controller_name);
     $gen->setCheckEnablement(true);
     foreach ($finder->in(sfConfig::get('sf_app_module_dir')) as $module_dir) {
         // proposed by Nicolas Martin to avoid problems with 'inited' modules
         if (!preg_match('/class(.*)Actions(.*)extends(.*)auto/', file_get_contents(sfConfig::get('sf_app_module_dir') . '/' . $module_dir . '/actions/actions.class.php')) && file_exists(sfConfig::get('sf_app_module_dir') . '/' . $module_dir . '/actions/actions.class.php')) {
             require_once sfConfig::get('sf_app_module_dir') . '/' . $module_dir . '/actions/actions.class.php';
             $class = new ReflectionClass($module_dir . 'Actions');
             $module_config = sfConfig::get('sf_app_module_dir') . '/' . $module_dir . '/config/module.yml';
             $this->getFilesystem()->mkdirs(dirname($module_config));
             if (!file_exists($module_config)) {
                 $this->getFilesystem()->touch($module_config);
             }
             $yml = sfYaml::load($module_config);
             if (!isset($yml[$env]) || !is_array($yml[$env])) {
                 $yml[$env] = array();
             }
             foreach ($class->getMethods() as $method) {
                 $name = $method->getName();
                 if (ckString::startsWith($name, 'execute') && strlen($name) > 7) {
                     $action = ckString::lcfirst(substr($name, 7));
                     $name = $module_dir . '_' . $action;
                     if (!$gen->addMethod($name, $method)) {
                         $yml[$env][$action] = array('enable' => false);
                         continue;
                     }
                     $yml[$env][$action] = array('enable' => true, 'parameter' => array(), 'result' => null, 'render' => false);
                     foreach (ckDocBlockParser::parseParameters($method->getDocComment()) as $param) {
                         $yml[$env][$action]['parameter'][] = $param['name'];
                     }
                 }
             }
             // only save if we added something to the configuration
             if (!empty($yml[$env])) {
                 file_put_contents($module_config, sfYaml::dump($yml));
             }
         }
     }
     $file = sprintf('%s/%s.wsdl', sfConfig::get('sf_web_dir'), $file);
     $gen->save($file);
     $this->logSection('file+', $file);
 }
 /**
  * @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);
 }