1 | <?php |
||||
2 | |||||
3 | /** |
||||
4 | * @license GPLv3, http://www.gnu.org/copyleft/gpl.html |
||||
5 | * @copyright Aimeos (aimeos.org), 2016 |
||||
6 | * @package TYPO3 |
||||
7 | */ |
||||
8 | |||||
9 | |||||
10 | namespace Aimeos\Aimeos\Custom; |
||||
11 | |||||
12 | |||||
13 | /** |
||||
14 | * Performs setup and installation steps during composer installs |
||||
15 | * |
||||
16 | * @package TYPO3 |
||||
17 | */ |
||||
18 | class Composer |
||||
19 | { |
||||
20 | /** |
||||
21 | * Installs the shop files. |
||||
22 | * |
||||
23 | * @param \Composer\Script\Event $event Event instance |
||||
0 ignored issues
–
show
|
|||||
24 | * @throws \RuntimeException If an error occured |
||||
25 | */ |
||||
26 | public static function install(\Composer\Script\Event $event) |
||||
27 | { |
||||
28 | $repository = $event->getComposer()->getRepositoryManager()->getLocalRepository(); |
||||
29 | |||||
30 | if (($t3package = $repository->findPackage('aimeos/aimeos-typo3', '*')) === null) { |
||||
31 | throw new \RuntimeException('No installed package "aimeos/aimeos-typo3" found'); |
||||
32 | } |
||||
33 | |||||
34 | $installer = $event->getComposer()->getInstallationManager(); |
||||
35 | $t3path = $installer->getInstallPath($t3package); |
||||
36 | |||||
37 | if (($package = $repository->findPackage('aimeos/ai-client-html', '*')) !== null) { |
||||
38 | $event->getIO()->write('Installing Aimeos public files from HTML client'); |
||||
39 | |||||
40 | $path = $installer->getInstallPath($package); |
||||
41 | self::copyRecursive($path . '/client/html/themes', $t3path . '/Resources/Public/Themes'); |
||||
42 | } |
||||
43 | |||||
44 | self::join($event); |
||||
45 | } |
||||
46 | |||||
47 | |||||
48 | /** |
||||
49 | * Copies the source directory recursively to the destination |
||||
50 | * |
||||
51 | * @param string $src Source directory path |
||||
52 | * @param string $dest Target directory path |
||||
53 | * @throws \RuntimeException If an error occured |
||||
54 | */ |
||||
55 | protected static function copyRecursive(string $src, string $dest) |
||||
56 | { |
||||
57 | self::createDirectory($dest); |
||||
58 | |||||
59 | $iterator = new \RecursiveIteratorIterator( |
||||
60 | new \RecursiveDirectoryIterator($src, \RecursiveDirectoryIterator::SKIP_DOTS), |
||||
61 | \RecursiveIteratorIterator::SELF_FIRST |
||||
62 | ); |
||||
63 | |||||
64 | foreach ($iterator as $item) { |
||||
65 | $target = $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName(); |
||||
0 ignored issues
–
show
The method
getSubPathName() does not exist on RecursiveIteratorIterator .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||||
66 | |||||
67 | if ($item->isDir() === false) { |
||||
68 | if (copy($item, $target) === false) { |
||||
69 | throw new \RuntimeException(sprintf('Unable to copy file "%1$s"', $item)); |
||||
70 | } |
||||
71 | } else { |
||||
72 | self::createDirectory($target); |
||||
73 | } |
||||
74 | } |
||||
75 | } |
||||
76 | |||||
77 | |||||
78 | /** |
||||
79 | * Creates a new directory if it doesn't exist yet |
||||
80 | * |
||||
81 | * @param string $dir Absolute path of the new directory |
||||
82 | * @throws \RuntimeException If directory couldn't be created |
||||
83 | */ |
||||
84 | protected static function createDirectory(string $dir) |
||||
85 | { |
||||
86 | $perm = 0755; |
||||
87 | |||||
88 | if (is_dir($dir) === false && mkdir($dir, $perm, true) === false) { |
||||
89 | $msg = 'Unable to create directory "%1$s" with permission "%2$s"'; |
||||
90 | throw new \RuntimeException(sprintf($msg, $dir, $perm)); |
||||
91 | } |
||||
92 | } |
||||
93 | |||||
94 | |||||
95 | /** |
||||
96 | * Join community |
||||
97 | * |
||||
98 | * @param Event $event Event instance |
||||
0 ignored issues
–
show
|
|||||
99 | * @throws \RuntimeException If an error occured |
||||
100 | */ |
||||
101 | protected static function join(\Composer\Script\Event $event) |
||||
102 | { |
||||
103 | try { |
||||
104 | if (!$event->getIO()->hasAuthentication('github.com')) { |
||||
105 | return; |
||||
106 | } |
||||
107 | |||||
108 | $options = [ |
||||
109 | 'http' => [ |
||||
110 | 'method' => 'POST', |
||||
111 | 'header' => ['Content-Type: application/json'], |
||||
112 | 'content' => json_encode(['query' => 'mutation{ |
||||
113 | _1: addStar(input:{clientMutationId:"_1",starrableId:"MDEwOlJlcG9zaXRvcnkxMDMwMTUwNzA="}){clientMutationId} |
||||
114 | _2: addStar(input:{clientMutationId:"_2",starrableId:"MDEwOlJlcG9zaXRvcnkzMTU0MTIxMA=="}){clientMutationId} |
||||
115 | _3: addStar(input:{clientMutationId:"_3",starrableId:"MDEwOlJlcG9zaXRvcnkyNjg4MTc2NQ=="}){clientMutationId} |
||||
116 | _4: addStar(input:{clientMutationId:"_4",starrableId:"MDEwOlJlcG9zaXRvcnkyMjIzNTY4OTA="}){clientMutationId} |
||||
117 | _5: addStar(input:{clientMutationId:"_5",starrableId:"R_kgDOG1PAJw"}){clientMutationId} |
||||
118 | }' |
||||
119 | ]) |
||||
120 | ] |
||||
121 | ]; |
||||
122 | $config = $event->getComposer()->config(); |
||||
123 | |||||
124 | if (method_exists('\Composer\Factory', 'createHttpDownloader')) { |
||||
125 | \Composer\Factory::createHttpDownloader($event->getIO(), $config) |
||||
126 | ->get('https://api.github.com/graphql', $options); |
||||
127 | } else { |
||||
128 | \Composer\Factory::createRemoteFilesystem($event->getIO(), $config) |
||||
129 | ->getContents('github.com', 'https://api.github.com/graphql', false, $options); |
||||
130 | } |
||||
131 | } catch(\Exception $e) {} |
||||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
|
|||||
132 | } |
||||
133 | } |
||||
134 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths