/**
  * Removes the header suffix from a given string, if it is present.
  *
  * @param string $name A name
  *
  * @return string The name without the header suffix
  *
  * @see HEADER_SUFFIX
  */
 protected function getSoapHeaderName($name)
 {
     $result = $name;
     if (ckString::endsWith($result, self::HEADER_SUFFIX)) {
         $result = substr($result, 0, -strlen(self::HEADER_SUFFIX));
     }
     return $result;
 }
 public function setPropertyValue($object, $property, $value)
 {
     if (is_array($value) && ckString::endsWith($property, 's')) {
         $method = 'add' . ckString::ucfirst(substr($property, 0, -1));
         if (!$this->getClass()->hasMethod($method)) {
             throw new InvalidArgumentException();
         }
         foreach ($value as $item) {
             call_user_func_array(array($object, $method), array($item));
         }
     } else {
         parent::setPropertyValue($object, $property, $value);
     }
 }
 /**
  * Checks wether the given type is an array type.
  *
  * @param string $name A type name
  *
  * @return boolean True, if the given type is an array type, false otherwise
  */
 public static function isArrayType($name)
 {
     return ckString::endsWith($name, self::ARRAY_SUFFIX);
 }
 /**
  * @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);
 }
 /**
  * Normalizes a given namespace uri, this means adding a slash at end if none is present.
  *
  * @param string $namespace A namespace uri
  *
  * @return string The normalized namespace uri
  */
 private function normalizeNamespaceUri($namespace)
 {
     return !ckString::endsWith($namespace, '/') ? $namespace . '/' : $namespace;
 }
 protected function isPluginActive($plugin)
 {
     foreach ($this->configuration->getPluginPaths() as $plugin_path) {
         if (ckString::endsWith($plugin_path, $plugin)) {
             return true;
         }
     }
     return false;
 }