/** * Load the required recipe and its requirements. * Note: recipes have to be loaded on init() declaring them as requirements * * This method will first look for built-in recipes and then for the user defined ones. * TODO: log warning message if the requested recipe is not found * * @param string $recipeName * @param bool $globalRecipe whether to search inside the DeploYii home folder * @param bool $userRecipe whether to search inside the user build scripts folder * * @return bool|mixed */ private function _loadRecipe($recipeName, $globalRecipe = false, $userRecipe = false) { $recipeScript = false; $recipeClass = ucfirst($recipeName) . 'Recipe'; if ($globalRecipe && !$userRecipe) { $recipesDir = Yii::getAlias('@home/recipes'); } elseif ($userRecipe) { $recipesDir = Yii::getAlias('@buildScripts/recipes'); } else { $recipesDir = __DIR__ . '/recipes'; } $recipeFile = $recipesDir . '/' . $recipeClass . '.php'; if (file_exists($recipeFile)) { Log::logger()->addInfo('Loading recipe file: {file}', ['file' => $recipeFile]); /** @noinspection PhpIncludeInspection */ $recipeScript = (require $recipeFile); } elseif (!$globalRecipe && !$userRecipe) { $recipeScript = $this->_loadRecipe($recipeName, true); } elseif (!$userRecipe) { $recipeScript = $this->_loadRecipe($recipeName, false, true); } $recipeVersion = isset($recipeScript['deployiiVersion']) ? $recipeScript['deployiiVersion'] : '0.3.0'; VersionManager::checkRecipeVersion($recipeVersion, $recipeName); // Load requirements and initialise the extra parameters: if (!empty($recipeScript['require'])) { $this->_loadRequirements($recipeScript['require']); } $this->_recipes[$recipeName] = $recipeScript; return $recipeScript; }