Example #1
0
 /**
  * loadConfiguration
  *
  * @param \Windwalker\Registry\Registry $config
  *
  * @return  void
  */
 protected function loadConfiguration($config)
 {
     $file = $this->get('project.path.root') . '/.vaseman/config.yml';
     if (is_file($file)) {
         $config->loadFile($file, 'yaml');
     }
 }
Example #2
0
 /**
  * Load configuration files.
  *
  * @param   Registry  $config  The config registry object.
  *
  * @throws  \RuntimeException
  *
  * @return  void
  */
 public static function loadConfiguration(Registry $config)
 {
     $config->loadFile($file = WINDWALKER_ETC . '/config.yml', 'yaml');
     $secret = WINDWALKER_ETC . '/secret.yml';
     if (is_file($secret)) {
         $config->loadFile($secret, 'yaml');
     }
 }
Example #3
0
 /**
  * loadConfiguration
  *
  * @param Registry $config
  *
  * @throws  \RuntimeException
  * @return  void
  */
 public static function loadConfiguration(Registry $config)
 {
     $file = WINDWALKER_ETC . '/config.yml';
     if (!is_file($file)) {
         exit('Please copy config.dist.yml to config.yml');
     }
     $config->loadFile($file, 'yaml');
 }
 /**
  * Get routing config.
  *
  * @param string $option The component option name.
  * @param string $type   The routing file type.
  *
  * @return  mixed
  */
 public static function getRouting($option, $type = self::TYPE_YAML)
 {
     if (self::$routing) {
         return self::$routing;
     }
     $path = PathHelper::getSite($option);
     $fileType = $type == static::TYPE_YAML ? 'yml' : $type;
     $data = new Registry();
     $data->loadFile($path . '/routing.' . $fileType, $type);
     return self::$routing = $data->toArray();
 }
Example #5
0
 /**
  * Method to render the view.
  *
  * @return  string  The rendered view.
  *
  * @throws  \RuntimeException
  */
 public function render()
 {
     if ($this->data instanceof Registry) {
         return $this->data->toString('json', array('options' => $this->options, 'depth' => $this->depth));
     }
     if (version_compare(PHP_VERSION, '5.5', '<')) {
         return json_encode($this->data, $this->options);
     } else {
         return json_encode($this->data, $this->options, $this->depth);
     }
 }
Example #6
0
 /**
  * prepareSystemPath
  *
  * @param Registry $config
  *
  * @return  void
  */
 public static function prepareSystemPath(Registry $config)
 {
     $config['path.root'] = WINDWALKER_ROOT;
     $config['path.bin'] = WINDWALKER_BIN;
     $config['path.cache'] = WINDWALKER_CACHE;
     $config['path.etc'] = WINDWALKER_ETC;
     $config['path.logs'] = WINDWALKER_LOGS;
     $config['path.resources'] = WINDWALKER_RESOURCES;
     $config['path.source'] = WINDWALKER_SOURCE;
     $config['path.temp'] = WINDWALKER_TEMP;
     $config['path.vendor'] = WINDWALKER_VENDOR;
     $config['path.public'] = WINDWALKER_PUBLIC;
     $config['path.migrations'] = WINDWALKER_MIGRATIONS;
     $config['path.seeders'] = WINDWALKER_SEEDERS;
     $config['path.languages'] = WINDWALKER_LANGUAGES;
     switch ($config['mode']) {
         case 'test':
             $root = WINDWALKER_ROOT;
             break;
         default:
             $env = new Environment();
             $root = $env->server->getWorkingDirectory();
             $root = $root ?: WINDWALKER_ROOT;
             break;
     }
     $data = $config->get('outer_project') ? $root . '/.vaseman' : $root;
     $config['path.templates'] = $data . '/layouts';
     $config->set('project.path.root', $root);
     $config->set('project.path.data', $data);
     $config->set('project.path.entries', WINDWALKER_ROOT . '/entries');
     $config->set('project.path.layouts', WINDWALKER_ROOT . '/layouts');
 }
