PluginProbe
Depicter — Popup & Slider Builder / 1.5.2
Depicter — Popup & Slider Builder v1.5.2
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
depicter / vendor / composer / installers / src / Composer / Installers / CakePHPInstaller.php

CakePHPInstaller.php in Depicter — Popup & Slider Builder 1.5.2, at vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php

67 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Composer\Installers;
3
4 use Composer\DependencyResolver\Pool;
5 use Composer\Semver\Constraint\Constraint;
6
7 class CakePHPInstaller extends BaseInstaller
8 {
9 protected $locations = array(
10 'plugin' => 'Plugin/{$name}/',
11 );
12
13 /**
14 * Format package name to CamelCase
15 */
16 public function inflectPackageVars($vars)
17 {
18 if ($this->matchesCakeVersion('>=', '3.0.0')) {
19 return $vars;
20 }
21
22 $nameParts = explode('/', $vars['name']);
23 foreach ($nameParts as &$value) {
24 $value = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $value));
25 $value = str_replace(array('-', '_'), ' ', $value);
26 $value = str_replace(' ', '', ucwords($value));
27 }
28 $vars['name'] = implode('/', $nameParts);
29
30 return $vars;
31 }
32
33 /**
34 * Change the default plugin location when cakephp >= 3.0
35 */
36 public function getLocations()
37 {
38 if ($this->matchesCakeVersion('>=', '3.0.0')) {
39 $this->locations['plugin'] = $this->composer->getConfig()->get('vendor-dir') . '/{$vendor}/{$name}/';
40 }
41 return $this->locations;
42 }
43
44 /**
45 * Check if CakePHP version matches against a version
46 *
47 * @param string $matcher
48 * @param string $version
49 * @return bool
50 * @phpstan-param Constraint::STR_OP_* $matcher
51 */
52 protected function matchesCakeVersion($matcher, $version)
53 {
54 $repositoryManager = $this->composer->getRepositoryManager();
55 if (! $repositoryManager) {
56 return false;
57 }
58
59 $repos = $repositoryManager->getLocalRepository();
60 if (!$repos) {
61 return false;
62 }
63
64 return $repos->findPackage('cakephp/cakephp', new Constraint($matcher, $version)) !== null;
65 }
66 }
67