/**
  * Constructor.
  *
  * @param   \Windwalker\DI\Container      $container
  * @param   \Muse\IO\IOInterface $io
  * @param   Registry                      $config
  */
 public function __construct(Container $container, IOInterface $io, Registry $config = null)
 {
     //		// 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);
 }
 /**
  * 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);
 }
 /**
  * Constructor.
  *
  * @param   \Windwalker\DI\Container $container
  * @param   \Muse\IO\IOInterface     $io
  * @param   Structure                $config
  *
  * @throws \InvalidArgumentException
  */
 public function __construct(Container $container, IOInterface $io, Structure $config = null)
 {
     // Get item & list name
     $ctrl = $config['ctrl'] ?: $io->getArgument(1);
     $ctrl = explode('.', $ctrl);
     $inflector = StringInflector::getInstance();
     if (empty($ctrl[0])) {
         $ctrl[0] = 'item';
     }
     if (empty($ctrl[1])) {
         $ctrl[1] = $inflector->toPlural($ctrl[0]);
     }
     list($itemName, $listName) = $ctrl;
     // Prepare package name
     $class = explode('\\', str_replace('/', '\\', $config['name']));
     $name = array_pop($class);
     $class = StringNormalise::toClassNamespace(implode('\\', $class));
     $class = $class ? $class . '\\' : null;
     // Check keywords
     if (in_array(strtolower($name), static::$keywords)) {
         throw new \InvalidArgumentException('Do not use reserved keywords: ' . $name);
     }
     if (in_array(strtolower($listName), static::$keywords)) {
         throw new \InvalidArgumentException('Do not use reserved keywords: ' . $listName);
     }
     if (in_array(strtolower($itemName), static::$keywords)) {
         throw new \InvalidArgumentException('Do not use reserved keywords: ' . $itemName);
     }
     $config['package.name'] = $name;
     $config['package.namespace'] = $class;
     $this->replace = new Structure();
     $this->replace['package.namespace'] = $class;
     $this->replace['package.name.lower'] = lcfirst($name);
     $this->replace['package.name.upper'] = strtoupper($name);
     $this->replace['package.name.cap'] = ucfirst($name);
     $this->replace['controller.list.name.lower'] = strtolower($listName);
     $this->replace['controller.list.name.upper'] = strtoupper($listName);
     $this->replace['controller.list.name.cap'] = ucfirst($listName);
     $this->replace['controller.item.name.lower'] = strtolower($itemName);
     $this->replace['controller.item.name.upper'] = strtoupper($itemName);
     $this->replace['controller.item.name.cap'] = ucfirst($itemName);
     // Set replace to config.
     $config->mergeTo('replace', $this->replace);
     // Set copy dir.
     $config->set('dir.dest', WINDWALKER_SOURCE . '/' . $this->replace['package.namespace'] . $this->replace['package.name.cap']);
     $config->set('dir.tmpl', PHOENIX_TEMPLATES . '/package/' . $config['template']);
     $config->set('dir.src', $config->get('dir.tmpl'));
     // 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, $this->replace->toArray());
 }