Example #7
0
 /**
  * Method to test flatten().
  *
  * @return void
  *
  * @covers Windwalker\Registry\Registry::toOneDimension
  */
 public function flatten()
 {
     $flatted = $this->instance->flatten();
     $this->assertEquals($flatted['pos1.sunflower'], 'sakura');
     $flatted = $this->instance->flatten('/');
     $this->assertEquals($flatted['pos1/sunflower'], 'sakura');
 }
 /**
  * Render view.
  *
  * @return string|void
  */
 public function doRender()
 {
     // Init some API objects
     // ================================================================================
     $container = $this->getContainer();
     $input = $container->get('input');
     $config = new Registry($this->config);
     // Set E_ALL for debugging
     error_reporting($config->get('error_reporting', 0));
     $elfinder_path = WINDWALKER . '/src/Elfinder/Connect/';
     include_once $elfinder_path . 'elFinderConnector.class.php';
     include_once $elfinder_path . 'elFinder.class.php';
     include_once $elfinder_path . 'elFinderVolumeDriver.class.php';
     /**
      * Simple function to demonstrate how to control file access using "accessControl" callback.
      * This method will disable accessing files/folders starting from '.' (dot)
      *
      * @param  string $attr attribute name (read|write|locked|hidden)
      * @param  string $path file path relative to volume root directory started with directory separator
      *
      * @return bool|null
      */
     function access($attr, $path)
     {
         // If file/folder begins with '.' (dot). Set read+write to false, other (locked+hidden) set to true
         if (strpos(basename($path), '.') === 0) {
             return !($attr == 'read' || $attr == 'write');
         } else {
             return null;
         }
     }
     // Get Some Request
     $root = $input->getPath('root', '/');
     $start_path = $input->getPath('start_path', '/');
     $this->createFolder($root);
     $this->createFolder($root . '/' . $start_path);
     $opts = array('roots' => array(array('driver' => 'LocalFileSystem', 'path' => JPath::clean(JPATH_ROOT . '/' . $root, '/'), 'startPath' => JPath::clean(JPATH_ROOT . '/' . $root . '/' . $start_path . '/'), 'URL' => JPath::clean(JURI::root(true) . '/' . $root . '/' . $start_path, '/'), 'tmbPath' => JPath::clean(JPATH_ROOT . '/cache/windwalker-finder-thumb'), 'tmbURL' => JURI::root(true) . '/cache/windwalker-finder-thumb', 'tmp' => JPath::clean(JPATH_ROOT . '/tmp/windwalker-finder-temp'), 'accessControl' => 'access', 'uploadDeny' => array('text/x-php'), 'disabled' => array('archive', 'extract', 'rename', 'mkfile'), 'quarantine' => JPATH_ROOT . '/tmp/.quarantine')));
     $opts = (array) $config->get('option') ?: $opts;
     foreach ($opts['roots'] as $driver) {
         include_once $elfinder_path . 'elFinderVolume' . $driver['driver'] . '.class.php';
     }
     // Run elFinder
     $connector = new elFinderConnector(new elFinder($opts));
     $connector->run();
     exit;
 }
