PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 1.10
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v1.10
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
imagify / vendor / composer / installers / src / Composer / Installers / CakePHPInstaller.php

CakePHPInstaller.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF 1.10, at vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php

66 lines 1.7 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 */
51 protected function matchesCakeVersion($matcher, $version)
52 {
53 $repositoryManager = $this->composer->getRepositoryManager();
54 if (! $repositoryManager) {
55 return false;
56 }
57
58 $repos = $repositoryManager->getLocalRepository();
59 if (!$repos) {
60 return false;
61 }
62
63 return $repos->findPackage('cakephp/cakephp', new Constraint($matcher, $version)) !== null;
64 }
65 }
66