Install the component.

@param (string) $archive Valid component zip archive in Data folder.
@param (string) $name    Name of component.

@since 3.0.0

@return bool
324697
public function install($archive, $name)
    {
        $exploadName = explode('.', $name);
        $name = $exploadName[0];
        $storageData = route()->storage_data;
        $file = $storageData.$archive;
        $files = new Files();
        $files->mkdir($storageData.'tmp/');
        $files->mkdir($storageData.'tmp/'.$name);
        (new Zip())->extract($file, $storageData.'tmp/'.$name.'/', true);
        if (file_exists($storageData.'tmp/'.$name.'/component.json')) {
            $file = new FileHandling();
            $c = $file->open($storageData.'/tmp/'.$name.'/component.json', 'readOnly')->read();
            $file->close();
            $config = json_decode($c, true);
            if ($this->isSupported($config['requires']['version'], $config['requires']['comparator']) === true) {
                if (!file_exists(route()->com.$name)) {
                    $files->moveDir($storageData.'tmp/', route()->com, $name);

                    return true;
                }
            }
        }

        return false;
    }
768125
public function install($name, $version = 'dev-master', $type = 'composer', $subtree = false)
    {
        $installer = new Installer($name, $version, $type, $subtree);

        return $installer->run();
    }
475225
private function add(string $name, string $class) : bool
  {
    $commands = ModulusCLI::$appdir . 'app' . DIRECTORY_SEPARATOR . 'Console' . DIRECTORY_SEPARATOR . 'Commands';
    $raw = str_replace(' ', '_', $name);
    $command = $commands . DIRECTORY_SEPARATOR . $class . '.php';

    ModulusCLI::_dir($commands);

    $content = Template::asset('command_template');
    $content = str_replace('{clean_command_name}', $class, $content);
    $content = str_replace('{command_name}', $raw, $content);

    if (file_exists($command)) {
      return false;
    }
    else {
      file_put_contents($command, $content);
      return true;
    }
  }
1201901
public function isInstalled(string $name): bool
    {
        $extension = $this->getAvailableExtensions()->findByName($this->getNormalizedName($name));

        if ($extension instanceof ExtensionContract) {
            return $extension->isInstalled();
        }

        return false;
    }
246982
public function addPlugin($name, $dir)
    {
        Debug::enterScope($name);
        $hasPlugin = $hasZfile = false;

        try {
            $this->plugins[$name] = $this->getLocator()->locate($name . '/Plugin.php', $dir, true);
            $this->pluginPaths[$name] = dirname($this->plugins[$name]);

            $hasPlugin = true;
            $this->sourceFiles[] = $this->plugins[$name];
        } catch (\InvalidArgumentException $e) {
        }

        try {
            $zFileLocation = $this->getLocator()->locate($name . '/z.yml', $dir);
            $this->import($zFileLocation, self::PLUGIN);
            if (!isset($this->pluginPaths[$name])) {
                $this->pluginPaths[$name] = dirname($zFileLocation);
            } else if ($this->pluginPaths[$name] != dirname($zFileLocation)) {
                throw new \UnexpectedValueException(
                    "Ambiguous plugin configuration:\n"
                    . "There was a Plugin.php found in {$this->pluginPaths[$name]}, but also a z.yml at $zFileLocation"
                );
            }

            $hasZfile = true;
            $this->sourceFiles[] = $zFileLocation;
        } catch (\InvalidArgumentException $e) {
        }

        if (!$hasPlugin && !$hasZfile) {
            throw new \InvalidArgumentException("You need at least either a z.yml or a Plugin.php in the plugin path for '{$name}'");
        }
        Debug::exitScope($name);
    }
727525
public function actionInstall($name=false)
	{
		if ($name == false || defined('CII_CONFIG'))
			return false;

		$filePath 	= Yii::getPathOfAlias('base.themes').DS.$name;
		$details 	= $this->actionDetails($name);

		// If the theme is already installed, make sure it is the correct version, otherwise we'll be performing an upgrade
		if ($this->actionIsInstalled($name, true))
		{
			if (file_exists($filePath.DS.'VERSION'))
			{
				$version = file_get_contents($filePath.DS.'VERSION');

				if ($version == $details['latest-version'])
					return true;
			}
		}

		// Set several variables to store the various paths we'll need
		$tmpPath 	= Yii::getPathOfAlias('application.runtime.themes').DS.$name;
		$themesPath = Yii::getPathOfAlias('application.runtime').DS.'themes';
		$zipPath 	= $themesPath.DS.$details['sha'].'.zip';

		// Verify the temporary directory exists
		if (!file_exists($themesPath))
			mkdir($themesPath);

		// Download the ZIP package to the runtime/themes temporary directory
		
		if (!$this->downloadPackage($details['sha'], $details['file'], Yii::getPathOfAlias('application.runtime.themes')))
			throw new CHttpException(500, Yii::t('Api.theme', 'Failed to download theme package from Github. Source might be down'));

		$zip = new ZipArchive;

		// If we can open the file
		if ($zip->open($zipPath) === true)
		{
			// And we were able to extract it
			if ($zip->extractTo($themesPath.DS.$details['sha']))
			{
				// Close the ZIP connection
				$zip->close();

				// Delete the downloaded ZIP file
				unlink($zipPath);

				// Move the folders around so we're operating on the bare folder, then delete the teporary folder
				rename($themesPath.DS.$details['sha'].DS.'ciims-themes-'.$name.'-'.$details['latest-version'], $tmpPath);
				rmdir(str_replace('.zip', '', $zipPath));

				// Store the version with the theme
				file_put_contents($tmpPath.'/VERSION', $details['latest-version']);

				// If a theme is already installed that has that name, rename it to "$filePath-old"
				if (file_exists($filePath) && is_dir($filePath))
					rename($filePath, $filePath . "-old");

				// Then copy over the theme from the tmpPath to the final destination path
				rename($tmpPath, $filePath);

				// Then purge the -old directories
				if (file_exists($filePath . "-old"))
				{
					foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($filePath . "-old", FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST) as $path)
					$path->isDir() ? rmdir($path->getPathname()) : unlink($path->getPathname());

					rmdir($filePath . "-old");
				}

				// Purge the cache
				Yii::app()->cache->delete('settings_themes');
				return true;
			}

		}

		unlink($tmpPath.'.zip');
		throw new CHttpException(500, Yii::t('Api.theme', 'Unable to extract downloaded ZIP package'));
	}