Example #9
0
 /**
  * onBeforeRenderFiles
  *
  * @param Event $event
  *
  * @return  void
  */
 public function onBeforeRenderFiles(Event $event)
 {
     $this->data = array();
     $files = new \DirectoryIterator(__DIR__ . '/../../resources');
     $resources = new PriorityQueue();
     $menus = new PriorityQueue();
     /** @var \SplFileInfo $file */
     foreach ($files as $file) {
         if ($file->isDir()) {
             continue;
         }
         $data = new Registry();
         $data->loadFile($file->getPathname(), 'yaml');
         $resName = $file->getBasename('.yml');
         list($priority, $resName) = explode('-', $resName, 2);
         $data['alias'] = $resName;
         $resources->insert($data->toArray(), PHP_INT_MAX - $priority);
         $menus->insert(array('title' => $data['title'], 'alias' => $resName), PHP_INT_MAX - $priority);
     }
     // Store in cache
     $this->data['menus'] = $menus->toArray();
     foreach ($resources as $data) {
         $this->data['resources'][$data['alias']] = $data;
     }
     // Auto create pages
     $categoryFolder = new \SplFileInfo(__DIR__ . '/../../entries/type');
     if (is_dir($categoryFolder->getPathname())) {
         Folder::delete($categoryFolder->getPathname());
     }
     Folder::create($categoryFolder->getPathname());
     foreach ($this->data['resources'] as $catName => &$category) {
         File::copy(__DIR__ . '/../../layouts/tmpl/category.twig', __DIR__ . '/../../entries/type/' . $catName . '.twig');
         // Auto create items page
         $itemFolder = new \SplFileInfo(__DIR__ . '/../../entries/type/' . $catName);
         if (is_dir($itemFolder->getPathname())) {
             Folder::delete($itemFolder->getPathname());
         }
         Folder::create($itemFolder->getPathname());
         foreach ($category['data'] as $itemAlias => &$item) {
             File::copy(__DIR__ . '/../../layouts/tmpl/item.twig', __DIR__ . '/../../entries/type/' . $catName . '/' . $itemAlias . '.twig');
             $item['alias'] = $itemAlias;
         }
     }
 }
Example #10
0
 /**
  * Match route.
  *
  * @param string $route
  * @param string $method
  * @param array  $options
  *
  * @return  Route|boolean
  */
 public function match($route, $method = 'GET', $options = array())
 {
     $matched = parent::match($route, $method, $options);
     $extra = $matched->getExtra();
     if (isset($extra['parseHandler']) && is_callable($extra['parseHandler'])) {
         $variables = call_user_func_array($extra['parseHandler'], array($matched->getVariables()));
         $matched->setVariables($variables);
     }
     $this->matched = $matched;
     $this->extra->reset()->load($matched->getExtra());
     return $matched;
 }
 /**
  * Get extension params.
  *
  * @param string $element The extension name.
  *
  * @return  Registry|\JRegistry Extension params object.
  */
 public static function getParams($element)
 {
     $extension = static::extractElement($element);
     switch ($extension['type']) {
         case 'component':
             $params = \JComponentHelper::getParams($element);
             $params = new Registry($params->toArray());
             break;
         case 'module':
             $module = \JModuleHelper::getModule($element);
             $params = new Registry();
             $params->loadString($module->params);
             break;
         case 'plugin':
             $plugin = \JPluginHelper::getPlugin($extension['group'], $extension['name']);
             $params = $plugin->params;
             $params = new Registry($params);
             break;
         default:
             $params = new Registry();
             break;
     }
     return $params;
 }
