Activate or Disable component.

@param (string) $name   Name of component.
@param (bool)   $status Valid status.

@since 3.0.0

@return bool
767073
public function enableOrDisable($name, $status)
    {
        $file = route()->com.$name.'/component.json';
        if (file_exists($file)) {
            $fileHandling = new FileHandling();
            $c = $fileHandling->open($file, 'readOnly')->read();
            $config = json_decode($c, true);
            $config['status'] = $status;
            $config = json_encode($config, JSON_PRETTY_PRINT);
            $fileHandling->open($file, 'writeOnly')->write($config);
            $fileHandling->close();

            return true;
        }

        return false;
    }
312473
public function status($status)
    {
        if (!($status instanceof Status)) {
            $status = new Status($status);
        }

        $this->status = $status;

        return $this;
    }
1049336
public function setStatus($status)
    {
        if (!in_array($status, static::getAvailableStatuses(), true)) {
            throw new InvalidArgumentException(sprintf('Status not recognized ; Had "%s", expected one of "%s"', $status, implode('", "', static::getAvailableStatuses())));
        }

        $this->status = $status;

        return $this;
    }
265010
public function status($status)
  {
    if (is_string($status)) {
      switch ($status) {
        case 'success':
          $this->status = JSendResponse::STATUS_SUCCESS;
          break;
        case 'error':
          $this->status = JSendResponse::STATUS_ERROR;
          break;
        case 'fail':
          $this->status = JSendResponse::STATUS_FAIL;
          break;
        default:
          throw new \InvalidArgumentException("Unable to parse status '${status}'");
      }
    } else {
      $this->status = $status;
    }

    return $this;
  }
709521
public function isActive($name, Context $context)
    {
        $this->setup();

        $builder = $this->getConnection()->createQueryBuilder();

        // $result contains the response from state (true / false) or false if no feature found
        $result = $builder
            ->select(
                $this->options['db_column_state']
            )
            ->from($this->options['db_table'])
            ->where(sprintf('%s = :feature', $this->options['db_column_feature']))
            ->setParameter('feature', $name)
            ->execute()
            ->fetchColumn();

        return is_bool($result) ? $result : filter_var($result, FILTER_VALIDATE_BOOLEAN);
    }
971762
public function __isset( $name ) {
		return $this->is_readonly_property( $name ) && property_exists( $this, $name ) && ! is_null( $this->$name );
	}
274372
public function getComponent($name)
    {
        foreach ($this->getComponents() as $component) {
            if ($component->getName() == $name) {
                return $component;
            }
        }
        throw new ComponentException(
            sprintf("'%s' is not a registered component", $name)
        );
    }
812090
def activate_component(self, name):
        

        if not name in self.__engine.components_manager.components:
            raise manager.exceptions.ComponentExistsError(
                "{0} | '{1}' Component isn't registered in the Components Manager!".format(self.__class__.__name__,
                                                                                           name))

        component = self.__engine.components_manager.components[name]
        if component.interface.activated:
            LOGGER.warning("!> {0} | '{1}' Component is already activated!".format(self.__class__.__name__, name))
            return False

        LOGGER.debug("> Attempting '{0}' Component activation.".format(component.name))
        component.interface.activate(self.__engine)
        if component.category in ("Default", "QObject"):
            component.interface.initialize()
        elif component.category == "QWidget":
            component.interface.initialize_ui()
            component.interface.add_widget()
        LOGGER.info("{0} | '{1}' Component has been activated!".format(self.__class__.__name__, component.name))
        self.activated_component.emit(name)
        self.refresh_nodes.emit()
        return True
185271
public function deactivate_script($name)
    {
        // Kolab's KEP:14
        if ($this->rc->config->get('managesieve_kolab_master')) {
            $extension   = $this->rc->config->get('managesieve_filename_extension', '.sieve');
            $user_script = $_SESSION['managesieve_user_script'];

            // if the script is active...
            if ($user_script && ($key = array_search($name, $this->active)) !== false) {
                // ...rewrite USER file removing appropriate include command
                if ($this->sieve->load($user_script)) {
                    $script = $this->sieve->script->as_array();
                    $name   = $name.$extension;

                    foreach ($script as $rid => $rules) {
                        foreach ($rules['actions'] as $action) {
                            if ($action['type'] == 'include' && empty($action['global'])
                                && $action['target'] == $name
                            ) {
                                break 2;
                            }
                        }
                    }

                    // Entry found
                    if ($rid < count($script)) {
                        $this->sieve->script->delete_rule($rid);
                        $result = $this->sieve->save();
                        if ($result) {
                            unset($this->active[$key]);
                        }
                    }
                }
            }
        }
        else {
            $result = $this->sieve->deactivate();
            if ($result)
                $this->active = array();
        }

        return $result;
    }
