Get the absolute path to the given $plugin.

@param string $plugin The name of the plugin.
@return string
344758
protected function _getPluginPath($plugin)
    {
        if (!Plugin::loaded($plugin)) {
            throw new MissingPluginException('Plugin ' . $plugin . ' is not loaded.');
        }
        $pluginPath = Plugin::path($plugin);

        return $pluginPath;
    }
908622
function getPluginName() {
        if ($this->plugin) {
            $manager = core_plugin_manager::instance();
            list($plugintype, $pluginname) = core_component::normalize_component($this->plugin);
            return $manager->plugintype_name($plugintype) . ' / ' . $manager->plugin_name($this->plugin);
        } else {
            return '';
        }
    }
48931
protected function getPlugin($plugin)
    {
        $path = $this->plugin->getPublicDirectory() . '/plugins/' . $plugin;
        
        if (file_exists($path) && is_dir($path)) {
            $files = scandir($path);
            
            foreach ($files as $file) {
                $pattern = defined('HHVM_VERSION') ? '/\.(php|hh)$/' : '/\.php$/';
                
                if (preg_match($pattern, $file)) {
                    $content = file_get_contents($path . '/' . $file);
                    
                    if (preg_match('/\/\*(?!.*\*\/.*Plugin Name).*Plugin Name/si', $content)) {
                        return $plugin . '/' . $file;
                    }
                }
            }
        }
        
        if (file_exists($path . '.php')) {
            return $plugin . '.php';
        }
        
        if (defined('HHVM_VERSION') && file_exists($path . '.hh')) {
            return $plugin . '.hh';
        }
        
        return false;
    }
828944
public function path($type, $plugin = null)
	{
		static $paths = array();

		if (!isset($paths[$type . $plugin]))
		{
			$paths[$type . $plugin] = '';

			$p = DS . 'plugins' . DS . $type . ($plugin ? DS . $plugin : '');

			foreach (array(PATH_APP, PATH_CORE) as $base)
			{
				if (is_dir($base . $p))
				{
					$paths[$type . $plugin] = $base . $p;
					break;
				}
			}
		}

		return $paths[$type . $plugin];
	}
268670
public static function unload($plugin = null)
    {
        if (self::loaded($plugin)) {
            $locales = Configure::read('App.paths.locales');
            foreach ($locales as $key => $path) {
                if ($path == self::getLocalePath($plugin)) {
                    unset($locales[$key]);
                }
            }

            Configure::write('App.paths.locales', $locales);
        }

        parent::unload($plugin);
    }
388386
public static function getPlugin($plugin) {
        return self::cache(array(__METHOD__, $plugin), function() use ($plugin) {
            $path = null;

            if ($plugin !== Configure::read('Admin.coreName')) {
                if (!CakePlugin::loaded($plugin)) {
                    return null;
                }

                $path = CakePlugin::path($plugin);
            }

            return array(
                'title' => $plugin,
                'path' => $path,
                'slug' => Inflector::underscore($plugin),
                'models' => Admin::getPluginModels($plugin)
            );
        });
    }
251279
protected function getMenuMethods($plugin)
    {
        //Gets all methods from `$PLUGIN\View\Helper\MenuHelper`
        $methods = get_child_methods(sprintf('\%s\View\Helper\MenuHelper', $plugin));

        //Filters invalid name methods and returns
        return $methods ? array_values(preg_grep('/^(?!_).+$/', $methods)) : [];
    }
1025866
private function get_plugin_checksums( $plugin, $version ) {
		$url = str_replace(
			array(
				'{slug}',
				'{version}',
			),
			array(
				$plugin,
				$version,
			),
			$this->url_template
		);

		$options = array(
			'timeout' => 30,
		);

		$headers  = array(
			'Accept' => 'application/json',
		);
		$response = Utils\http_request( 'GET', $url, null, $headers, $options );

		if ( ! $response->success || 200 !== $response->status_code ) {
			return false;
		}

		$body = trim( $response->body );
		$body = json_decode( $body, true );

		if ( ! is_array( $body ) || ! isset( $body['files'] ) || ! is_array( $body['files'] ) ) {
			return false;
		}

		return $body['files'];
	}
133920
public function get_root_path($repository){
    if ( \is_string($repository) ){
      $repository = $this->repository($repository);
    }
    if ( !empty($repository) && !empty($repository['bbn_path']) ){
      $repository_path = !empty($repository['path']) ? '/' . $repository['path'] : '';
      $path = self::decipher_path($repository['bbn_path'] . $repository_path) . '/';
      return \bbn\str::parse_path($path);
    }
    return false;
  }
1138900
public function adminPath($filename, $absolute = true)
    {
        $path = "ext/{$this->plugin->getName()}/admin/templates/$filename";
        if ($absolute)
        {
            $path = $this->getFullPath($path);
        }
        return $path;
    }
938564
protected function _getAbsPath(string $resName): string
    {
        foreach ($this->_resDir as $dir) {
            $absPath = rtrim($dir, DIRECTORY_SEPARATOR)
                . DIRECTORY_SEPARATOR
                . $resName;

            if (file_exists($absPath)) {
                return $absPath;
            }
        }

        return "";
    }
238891
public static function version($plugin = null) {
		if (empty($plugin)) {
			try {
				$plugin = self::plugin(self::path(true));
			} catch (Exception $e) {}
		}

		if (empty($plugin)) {
			throw new Exception();
		}

		$name = $plugin . '.version';

		if (!Configure::check($name)) {
			$versionPath = CakePlugin::path($plugin) . 'VERSION';
			if (!file_exists($versionPath)) {
				throw new Exception();
			}
			$content = file($versionPath);
			Configure::write($name, trim(array_pop($content)));
		}

		return Configure::read($name);
	}
387460
public function getBasePath() : string
    {
        $baseUri = $this->getBase();
        $path = ltrim($this->getPath(), "/");

        $absoluteUri = $baseUri . (($path === "") ? "" : "/" . $path);

        return $absoluteUri;
    }
1102010
public function getPluginOption($plugin, $option = null)
    {
        $option = $option ? '.'.$option : '';

        return $this->config->get('plugins.config.'.$plugin.$option);
    }
68051
protected function _camelizePlugin($plugin) {
		if (strpos($plugin, '/') === false) {
			return Inflector::camelize($plugin);
		}
		list($vendor, $plugin) = explode('/', $plugin, 2);
		return Inflector::camelize($vendor) . '/' . Inflector::camelize($plugin);
	}
859921
private function getDoneStringForPlugin($plugin, $idSites)
    {
        return Rules::getDoneStringFlagFor(
                    $idSites,
                    $this->params->getSegment(),
                    $this->getPeriodLabel(),
                    $plugin
        );
    }
1169689
protected static function stripAbsolutePath(array $paths, $plugin = null): array
    {
        foreach (App::path('Template', $plugin) as $templatesPath) {
            array_walk($paths, function (&$path) use ($templatesPath) {
                if (substr($path, 0, strlen($templatesPath)) == $templatesPath) {
                    $path = substr($path, strlen($templatesPath));
                }
            });
        }

        return $paths;
    }