Example #12
0
 /**
  * getTwig
  *
  * @param bool $new
  *
  * @return  \Twig_Environment
  */
 public function getEngine($new = false)
 {
     if (!$this->engine instanceof \Twig_Environment || $new) {
         $this->engine = new \Twig_Environment($this->getLoader(), $this->config->toArray());
         foreach (GlobalContainer::getExtensions() as $extension) {
             $this->engine->addExtension(clone $extension);
         }
         foreach ($this->extensions as $extension) {
             $this->engine->addExtension($extension);
         }
         foreach (GlobalContainer::getGlobals() as $name => $value) {
             $this->engine->addGlobal($name, $value);
         }
         if ($this->config->get('debug')) {
             $this->engine->addExtension($this->getDebugExtension());
         }
     }
     return $this->engine;
 }
 /**
  * Constructor.
  *
  * @param   \Windwalker\DI\Container      $container
  * @param   \Muse\IO\IOInterface $io
  * @param   Registry                      $config
  */
 public function __construct(Container $container, IOInterface $io, Registry $config = null)
 {
     // Get item & list name
     $ctrl = $config['ctrl'] ?: $io->getArgument(1);
     $ctrl = explode('.', $ctrl);
     $inflector = \JStringInflector::getInstance();
     if (empty($ctrl[0])) {
         $ctrl[0] = 'item';
     }
     if (empty($ctrl[1])) {
         $ctrl[1] = $inflector->toPlural($ctrl[0]);
     }
     list($itemName, $listName) = $ctrl;
     $replace['extension.element.lower'] = strtolower($config['element']);
     $replace['extension.element.upper'] = strtoupper($config['element']);
     $replace['extension.element.cap'] = ucfirst($config['element']);
     $replace['extension.name.lower'] = strtolower($config['name']);
     $replace['extension.name.upper'] = strtoupper($config['name']);
     $replace['extension.name.cap'] = ucfirst($config['name']);
     $replace['controller.list.name.lower'] = strtolower($listName);
     $replace['controller.list.name.upper'] = strtoupper($listName);
     $replace['controller.list.name.cap'] = ucfirst($listName);
     $replace['controller.item.name.lower'] = strtolower($itemName);
     $replace['controller.item.name.upper'] = strtoupper($itemName);
     $replace['controller.item.name.cap'] = ucfirst($itemName);
     // Set replace to config.
     foreach ($replace as $key => $val) {
         $config->set('replace.' . $key, $val);
     }
     // Set copy dir.
     $config->set('dir.dest', PathHelper::get(strtolower($config['element']), $config['client']));
     $config->set('dir.tmpl', GENERATOR_BUNDLE_PATH . '/Template/' . $config['extension'] . '/' . $config['template']);
     $config->set('dir.src', $config->get('dir.tmpl') . '/' . $config['client']);
     // Replace DS
     $config['dir.dest'] = Path::clean($config['dir.dest']);
     $config['dir.tmpl'] = Path::clean($config['dir.tmpl']);
     $config['dir.src'] = Path::clean($config['dir.src']);
     // Push container
     $this->container = $container;
     parent::__construct($io, $config, $replace);
 }
Example #14
0
 /**
  * extractConfig
  *
  * @param string $template
  *
  * @return  string
  */
 public function prepareData($template)
 {
     $template = explode('---', $template, 3);
     if (!trim($template[0])) {
         array_shift($template);
         $template = implode('---', $template);
         $template = explode('---', $template, 2);
     }
     try {
         $config = Yaml::parse($template[0]);
         if ($config) {
             array_shift($template);
         }
         $this->config->loadArray($config);
         $this->config->merge(Ioc::getConfig());
         $this->getData()->bind(array('config' => $this->config->toArray()));
         // Target permalink
         if ($this->config['permalink']) {
             $this->target = rtrim($this->config['permalink'], '/');
             if (substr($this->target, -5) != '.html') {
                 $this->target .= '/index.html';
             }
             $this->data->uri['base'] = ProcessorHelper::getBackwards($this->target) ?: './';
             $this->data->uri['media'] = ProcessorHelper::getBackwards($this->target) . 'media/';
         } else {
             $this->target = $this->getTarget();
         }
         $template = implode('---', $template);
     } catch (ParseException $e) {
         $template = implode('---', $template);
     }
     $event = new Event('loadProvider');
     $event['data'] = $this->data;
     $event['processor'] = $this;
     $dispatcher = Ioc::getDispatcher();
     $dispatcher->triggerEvent($event);
     return $template;
 }