1308228
public function moduleEnabled($name) {
    $this->options[] = '--format=json';
    $modules = $this->__call('pmList', []);
    if (!$modules = json_decode($modules, TRUE)) {
      throw new DrushFormatException("Cannot parse json output from drush: $modules", $modules);
    }
    $this->options = [];
    return isset($modules[$name]) && $modules[$name]['status'] === 'Enabled';
  }
181124
public function getAction($name, $need = TRUE)
    {
        return $this->hasActions()
            ? $this->getComponent(Action::ID)->getComponent($name, $need)
            : NULL;
    }
206127
public function enable($name)
    {
        if ($this->isEnabled($name)) {
            return;
        }

        $extension = $this->getExtension($name);

        $this->dispatcher->dispatch(new Enabling($extension));

        $enabled = $this->getEnabled();

        $enabled[] = $name;

        $this->migrate($extension);

        $this->publishAssets($extension);

        $this->setEnabled($enabled);

        $extension->enable($this->app);

        $this->dispatcher->dispatch(new Enabled($extension));
    }
461211
public function enable(string $name, int $timeout = 0)
    {
        return $this->curl->post($this->base_url.'/'.$name.'/enable?'.http_build_query([
                    'timeout' => $timeout,
                ]
            )
        );
    }
1312014
public function del(string $name): ConfigInterface
    {
        // Check if key is certificate or push, or classic parameter
        if (\in_array($name, self::CERTS, true)) {
            $this->delCert($name);
        } elseif ($name === 'push') {
            throw new \RuntimeException("Not possible to remove push, use 'delPush' instead");
        } else {
            $this->_params = array_map(
                function($param) use ($name) {
                    return ($param['name'] === $name) ? null : $param;
                },
                $this->_params
            );
        }

        return $this;
    }
310016
public function deleteComponentEntry($name)
	{
		if ($this->baseDb->tableExists('#__components'))
		{
			// Delete component entry
			$query = "DELETE FROM `#__components` WHERE `name` = " . $this->baseDb->quote($name);
			$this->baseDb->setQuery($query);
			$this->baseDb->query();

			$this->log(sprintf('Removed component entry for "%s"', $element));

			return true;
		}
		elseif ($this->baseDb->tableExists('#__extensions'))
		{
			$name = 'com_' . strtolower($name);
			// Delete component entry
			$query = "DELETE FROM `#__extensions` WHERE `name` = " . $this->baseDb->quote($name);
			$this->baseDb->setQuery($query);
			$this->baseDb->query();

			// Remove the component container in the assets table
			$asset = \Hubzero\Access\Asset::oneByName($name);
			if ($asset && $asset->get('id'))
			{
				$asset->destroy();
			}

			$this->log(sprintf('Removed extension entry for component "%s"', $element));

			if ($this->baseDb->tableExists('#__menu'))
			{
				// Check for an admin menu entry...if it's not there, create it
				$query = "DELETE FROM `#__menu` WHERE `menutype` = 'main' AND `title` = " . $this->baseDb->quote($name);
				$this->baseDb->setQuery($query);
				$this->baseDb->query();

				// Rebuild lft/rgt
				$this->rebuildMenu();

				$this->log(sprintf('Removed menu entry for component "%s"', $element));
			}

			return true;
		}

		return false;
	}
711381
public function muted($status = false)
    {
        if($status) {
            $this->attributes['muted'] = true;
        } else {
            unset($this->attributes['muted']);
        }

        return $this;
    }
546458
public static function isEnabled(array $options, string $name, $default = false): bool
    {
        $enabled = $default;
        $options = self::normalize($options);

        if (array_key_exists('*', $options)) {
            $enabled = $options['*'];
        }

        if (array_key_exists($name, $options)) {
            $enabled = (bool) $options[$name];
        }

        return $enabled;
    }