checkRequirements() 공개 메소드

An addon cannot be enabled if it has missing or invalid requirements. If an addon has requirements that are simply disabled it will pass this test as long as it's requirements also meet *their* requirements.
public checkRequirements ( Addon $addon, boolean $throw = false ) : boolean
$addon Addon The addon to check.
$throw boolean Whether or not to throw an exception if the requirements are not met.
리턴 boolean Returns **true** if the requirements are met or **false** otherwise.
예제 #1
0
 /**
  *
  *
  * @param $pluginName
  * @param Gdn_Validation $validation
  * @param bool $setup
  * @return bool
  * @throws Exception
  * @throws Gdn_UserException
  */
 public function enablePlugin($pluginName, $validation, $setup = true)
 {
     // Check to see if the plugin is already enabled.
     if ($this->addonManager->isEnabled($pluginName, Addon::TYPE_ADDON)) {
         throw new Gdn_UserException(t('The plugin is already enabled.'));
     }
     $addon = $this->addonManager->lookupAddon($pluginName);
     if (!$addon) {
         throw notFoundException('Plugin');
     }
     if (!$validation instanceof Gdn_Validation) {
         $validation = new Gdn_Validation();
     }
     try {
         $this->addonManager->checkRequirements($addon, true);
         $addon->test(true);
     } catch (\Exception $ex) {
         $validation->addValidationResult('addon', '@' . $ex->getMessage());
         return false;
     }
     // Enable this addon's requirements.
     $requirements = $this->addonManager->lookupRequirements($addon, AddonManager::REQ_DISABLED);
     foreach ($requirements as $addonKey => $row) {
         $requiredAddon = $this->addonManager->lookupAddon($addonKey);
         $this->enableAddon($requiredAddon, $setup);
     }
     // Enable the addon.
     $this->enableAddon($addon, $setup);
     // Refresh the locale just in case there are some translations needed this request.
     Gdn::locale()->refresh();
     $this->EventArguments['AddonName'] = $addon->getRawKey();
     $this->fireEvent('AddonEnabled');
     return true;
 }
예제 #2
0
 /**
  * Test a theme for dependencies and parse errors.
  *
  * @param string $themeName The case-sensitive theme name.
  * @return bool Returns
  * @throws Gdn_UserException Throws an exception when there was an issue testing the theme.
  */
 public function testTheme($themeName)
 {
     $addon = $this->addonManager->lookupTheme($themeName);
     if (!$addon) {
         throw notFoundException('Plugin');
     }
     try {
         $this->addonManager->checkRequirements($addon, true);
         $addon->test(true);
     } catch (\Exception $ex) {
         throw new Gdn_UserException($ex->getMessage(), $ex->getCode());
     }
     return true;
 }