Example #15
0
 /**
  * Unset a property.
  *
  * @param mixed $offset Offset key to unset.
  *
  * @throws  \InvalidArgumentException
  * @return  void
  */
 public function offsetUnset($offset)
 {
     $this->state->set($offset, null);
 }
 /**
  * Method to render the view.
  *
  * @return  string  The rendered view.
  *
  * @throws  \RuntimeException
  */
 public function doRender()
 {
     return JsonResponse::response($this->data->toArray());
 }
 /**
  * Set config object into this class.
  *
  * @param   Registry $config The config object.
  *
  * @return  void
  */
 public static function setConfig($config)
 {
     if ($config instanceof \Joomla\Registry\Registry) {
         $config = new Registry($config->toArray());
     }
     self::$config = $config;
 }
 /**
  * Set config.
  *
  * @param string $key   Config key.
  * @param string $value Value you want to set.
  *
  * @return  AbstractTaskController  Return self to support chaining.
  */
 public function set($key, $value)
 {
     $this->config->set($key, $value);
     return $this;
 }
 /**
  * Method to run this controller.
  *
  * @return  mixed
  */
 protected function doExecute()
 {
     // Init Variables
     $data = $this->input->get($this->input->get('formctrl'), array(), 'array');
     $result = new Registry();
     $result->set('Result', false);
     $model_name = $this->input->get('model_name');
     $component = $this->input->get('component');
     $extension = $this->input->get('extension');
     // Include Needed Classes
     JLoader::registerPrefix(ucfirst($component), JPATH_BASE . "/components/com_{$component}");
     JForm::addFormPath(JPATH_BASE . "/components/com_{$component}/models/forms");
     JForm::addFieldPath(JPATH_BASE . "/components/com_{$component}/models/fields");
     JTable::addIncludePath(JPATH_BASE . "/components/com_{$component}/tables");
     LanguageHelper::loadLanguage($extension, null);
     // Get Model
     /** @var $model CrudModel */
     $model = $this->getModel(ucfirst($model_name), ucfirst($component));
     if (!$model instanceof CrudModel) {
         $result->set('errorMsg', 'Model need extends to \\Windwalker\\Model\\CrudModel.');
         jexit($result);
     }
     // For WindWalker Component only
     if (method_exists($model, 'getFieldsName')) {
         $fields_name = $model->getFieldsName();
         $data = ArrayHelper::pivotToTwoDimension($data, $fields_name);
     }
     // Check for validation errors.
     try {
         // Get Form
         if (method_exists($model, 'getForm')) {
             $form = $model->getForm($data, false);
             if (!$form) {
                 $result->set('errorMsg', 'No form');
                 jexit($result);
             }
             // Test whether the data is valid.
             $validData = $model->validate($form, $data);
         } else {
             $validData = $data;
         }
         // Do Save
         $model->save($validData);
     } catch (ValidateFailException $e) {
         // Get the validation messages.
         $errors = $e->getErrors();
         $errors = array_map(function ($error) {
             return (string) $error->getMessage();
         }, $errors);
         $result->set('errorMsg', $errors);
         exit($result);
     } catch (\Throwable $e) {
         // Return Error Message.
         $result->set('errorMsg', \JText::sprintf('JLIB_APPLICATION_ERROR_SAVE_FAILED', $e->getMessage()));
         $result->set('backtrace', BacktraceHelper::normalizeBacktraces($e->getTrace()));
         jexit($result);
     } catch (\Exception $e) {
         // Return Error Message.
         $result->set('errorMsg', \JText::sprintf('JLIB_APPLICATION_ERROR_SAVE_FAILED', $e->getMessage()));
         $result->set('backtrace', BacktraceHelper::normalizeBacktraces($e->getTrace()));
         jexit($result);
     }
     // Set ID
     $data['id'] = $model->getState()->get($model_name . '.id');
     // Set Result
     $result->set('Result', true);
     $result->set('data', $data);
     jexit($result);
 }
Example #20
0
 /**
  * Reset cache position.
  *
  * @return void
  */
 public function resetCachePosition()
 {
     if ($this->extension) {
         $params = ExtensionHelper::getParams($this->extension);
     } else {
         $params = new Registry();
     }
     $this->config = new Registry();
     $this->config['path.cache'] = Path::clean(JPATH_ROOT . $params->get('thumb.cache-path', '/cache/thumbs/cache'));
     $this->config['path.temp'] = Path::clean(JPATH_ROOT . $params->get('thumb.temp-path', '/cache/thumbs/temp'));
     $this->config['url.cache'] = $params->get('thumb.cache-url', '/cache/thumbs/cache');
     $this->config['url.temp'] = $params->get('thumb.temp-url', '/cache/thumbs/cache');
 }
