getParameter() public method

Returns parameter named parameterName if specified on the command line else null
public getParameter ( string $parameterName ) : string
$parameterName string
return string
示例#1
0
 /**
  * Initializes a Zephir extension
  *
  * @param CommandInterface $command
  *
  * @throws Exception
  */
 public function init(CommandInterface $command)
 {
     /**
      * If init namespace is specified
      */
     $namespace = $command->getParameter('namespace');
     if (!$namespace) {
         throw new Exception("Cannot obtain a valid initial namespace for the project");
     }
     /**
      * Tell the user the name could be reserved by another extension
      */
     if (extension_loaded($namespace)) {
         $this->logger->output('This extension can have conflicts with an existing loaded extension');
     }
     $this->config->set('namespace', $namespace);
     $this->config->set('name', $namespace);
     if (!is_dir($namespace)) {
         mkdir($namespace);
     }
     chdir($namespace);
     if (!is_dir($namespace)) {
         mkdir($namespace);
     }
     /**
      * Create 'kernel'
      */
     if (!is_dir('ext/kernel')) {
         mkdir('ext/kernel', 0755, true);
     }
     // Copy the latest kernel files
     $this->recursiveProcess($this->backend->getInternalKernelPath(), 'ext/kernel');
 }
示例#2
0
 /**
  * Find the theme directory depending on the command  line options and the config.
  *
  * theme directory is checked in this order :
  *  => check if the command line argument --theme-path was given
  *  => if not ; find the different theme directories on the config $config['api']['theme-directories']
  *  search the theme from the name ($config['api']['theme']['name'] in the theme directories,
  * if nothing was found, we look in the zephir install dir default themes (templates/Api/themes)
  *
  * @param $themeConfig
  * @param Config $config
  * @param CommandInterface $command
  * @return null|string
  * @throws ConfigException
  * @throws Exception
  */
 private function __findThemeDirectory($themeConfig, Config $config, CommandInterface $command)
 {
     // check if there are additional theme paths in the config
     $themeDirectoriesConfig = $config->get("theme-directories", "api");
     if ($themeDirectoriesConfig) {
         if (is_array($themeDirectoriesConfig)) {
             $themesDirectories = $themeDirectoriesConfig;
         } else {
             throw new ConfigException("invalid value for theme config 'theme-directories'");
         }
     } else {
         $themesDirectories = array();
     }
     $themesDirectories[] = ZEPHIRPATH . "templates/Api/themes";
     $this->themesDirectories = $themesDirectories;
     // check if the path was set from the command
     $themePath = $command->getParameter("theme-path");
     if (null !== $themePath) {
         if (file_exists($themePath) && is_dir($themePath)) {
             return $themePath;
         } else {
             throw new Exception("Invalid value for option 'theme-path' : the theme '{$themePath}' was not found or is not a valid theme.");
         }
     }
     if (!isset($themeConfig["name"]) || !$themeConfig["name"]) {
         throw new ConfigException("There is no theme neither in the the theme config nor as a command line argument");
     }
     return $this->findThemePathByName($themeConfig["name"]);
 }
示例#3
0
 /**
  * Find the theme directory depending on the command  line options and the config.
  *
  * theme directory is checked in this order :
  *  => check if the command line argument --theme-path was given
  *  => if not ; find the different theme directories on the config $config['api']['theme-directories']
  *  search the theme from the name ($config['api']['theme']['name'] in the theme directories,
  * if nothing was found, we look in the zephir install dir default themes (templates/Api/themes)
  *
  * @param $themeConfig
  * @param Config $config
  * @param CommandInterface $command
  * @return null|string
  * @throws ConfigException
  * @throws Exception
  */
 private function __findThemeDirectory($themeConfig, Config $config, CommandInterface $command)
 {
     // check if the path was set from the command
     $themePath = $command->getParameter("theme-path");
     if (null !== $themePath) {
         if (file_exists($themePath) && is_dir($themePath)) {
             return $themePath;
         } else {
             throw new Exception("Invalid value for option 'theme-path' : the theme '{$themePath}' was not found or is not a valid theme.");
         }
     }
     // check the theme from the config
     // check if there are additional theme paths in the config
     $themeDirectoriesConfig = $config->get("theme-directories", "api");
     if ($themeDirectoriesConfig) {
         if (is_array($themeDirectoriesConfig)) {
             $themesDirectories = $themeDirectoriesConfig;
         } else {
             throw new ConfigException("invalid value for theme config 'theme-directories'");
         }
     } else {
         $themesDirectories = array();
     }
     $themesDirectories[] = ZEPHIRPATH . "templates/Api/themes";
     $path = null;
     foreach ($themesDirectories as $themeDir) {
         $dir = rtrim($themeDir, "/") . "/";
         $path = realpath($dir . $themeConfig["name"]);
         if ($path) {
             break;
         }
     }
     return $path;
 }