640529
public function organizationHaveNoJob($name)
    {
        $org = $this->findOrganizationByName($name);

        /* @var JobRepository $jobRepo */
        $jobRepo = $this->getRepository('Jobs/Job');
        $result = $jobRepo->findByOrganization($org->getId());

        foreach($result as $job){
            $jobRepo->remove($job,true);
        }
    }
183686
public function installRepository(string $name, string $type, string $url)
    {
        if (array_key_exists('repositories', $this->definition)
            && array_key_exists($name, $this->definition['repositories'])
        ) {
            return;
        }

        $application = new Application();
        $command     = new ConfigCommand();

        $definition = clone $application->getDefinition();
        $definition->addArguments($command->getDefinition()->getArguments());
        $definition->addOptions($command->getDefinition()->getOptions());

        $input = new ArrayInput(
            [
                'command' => 'config',
                'setting-key' => 'repositories.' . $name,
                'setting-value' => [
                    $type,
                    $url
                ],
                '--working-dir' => $this->workingDir
            ],
            $definition
        );

        $application->setAutoExit(false);
        $application->run($input, $this->output);
    }
287392
public static function isInstalled($author, $name)
    {
        if (!self::checkOnDisk($author, $name))
            return false;
        return self::getFromDb($author, $name);
    }
122033
public function addRss($name, $attributes = [])
    {
        $rssPath = $this->getAssetPath($name);

        if (isset($this->controller)) {
            $this->controller->addRss($rssPath, $attributes);
        }

        if (is_string($attributes)) {
            $attributes = ['build' => $attributes];
        }

        $rssPath = $this->getAssetScheme($rssPath);

        if (!in_array($rssPath, $this->assets['rss'])) {
            $this->assets['rss'][] = ['path' => $rssPath, 'attributes' => $attributes];
        }
    }
206173
public function getComponentByName($name)
    {
        foreach ($this->components as $component) {
            if ($component->getName() == $name) {
                return $component;
            }
        }
    }
1292940
public function downloadPlugin($name, $hash, $installation = false)
    {
        $fileCode = $name . $hash;
        $this->requestServerFile('plugin/get', $fileCode, $hash, [
            'name' => $name,
            'installation' => $installation ? 1 : 0
        ]);
    }
146197
public function insert($name, array $data=null)
	{
		// Register the template file (to find the custom templates)
		if (!array_key_exists($name, TemplateLoader::getFiles()))
		{
			$objTheme = \LayoutModel::findById(Controller::getLayoutId($this->ptable, $this->pid))->getRelated('pid');
			
			TemplateLoader::addFile($name, $objTheme->templates);
		}
		
		/** @var \Template $tpl */
		if ($this instanceof \Template)
		{
			$tpl = new static($name);
		}
		elseif (TL_MODE == 'BE')
		{
			$tpl = new BackendTemplate($name);
		}
		else
		{
			$tpl = new FrontendTemplate($name);
		}
		if ($data !== null)
		{
			$tpl->setData($data);
		}
		
		echo $tpl->parse();
	}
473539
protected function createComponent($name)
    {
        $result = null;

        $config = $this->getComponentConfig($name);

        if ($config !== null && isset($config['class'])) {
            $result = new $config['class'];
            if (!($result instanceof \pwf\basic\interfaces\Component)) {
                throw new \Exception('Component must implement \'Component\' interface',
                500);
            }
            $result->loadConfiguration($config);
        }

        return $result;
    }
700527
public function addComponentLayout($name, ComponentLayout $component_layout) {
    $this->componentLayouts[(string) $name] = $component_layout;
    return $this;
  }
1255886
public function findOrFail($name)
    {
        $component = $this->find($name);

        if ($component !== null) {
            return $component;
        }

        throw new ComponentNotFoundException("Component [{$name}] does not exist!");
    }
102891
public function publish($name, $source)
    {
        $package = str_replace('_', '-', $name);

        $destination = $this->publishPath .str_replace('/', DS, "/packages/{$package}");

        if (! $this->files->isDirectory($destination)) {
            $this->files->makeDirectory($destination, 0777, true);
        }

        $success = $this->files->copyDirectory($source, $destination);

        if (! $success) {
            throw new \RuntimeException("Unable to publish assets.");
        }

        return $success;
    }