Example #21
0
 /**
  * prepareGlobals
  *
  * @param \Windwalker\Data\Data $data
  *
  * @return  void
  */
 protected function prepareGlobals($data)
 {
     $uri = new Registry();
     $layout = explode('/', $this->getLayout());
     array_pop($layout);
     $uri['base'] = str_repeat('../', count($layout)) ?: './';
     $uri['media'] = str_repeat('../', count($layout)) . 'media/';
     $layout = implode('/', (array) $layout);
     $this->data->uri = $uri->toArray();
     $this->data->helper = new HelperSet();
     $this->data->path = explode('/', $this->getLayout());
     $this->data->bind(GlobalProvider::loadGlobalProvider());
 }
 /**
  * Writes a configuration button and invokes a cancel operation (eg a checkin).
  *
  * @param   string   $component  The name of the component, eg, com_content.
  * @param   string   $alt        The name of the button.
  * @param   string   $path       An alternative path for the configuation xml relative to JPATH_SITE.
  *
  * @return  void
  */
 public function preferences($component = null, $alt = 'JToolbar_Options', $path = '')
 {
     $component = $component ?: $this->config->get('option', Container::getInstance()->get('input')->get('option'));
     $component = urlencode($component);
     JToolbarHelper::preferences($component, $alt, $path);
 }
Example #23
0
 /**
  * Class init.
  *
  * @param \SplPriorityQueue $paths
  * @param array             $config
  */
 public function __construct($paths = null, $config = array())
 {
     $this->setPaths($paths);
     $this->config = new Registry($this->config);
     $this->config->loadArray($config);
 }
Example #24
0
<?php

require_once 'vendor/autoload.php';
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse as Response;
use Windwalker\Registry\Registry;
use League\Route\RouteCollection;
//use Symfony\Component\HttpFoundation\RedirectResponse as Redirect;
$router = new RouteCollection();
$request = Request::createFromGlobals();
$registry = new Registry();
$registry->set('config.posibile-hoteluri', ['perla', 'parc']);
$registry->set('config.string_hotel_identifier_limit', 3);
/**
 * Helpers
 */
$registry->set('helper.generator-hotel-item-body', function ($identifier) use($registry) {
    return ['identifier' => $identifier, 'name' => 'Hotel ' . ucwords($identifier) . ' ' . str_repeat('*', strlen($identifier)), 'mobile' => '0421.000.000', 'country' => 'Romania', 'geo' => ['lat' => '41.222', 'lon' => '26.222'], '@self' => '/hotel/' . $identifier, '@rooms' => '/rooms?hotel=' . $identifier];
});
$registry->set('helper.generator-room-number', function ($args) use($registry) {
    $charLimit = $registry->get('config.string_hotel_identifier_limit');
    $prefix = strtoupper(substr(md5($args['hotelIdentifier']), 0, $charLimit));
    $padding = str_pad($args['number'], 5, 0);
    return $prefix . $padding . $args['number'];
});
$registry->set('helper.generator-room-item-body', function ($roomIdentifier, $hotelIdentifier) use($registry) {
    $charLimit = $registry->get('config.string_hotel_identifier_limit');
    return ['identifier' => $roomIdentifier, 'name' => 'Room ' . substr($roomIdentifier, $charLimit + 1), '@self' => '/room/' . $roomIdentifier, '@hotel' => '/hotel/' . $hotelIdentifier];
});
$registry->set('helper.find-hotel-by-room-identifier', function ($roomIdentifier) use($registry) {
    $demoList = $registry->get('config.posibile-hoteluri');
Example #25
0
 /**
  * Merge a Registry object into this one
  *
  * @param   Registry  $source     Source Registry object to merge.
  * @param   boolean   $recursive  True to support recursive merge the children values.
  *
  * @return  Registry  Return this object to support chaining.
  *
  * @since   2.0
  */
 public function merge(Registry $source, $recursive = true)
 {
     $this->bindData($this->data, $source->toArray(), $recursive, false);
     return $this;
 }
 /**
  * Dump to one dimension array.
  *
  * @param   string  $separator  The key separator.
  *
  * @return  string[]  Dumped array.
  *
  * @since   1.3.0
  */
 public function flatten($separator = null)
 {
     return $this->registry->flatten($separator);
 }
 /**
  * Modifies a property of the object, creating it if it does not already exist.
  *
  * @param   string  $key    The name of the property.
  * @param   mixed   $value  The value of the property to set (optional).
  *
  * @return  mixed   Previous value of the property
  *
  * @since   2.0
  */
 public function set($key, $value = null)
 {
     $previous = $this->config->get($key);
     $this->config->set($key, $value);
     return $previous;
 }
 /**
  * Load config.
  *
  * @return  Registry Config registry object.
  */
 public function loadConfig()
 {
     $file = WINDWALKER . '/config.json';
     if (!is_file($file)) {
         \JFile::copy(WINDWALKER . '/config.dist.json', $file);
     }
     $config = new Registry();
     return $config->loadFile($file, 'json');
 }
 /**
  * Execute the controller.
  *
  * @return  boolean  True if controller finished execution, false if the controller did not
  *                   finish execution. A controller might return false if some precondition for
  *                   the controller to run has not been satisfied.
  *
  * @throws  \LogicException
  * @throws  \RuntimeException
  */
 public function execute()
 {
     $package = $this->io->getArgument(0, new ValidatePrompter('Enter package name: '));
     $class = $this->io->getArgument(1, new ValidatePrompter('Enter class name: '));
     $class = StringNormalise::toClassNamespace($class);
     $target = $this->io->getArgument(2, $package . '\\' . $class . 'Test');
     $target = StringNormalise::toClassNamespace($target);
     $package = ucfirst($package);
     if (!class_exists($class)) {
         $class = 'Windwalker\\' . $package . '\\' . $class;
     }
     if (!class_exists($class)) {
         $this->out('Class not exists: ' . $class);
         exit;
     }
     $replace = $this->replace;
     $ref = new \ReflectionClass($class);
     $replace['origin.class.dir'] = dirname($ref->getFileName());
     $replace['origin.class.file'] = $ref->getFileName();
     $replace['origin.class.name'] = $ref->getName();
     $replace['origin.class.shortname'] = $ref->getShortName();
     $replace['origin.class.namespace'] = $ref->getNamespaceName();
     $replace['test.dir'] = WINDWALKER_ROOT . DIRECTORY_SEPARATOR . 'test';
     $replace['test.class.name'] = 'Windwalker\\Test\\' . $target;
     $replace['test.class.file'] = Path::clean($replace['test.dir'] . DIRECTORY_SEPARATOR . $target . '.php');
     $replace['test.class.dir'] = dirname($replace['test.class.file']);
     $replace['test.class.shortname'] = $this->getShortname(StringNormalise::toClassNamespace($replace['test.class.name']));
     $replace['test.class.namespace'] = $this->getNamespace($replace['test.class.name']);
     $this->replace = $replace;
     $config = new Registry();
     // Set replace to config.
     foreach ($this->replace as $key => $val) {
         $config->set('replace.' . $key, $val);
     }
     $methods = $ref->getMethods(\ReflectionMethod::IS_PUBLIC);
     $methodTmpl = file_get_contents(GENERATOR_BUNDLE_PATH . '/Template/test/testMethod.php');
     $methodCodes = array();
     foreach ($methods as $method) {
         $config['replace.origin.method'] = $method->getName();
         $config['replace.test.method'] = ucfirst($method->getName());
         $methodCodes[] = StringHelper::parseVariable($methodTmpl, $config->get('replace'));
     }
     $config['replace.test.methods'] = implode("", $methodCodes);
     $this->replace = $config->get('replace');
     $this->config = $config;
     $this->doAction(new GenClassAction());
     $this->out('Generate test class: ' . $replace['test.class.name'] . ' to file: ' . $replace['test.class.file'])->out();
     return true;
 }
 /**
  * testGetIterator
  *
  * @return  void
  *
  * @covers  Windwalker\Registry\Registry::getIterator
  */
 public function testGetIterator()
 {
     $this->assertInstanceOf('RecursiveArrayIterator', $this->instance->getIterator());
     $this->assertEquals($this->getTestData(), iterator_to_array($this->instance));
     $this->assertEquals(iterator_to_array(new \RecursiveIteratorIterator(new \RecursiveArrayIterator($this->getTestData()))), iterator_to_array(new \RecursiveIteratorIterator($this->instance)));
 }