├── .github ├── ISSUE_TEPLATES │ ├── Bug_report.md │ ├── Feature_request.md │ └── Support_question.md ├── PULL_REQUEST_TEMPLATE.md └── SECURITY.md ├── .gitignore ├── Application ├── Routine │ ├── ApiRoutine.php │ └── RenderDashboardRoutine.php └── RoutineInterface.php ├── CHANGELOG-1.0.md ├── CHANGELOG-1.1.md ├── Configurators └── Configurator.php ├── Console └── BuildExtensions.php ├── Controller ├── Application.php └── Dashboard.php ├── Definition ├── Application │ ├── Application.php │ ├── ApplicationInterface.php │ └── ApplicationMetadata.php ├── MappingResource.php ├── Package │ ├── ConfigurablePackage.php │ ├── ConfigurablePackageInterface.php │ ├── ContainerBuilderAwarePackageInterface.php │ ├── Package.php │ ├── PackageInterface.php │ └── PackageMetadata.php ├── PackageManager.php ├── RouteLoader.php └── Routing │ ├── ApiRoutingResourceInterface.php │ ├── ExposedRoutingResourceInterface.php │ ├── ProtectedRoutingResourceInterface.php │ └── RoutingResourceInterface.php ├── DependencyInjection ├── Configuration.php ├── ContainerExtension.php └── Passes │ ├── ConfigurationPass.php │ ├── PackageConfigurationPass.php │ └── RoutingPass.php ├── EventListener ├── Console.php └── Kernel.php ├── LICENSE.txt ├── README.md ├── Resources ├── config │ ├── routes.yaml │ ├── routes │ │ ├── private.yaml │ │ └── public.yaml │ └── services.yaml └── views │ ├── applicationDashboard.html.twig │ └── dashboard.html.twig ├── Routing └── RoutingResource.php ├── Templates ├── config.yaml └── routes.yaml ├── UIComponents └── Dashboard │ ├── Homepage │ ├── Items │ │ └── ExploreApps.php │ └── Sections │ │ └── Apps.php │ ├── Navigation │ └── Apps.php │ └── Search │ └── Apps.php ├── UVDeskExtensionFrameworkBundle.php ├── Utils ├── ApplicationCollection.php └── PackageCollection.php └── composer.json /.github/ISSUE_TEPLATES/Bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🐛 Bug Report 3 | about: Report errors and problems 4 | 5 | --- 6 | 7 | **Description** 8 | 9 | 10 | **How to reproduce** 11 | 12 | 13 | **Possible Solution** 14 | 15 | 16 | **Additional context** 17 | -------------------------------------------------------------------------------- /.github/ISSUE_TEPLATES/Feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🚀 Feature Request 3 | about: RFC and ideas for new features and improvements 4 | 5 | --- 6 | 7 | **Description** 8 | 9 | 10 | **Example** 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEPLATES/Support_question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: ⛔ Support Question 3 | about: Visit https://support.uvdesk.com/ to learn more about how the uvdesk team can assist you 4 | 5 | --- 6 | 7 | We use GitHub issues only to discuss about uvdesk bugs and new features. For customizations and extended support: 8 | 9 | - Contact us at support@uvdesk.com 10 | - Visit official support website (https://support.uvdesk.com/en/) 11 | - Visit our community forums (https://forums.uvdesk.com) 12 | 13 | Thanks! -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 4 | 5 | ### 1. Why is this change necessary? 6 | 7 | 8 | ### 2. What does this change do, exactly? 9 | 10 | 11 | ### 3. Please link to the relevant issues (if any). -------------------------------------------------------------------------------- /.github/SECURITY.md: -------------------------------------------------------------------------------- 1 | Security Policy 2 | =============== 3 | 4 | ⚠ PLEASE DON'T DISCLOSE SECURITY-RELATED ISSUES PUBLICLY, SEE BELOW. 5 | 6 | If you have found a security issue in Uvdesk, please send the details to support@uvdesk.com and don't disclose it publicly until we can provide a fix for it. 7 | 8 | Thanks! -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /Resources/public/extensions 2 | -------------------------------------------------------------------------------- /Application/Routine/ApiRoutine.php: -------------------------------------------------------------------------------- 1 | request = $requestStack->getCurrentRequest(); 21 | } 22 | 23 | public static function getName() : string 24 | { 25 | return self::NAME; 26 | } 27 | 28 | public function getRequest() : Request 29 | { 30 | return $this->request; 31 | } 32 | 33 | public function setResponseCode(int $responseCode) 34 | { 35 | $this->responseCode = $responseCode; 36 | 37 | return $this; 38 | } 39 | 40 | public function getResponseCode() : int 41 | { 42 | return $this->responseCode; 43 | } 44 | 45 | public function setResponseData(array $responseData) 46 | { 47 | $this->responseData = $responseData; 48 | 49 | return $this; 50 | } 51 | 52 | public function getResponseData() : array 53 | { 54 | return $this->responseData; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Application/Routine/RenderDashboardRoutine.php: -------------------------------------------------------------------------------- 1 | dashboardTemplate = $dashboardTemplate; 21 | } 22 | 23 | public static function getName() : string 24 | { 25 | return self::NAME; 26 | } 27 | 28 | public function getDashboardTemplate() : DashboardTemplate 29 | { 30 | return $this->dashboardTemplate; 31 | } 32 | 33 | public function setTemplateReference($template) 34 | { 35 | $this->template = $template; 36 | 37 | return $this; 38 | } 39 | 40 | public function getTemplateReference() 41 | { 42 | return $this->template; 43 | } 44 | 45 | public function addTemplateData($name, $value) 46 | { 47 | $this->templateData[$name] = $value; 48 | 49 | return $this; 50 | } 51 | 52 | public function getTemplateData() 53 | { 54 | return $this->templateData; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Application/RoutineInterface.php: -------------------------------------------------------------------------------- 1 | container = $container; 21 | $this->mappingResource = $mappingResource; 22 | } 23 | 24 | public function configurePackage(PackageInterface $package) 25 | { 26 | $metadata = new PackageMetadata(); 27 | $attributes = $this->mappingResource->getPackage(get_class($package)); 28 | 29 | // Prepare package metadata 30 | if (empty($attributes['metadata'])) { 31 | throw new \Exception("Unable to initialize package '" . get_class($package) . "'. Missing package attributes."); 32 | } 33 | 34 | $root = $this->container->getParameter("uvdesk_extensions.dir") . "/" . $attributes['metadata']['name']; 35 | 36 | $metadata 37 | ->setRoot($root) 38 | ->setName($attributes['metadata']['name']) 39 | ->setDescription($attributes['metadata']['description']) 40 | ->setType($attributes['metadata']['type']) 41 | ->setDefinedNamespaces($attributes['metadata']['autoload']); 42 | 43 | foreach ($attributes['metadata']['package'] as $reference => $env) { 44 | $metadata->addPackageReference($reference, $env); 45 | } 46 | 47 | $package->setMetadata($metadata); 48 | 49 | if ($package instanceof ConfigurablePackageInterface) { 50 | $configurationFilepath = $this->container->getParameter("kernel.project_dir") . "/config/extensions/" . str_replace(['/', '-'], '_', $attributes['metadata']['name']) . ".yaml"; 51 | 52 | $package->setConfigurationFilepath($configurationFilepath); 53 | $package->setConfigurationParameters($attributes['configurations']); 54 | } 55 | } 56 | 57 | public function configureApplication(ApplicationInterface $application) 58 | { 59 | $packageReference = $this->getQualifiedPackageReference(get_class($application)); 60 | 61 | if (empty($packageReference)) { 62 | throw new \Exception("Unable to initialize application '" . get_class($application) . "'. No base package found."); 63 | } 64 | 65 | $application->setPackage($this->container->get($packageReference)); 66 | } 67 | 68 | public function autoconfigure() 69 | { 70 | if (false == $this->isConfigured) { 71 | foreach ($this->mappingResource->getPackages() as $id => $definition) { 72 | $namespace = substr($id, 0, strrpos($id, '\\')); 73 | 74 | $this->packages[$namespace] = [ 75 | 'id' => $id, 76 | 'tags' => $definition['tags'], 77 | 'metadata' => $definition['metadata'], 78 | ]; 79 | } 80 | } 81 | 82 | return; 83 | } 84 | 85 | private function getQualifiedPackageReference($class) : ?string 86 | { 87 | $namespaceCollection = []; 88 | 89 | foreach (explode('\\', $class) as $index => $section) { 90 | if ($index == 0) { 91 | $namespaceCollection[$index] = $section; 92 | continue; 93 | } 94 | 95 | $namespaceCollection[$index] = $namespaceCollection[$index - 1] . '\\' . $section; 96 | } 97 | 98 | $namespaceCollection = array_reverse($namespaceCollection); 99 | 100 | foreach ($namespaceCollection as $namespace) { 101 | if (isset($this->packages[$namespace])) { 102 | return $this->packages[$namespace]['id']; 103 | } 104 | } 105 | 106 | return null; 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /Console/BuildExtensions.php: -------------------------------------------------------------------------------- 1 | container = $container; 19 | 20 | parent::__construct(); 21 | } 22 | 23 | protected function configure() 24 | { 25 | $this->setName('uvdesk_extensions:configure-extensions'); 26 | } 27 | 28 | protected function execute(InputInterface $input, OutputInterface $output):int 29 | { 30 | if ('dev' != $this->container->get('kernel')->getEnvironment()) { 31 | $output->writeln("\nThis command is only allowed to be used in development environment."); 32 | 33 | return Command::INVALID; 34 | } 35 | 36 | $metadata = $this->prepareMetadata(); 37 | $lockfile = $this->updateLockfile($metadata); 38 | 39 | $this->updateComposerJson($output, $lockfile); 40 | $this->autoconfigurePackages($output, $metadata); 41 | 42 | return Command::SUCCESS; 43 | } 44 | 45 | private function prepareMetadata() 46 | { 47 | $metadata = []; 48 | $path = $this->container->getParameter('uvdesk_extensions.dir'); 49 | 50 | if (!file_exists($path) || !is_dir($path)) { 51 | throw new \Exception("No apps directory found. Looked in $path"); 52 | } 53 | 54 | foreach (array_diff(scandir($path), ['.', '..']) as $vendor) { 55 | $directory = "$path/$vendor"; 56 | 57 | if (file_exists($directory) && is_dir($directory)) { 58 | foreach (array_diff(scandir($directory), ['.', '..']) as $package) { 59 | $root = "$directory/$package"; 60 | 61 | if (file_exists($root) && is_dir($root)) { 62 | $packageMetadata = new PackageMetadata($root); 63 | 64 | if ($vendor != $packageMetadata->getVendor() || $package != $packageMetadata->getPackage()) { 65 | throw new \Exception("Invalid package extension.json file. The qualified package name should be '$vendor/$package' but the specified name is '" . $packageMetadata->getName() . "'"); 66 | } 67 | 68 | $metadata[] = $packageMetadata; 69 | } 70 | } 71 | } 72 | } 73 | 74 | // Sort packages alphabetically 75 | usort($metadata, function($data_a, $data_b) { 76 | return strcasecmp($data_a->getName(), $data_b->getName()); 77 | }); 78 | 79 | return $metadata; 80 | } 81 | 82 | private function updateLockfile(array $metadata = []) 83 | { 84 | $lockfile = [ 85 | '_readme' => [ 86 | "This file locks the dependencies of your project to a known state", 87 | "This file is @generated automatically. Avoid making changes to this file directly.", 88 | ], 89 | 'packages' => array_map(function ($packageMetadata) { 90 | return [ 91 | 'name' => $packageMetadata->getName(), 92 | 'description' => $packageMetadata->getDescription(), 93 | 'type' => $packageMetadata->getType(), 94 | 'autoload' => $packageMetadata->getDefinedNamespaces(), 95 | 'package' => $packageMetadata->getPackageReferences(), 96 | ];; 97 | }, $metadata), 98 | ]; 99 | 100 | $path = $this->container->getParameter('kernel.project_dir') . "/uvdesk.lock"; 101 | file_put_contents($path, json_encode($lockfile, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); 102 | 103 | return $lockfile; 104 | } 105 | 106 | private function updateComposerJson($output, array $lockfile = []) 107 | { 108 | $path = $this->container->getParameter('kernel.project_dir') . "/composer.json"; 109 | $prefix = str_ireplace($this->container->getParameter('kernel.project_dir') . "/", "", $this->container->getParameter('uvdesk_extensions.dir')); 110 | 111 | $json = json_decode(file_get_contents($path), true); 112 | $psr4_current = $psr4_modified = $json['autoload']['psr-4'] ?? []; 113 | 114 | foreach ($lockfile['packages'] as $package) { 115 | foreach ($package['autoload'] as $namespace => $relativePath) { 116 | $psr4_modified[$namespace] = "$prefix/" . $package['name'] . "/" . $relativePath; 117 | } 118 | } 119 | 120 | if (array_diff($psr4_modified, $psr4_current) != null) { 121 | $json['autoload']['psr-4'] = $psr4_modified; 122 | file_put_contents($path, json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); 123 | 124 | $output->writeln("New extensions have been found and added to composer.json. Dumping composer autoloader...\n"); 125 | 126 | shell_exec('composer dump-autoload'); 127 | } 128 | } 129 | 130 | private function getUnloadedReflectionClass(string $class, PackageMetadata $metadata) : \ReflectionClass 131 | { 132 | try { 133 | $reflectionClass = new \ReflectionClass($class); 134 | } catch (\ReflectionException $e) { 135 | $classPath = null; 136 | $iterations = explode('\\', $class); 137 | 138 | foreach ($metadata->getDefinedNamespaces() as $namespace => $path) { 139 | $depth = 1; 140 | $namespaceIterations = explode('\\', $namespace); 141 | 142 | foreach ($iterations as $index => $iteration) { 143 | if (empty($namespaceIterations[$index]) || $namespaceIterations[$index] != $iteration) { 144 | break; 145 | } 146 | 147 | $depth++; 148 | } 149 | 150 | if (0 === (count($namespaceIterations) - $depth)) { 151 | $path .= str_ireplace([$namespace, "\\"], ["", "/"], $class); 152 | $classPath = $metadata->getRoot() . "/$path.php"; 153 | break; 154 | } 155 | } 156 | } finally { 157 | if (empty($reflectionClass) && !empty($classPath)) { 158 | include_once $classPath; 159 | 160 | $reflectionClass = new \ReflectionClass($class); 161 | } else if (empty($reflectionClass)) { 162 | throw new \Exception("Class $class does not exist"); 163 | } 164 | } 165 | 166 | return $reflectionClass; 167 | } 168 | 169 | private function autoconfigurePackages($output, array $metadata = []) 170 | { 171 | $pathToConfig = $this->container->getParameter('kernel.project_dir') . "/config/extensions"; 172 | $pathToDoctrineConfig = $this->container->getParameter('kernel.project_dir') . "/config/packages/doctrine.yaml"; 173 | 174 | if (!file_exists($pathToConfig) || !is_dir($pathToConfig)) { 175 | mkdir($pathToConfig, 0755, true); 176 | } 177 | 178 | if (file_exists($pathToDoctrineConfig)) { 179 | $expiredNamespaces = []; 180 | $doctrine = Yaml::parseFile($pathToDoctrineConfig); 181 | $doctrineMappings = $doctrine['doctrine']['orm']['mappings']; 182 | 183 | // Filter out existing community package configurations 184 | foreach ($doctrineMappings as $namespace => $mappingDetails) { 185 | $namespaceIterations = explode('\\', $namespace); 186 | 187 | if (count($namespaceIterations) >= 2) { 188 | if ('UVDesk' == $namespaceIterations[0] && 'CommunityPackages' == $namespaceIterations[1]) { 189 | $expiredNamespaces[] = $namespace; 190 | } 191 | } 192 | } 193 | 194 | foreach ($expiredNamespaces as $namespace) { 195 | unset($doctrineMappings[$namespace]); 196 | } 197 | } 198 | 199 | foreach ($metadata as $packageMetadata) { 200 | $class = current(array_keys($packageMetadata->getPackageReferences())); 201 | $packageReflectionClass = $this->getUnloadedReflectionClass($class, $packageMetadata); 202 | 203 | if (!$packageReflectionClass->implementsInterface(PackageInterface::class)) { 204 | throw new \Exception("Class $class could not be registered as an package. Please check that it implements the " . PackageInterface::class . " interface."); 205 | } 206 | 207 | if (!empty($doctrineMappings)) { 208 | $packageDoctrineMetadata = $this->getPackageDoctrineMetadata($packageMetadata); 209 | 210 | if (!empty($packageDoctrineMetadata)) { 211 | $namespace = current(array_keys($packageDoctrineMetadata)); 212 | $doctrineMappings[$namespace] = $packageDoctrineMetadata[$namespace]; 213 | } 214 | } 215 | 216 | if ($packageReflectionClass->implementsInterface(ConfigurablePackageInterface::class)) { 217 | $configurablePackage = $packageReflectionClass->newInstanceWithoutConstructor(); 218 | $configurablePackage->setConfigurationFilepath($pathToConfig . "/" . str_replace(['/', '-'], '_', $packageMetadata->getName()) . ".yaml"); 219 | 220 | if (!file_exists($configurablePackage->getConfigurationFilepath()) || is_dir($configurablePackage->getConfigurationFilepath())) { 221 | $configurablePackage->install(); 222 | } 223 | } 224 | } 225 | 226 | if (!empty($doctrine) && !empty($doctrineMappings)) { 227 | // Add quotes, we will remove later any extra quotes 228 | foreach ($doctrineMappings as $namespace => $attributes) { 229 | $attributes['dir'] = "'" . $attributes['dir'] . "'"; 230 | $attributes['prefix'] = "'" . $attributes['prefix'] . "'"; 231 | 232 | $doctrineMappings[$namespace] = $attributes; 233 | } 234 | 235 | $doctrine['doctrine']['orm']['mappings'] = $doctrineMappings; 236 | 237 | $originalContent = file_get_contents($pathToDoctrineConfig); 238 | $modifiedContent = YAML::dump($doctrine, 6); 239 | 240 | $explodedOriginalContent = preg_split("/\r\n|\n|\r/", $originalContent); 241 | $explodedModifiedContent = preg_split("/\r\n|\n|\r/", $modifiedContent); 242 | 243 | $incr = 0; 244 | $skipFlag = false; 245 | $processedModifiedContent = []; 246 | 247 | foreach ($explodedModifiedContent as $index => $content) { 248 | if ($skipFlag || !isset($explodedOriginalContent[$index + $incr])) { 249 | $processedModifiedContent[] = $content; 250 | 251 | continue; 252 | } 253 | 254 | if ('mappings:' == trim($explodedOriginalContent[$index + $incr]) || 'mappings:' == trim($explodedModifiedContent[$index])) { 255 | $skipFlag = true; 256 | $processedModifiedContent[] = $content; 257 | 258 | continue; 259 | } else if ($content == $explodedOriginalContent[$index + $incr]) { 260 | $processedModifiedContent[] = $content; 261 | } else { 262 | if (str_replace(['\'', '"'], '', $content) == str_replace(['\'', '"'], '', $explodedOriginalContent[$index + $incr])) { 263 | $processedModifiedContent[] = $explodedOriginalContent[$index + $incr]; 264 | 265 | continue; 266 | } 267 | 268 | for ($i = $index + $incr; $i < count($explodedOriginalContent); $i++) { 269 | if (trim($explodedModifiedContent[$index]) == trim($explodedOriginalContent[$i])) { 270 | $processedModifiedContent[] = $content; 271 | break; 272 | } else if (str_replace(['\'', '"'], '', trim($explodedModifiedContent[$index])) == str_replace(['\'', '"'], '', trim($explodedOriginalContent[$i]))) { 273 | $processedModifiedContent[] = $explodedOriginalContent[$i]; 274 | break; 275 | } 276 | 277 | $incr++; 278 | $processedModifiedContent[] = $explodedOriginalContent[$i]; 279 | } 280 | } 281 | } 282 | 283 | $content = str_replace("'''", "'", implode(PHP_EOL, $processedModifiedContent)); 284 | file_put_contents($pathToDoctrineConfig, $content); 285 | } 286 | } 287 | 288 | private function getPackageDoctrineMetadata($packageMetadata) 289 | { 290 | $params = [ 291 | 'is_bundle' => false, 292 | 'type' => 'annotation', 293 | ]; 294 | 295 | $baseNamespace = current(array_keys($packageMetadata->getDefinedNamespaces())); 296 | $packageClassPath = current(array_keys($packageMetadata->getPackageReferences())); 297 | $relativePathToNamespace = $packageMetadata->getDefinedNamespaces()[$baseNamespace]; 298 | 299 | $baseNamespace = rtrim($baseNamespace, '\\'); 300 | $pathToNamespace = rtrim($packageMetadata->getRoot(), '/') . "/" . rtrim(ltrim($relativePathToNamespace, '/'), '/') . "/"; 301 | $pathToEntities = $pathToNamespace . "Entity"; 302 | 303 | if (file_exists($pathToEntities) && is_dir($pathToEntities)) { 304 | // Parse qualified vendor name 305 | $p1 = strrpos($baseNamespace, '\\'); 306 | $p2 = strrpos(substr($baseNamespace, 0, $p1), '\\'); 307 | $vendor = substr($baseNamespace, $p2 + 1, $p1 - $p2 - 1); 308 | 309 | // Parse qualified package name 310 | $p1 = strrpos($packageClassPath, '\\'); 311 | $package = substr($packageClassPath, $p1 + 1); 312 | 313 | $params['dir'] = str_replace($this->container->getParameter('kernel.project_dir'), '%kernel.project_dir%', $pathToEntities); 314 | $params['prefix'] = "$baseNamespace\\Entity"; 315 | $params['alias'] = "$vendor$package"; 316 | 317 | return [$baseNamespace => $params]; 318 | } 319 | 320 | return null; 321 | } 322 | } 323 | -------------------------------------------------------------------------------- /Controller/Application.php: -------------------------------------------------------------------------------- 1 | findApplicationByFullyQualifiedName($vendor, $package, $qualifiedName); 19 | 20 | if (empty($application)) { 21 | throw new \Exception("No application found with the qualified name of '$qualifiedName' within the '$vendor/$package' namespace.", 404); 22 | } 23 | 24 | $dispatcher = new EventDispatcher(); 25 | $dispatcher->addSubscriber($application); 26 | $dispatcher->dispatch($event, $event::getName()); 27 | 28 | // Prepare template data 29 | $templateData = array_merge([ 30 | 'dashboard' => [ 31 | 'template' => $event->getTemplateReference() 32 | ], 33 | 'application' => $application 34 | ], $event->getTemplateData()); 35 | 36 | return $this->render('@UVDeskExtensionFramework//applicationDashboard.html.twig', $templateData); 37 | } 38 | 39 | public function apiEndpointXHR($vendor, $package, $qualifiedName, ApplicationCollection $applicationCollection, ApiRoutine $event) 40 | { 41 | $application = $applicationCollection->findApplicationByFullyQualifiedName($vendor, $package, $qualifiedName); 42 | 43 | if (empty($application)) { 44 | throw new \Exception("No application found with the qualified name of '$qualifiedName' within the '$vendor/$package' namespace.", 404); 45 | } 46 | 47 | $dispatcher = new EventDispatcher(); 48 | $dispatcher->addSubscriber($application); 49 | $dispatcher->dispatch($event, $event::getName()); 50 | 51 | return new JsonResponse($event->getResponseData(), $event->getResponseCode()); 52 | } 53 | } -------------------------------------------------------------------------------- /Controller/Dashboard.php: -------------------------------------------------------------------------------- 1 | isAccessAuthorized('ROLE_AGENT_MANAGE_APP')) { 17 | return $this->redirect($this->generateUrl('helpdesk_member_dashboard')); 18 | } 19 | 20 | return $this->render('@UVDeskExtensionFramework//dashboard.html.twig', []); 21 | } 22 | 23 | public function applicationsXHR(Request $request, ApplicationCollection $applications, ContainerInterface $container) 24 | { 25 | $assetsManager = $container->get('uvdesk_extension.assets_manager'); 26 | 27 | $collection = array_map(function ($application) use ($assetsManager) { 28 | $metadata = $application->getMetadata(); 29 | $packageMetadata = $application->getPackage()->getMetadata(); 30 | 31 | return [ 32 | 'icon' => $assetsManager->getUrl($metadata->getIconPath()), 33 | 'name' => $metadata->getName(), 34 | 'qname' => $metadata->getQualifiedName(), 35 | 'reference' => [ 36 | 'vendor' => $packageMetadata->getVendor(), 37 | 'package' => $packageMetadata->getPackage(), 38 | ], 39 | ]; 40 | }, $applications->getCollection()); 41 | 42 | return new JsonResponse($collection); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Definition/Application/Application.php: -------------------------------------------------------------------------------- 1 | package)) { 19 | $this->package = $package; 20 | } 21 | 22 | return $this; 23 | } 24 | 25 | final public function getPackage() : PackageInterface 26 | { 27 | return $this->package; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Definition/Application/ApplicationInterface.php: -------------------------------------------------------------------------------- 1 | packages[$id]['tags'] = $tags; 13 | } 14 | 15 | public function setPackageMetadata($id, array $metadata) 16 | { 17 | $this->packages[$id]['metadata'] = $metadata; 18 | } 19 | 20 | public function setPackageConfigurations($id, array $configurations) 21 | { 22 | $this->packages[$id]['configurations'] = $configurations; 23 | } 24 | 25 | public function setApplication($id, array $tags) 26 | { 27 | $this->applications[$id]['tags'] = $tags; 28 | } 29 | 30 | public function getPackage($id) 31 | { 32 | return $this->packages[$id]; 33 | } 34 | 35 | public function getPackages() 36 | { 37 | return $this->packages; 38 | } 39 | 40 | public function getApplications() 41 | { 42 | return $this->applications; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Definition/Package/ConfigurablePackage.php: -------------------------------------------------------------------------------- 1 | configurationFilepath)) { 17 | $this->configurationFilepath = $configurationFilepath; 18 | } 19 | 20 | return $this; 21 | } 22 | 23 | final public function getConfigurationFilepath() : string 24 | { 25 | return $this->configurationFilepath; 26 | } 27 | 28 | final public function setConfigurationParameters(array $configurationParameters) : ConfigurablePackageInterface 29 | { 30 | if (empty($this->configurationParameters)) { 31 | $this->configurationParameters = $configurationParameters; 32 | } 33 | 34 | return $this; 35 | } 36 | 37 | final public function getConfigurationParameters() : array 38 | { 39 | return $this->configurationParameters; 40 | } 41 | 42 | public function install() : void 43 | { 44 | return; 45 | } 46 | 47 | public function updatePackageConfiguration(string $content) : void 48 | { 49 | if (empty($content)) { 50 | throw new \Exception('Configuration file cannot be empty'); 51 | } 52 | 53 | file_put_contents($this->getConfigurationFilepath(), $content); 54 | } 55 | } -------------------------------------------------------------------------------- /Definition/Package/ConfigurablePackageInterface.php: -------------------------------------------------------------------------------- 1 | metadata = $metadata; 12 | 13 | return $this; 14 | } 15 | 16 | final public function getMetadata() : PackageMetadata 17 | { 18 | return $this->metadata; 19 | } 20 | } -------------------------------------------------------------------------------- /Definition/Package/PackageInterface.php: -------------------------------------------------------------------------------- 1 | setRoot($root); 19 | 20 | foreach (json_decode(file_get_contents($path), true) as $attribute => $value) { 21 | switch ($attribute) { 22 | case 'name': 23 | $this->setName($value); 24 | break; 25 | case 'description': 26 | $this->setDescription($value); 27 | break; 28 | case 'type': 29 | $this->setType($value); 30 | break; 31 | case 'authors': 32 | // $this->setName($value); 33 | break; 34 | case 'autoload': 35 | $this->setDefinedNamespaces($value); 36 | break; 37 | case 'package': 38 | foreach ($value as $reference => $env) { 39 | $this->addPackageReference($reference, $env); 40 | } 41 | 42 | break; 43 | default: 44 | break; 45 | } 46 | } 47 | } 48 | } 49 | 50 | public function setRoot(string $root) : PackageMetadata 51 | { 52 | $this->root = $root; 53 | 54 | return $this; 55 | } 56 | 57 | public function getRoot() : string 58 | { 59 | return $this->root; 60 | } 61 | 62 | public function setName(string $name) : PackageMetadata 63 | { 64 | list($vendor, $package) = explode('/', $name); 65 | 66 | $this->name = $name; 67 | $this->vendor = $vendor; 68 | $this->package = $package; 69 | 70 | return $this; 71 | } 72 | 73 | public function getName() : string 74 | { 75 | return $this->name; 76 | } 77 | 78 | public function getVendor() : string 79 | { 80 | return $this->vendor; 81 | } 82 | 83 | public function getPackage() : string 84 | { 85 | return $this->package; 86 | } 87 | 88 | public function setDescription(string $description) : PackageMetadata 89 | { 90 | $this->description = $description; 91 | 92 | return $this; 93 | } 94 | 95 | public function getDescription() : string 96 | { 97 | return $this->description; 98 | } 99 | 100 | public function setType(string $type) : PackageMetadata 101 | { 102 | if (!in_array($type, self::$supportedTypes)) { 103 | throw new \Exception("Invalid package type " . $type . ". Supported types are [" . implode(", ", self::$supportedTypes) . "]"); 104 | } 105 | 106 | $this->type = $type; 107 | 108 | return $this; 109 | } 110 | 111 | public function getType() : string 112 | { 113 | return $this->type; 114 | } 115 | 116 | public function setDefinedNamespaces(array $definedNamespaces) 117 | { 118 | $this->definedNamespaces = $definedNamespaces; 119 | 120 | return $this; 121 | } 122 | 123 | public function getDefinedNamespaces() : array 124 | { 125 | return $this->definedNamespaces; 126 | } 127 | 128 | public function addPackageReference($reference, $env) 129 | { 130 | $this->packageReference[$reference] = $env; 131 | 132 | return $this; 133 | } 134 | 135 | public function getPackageReferences() 136 | { 137 | return $this->packageReference; 138 | } 139 | } -------------------------------------------------------------------------------- /Definition/PackageManager.php: -------------------------------------------------------------------------------- 1 | container = $container; 21 | $this->pathToPackageConfigurations = $container->getParameter("kernel.project_dir") . "/config/extensions"; 22 | } 23 | 24 | public function autoconfigure() 25 | { 26 | $twigLoader = $this->container->get('uvdesk_extension.twig_loader'); 27 | 28 | foreach ($this->packages as $package) { 29 | $metadata = $package->getMetadata(); 30 | $class = new \ReflectionClass($package); 31 | 32 | $pathToExtensionsTwigResources = dirname($class->getFileName()) . "/Resources/views"; 33 | 34 | if (is_dir($pathToExtensionsTwigResources)) { 35 | $twigLoader->addPath($pathToExtensionsTwigResources, sprintf("_uvdesk_extension_%s_%s", $metadata->getVendor(), $metadata->getPackage())); 36 | } 37 | } 38 | } 39 | 40 | public function getPackages() 41 | { 42 | return $this->packages; 43 | } 44 | 45 | public function getApplications() : array 46 | { 47 | return $this->applications; 48 | } 49 | 50 | public function getApplicationByReference($reference) : ApplicationInterface 51 | { 52 | if (empty($this->applications[$reference])) { 53 | throw new \Exception('No application found'); 54 | } 55 | 56 | return $this->applications[$reference]; 57 | } 58 | 59 | public function getApplicationByAttributes($vendor, $extension, $qualifiedName) : ApplicationInterface 60 | { 61 | if (empty($this->organizedCollection[$vendor][$extension])) { 62 | throw new \Exception(sprintf("No applications found under the %s/%s extension namespace", $vendor, $extension)); 63 | } else if (empty($this->organizedCollection[$vendor][$extension][$qualifiedName])) { 64 | throw new \Exception(sprintf("No application %s found under the %s/%s extension namespace", $qualifiedName, $vendor, $extension)); 65 | } 66 | 67 | return $this->organizedCollection[$vendor][$extension][$qualifiedName]; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Definition/RouteLoader.php: -------------------------------------------------------------------------------- 1 | env = $container->get('kernel')->getEnvironment(); 27 | } 28 | 29 | public function addApiRoutingResource(ApiRoutingResourceInterface $routingResource, array $tags = []) 30 | { 31 | if (empty($tags)) { 32 | $this->apiRoutingResources[] = $routingResource; 33 | 34 | return; 35 | } 36 | 37 | foreach ($tags as $tag) { 38 | if (empty($tag) || empty($tag['env'])) { 39 | $this->apiRoutingResources[] = $routingResource; 40 | } else if (!empty($tag['env']) && $this->env === $tag['env']) { 41 | $this->apiRoutingResources[] = $routingResource; 42 | } 43 | } 44 | } 45 | 46 | public function addExposedRoutingResource(ExposedRoutingResourceInterface $routingResource, array $tags = []) 47 | { 48 | if (empty($tags)) { 49 | $this->exposedRoutingResources[] = $routingResource; 50 | 51 | return; 52 | } 53 | 54 | foreach ($tags as $tag) { 55 | if (empty($tag) || empty($tag['env'])) { 56 | $this->exposedRoutingResources[] = $routingResource; 57 | } else if (!empty($tag['env']) && $this->env === $tag['env']) { 58 | $this->exposedRoutingResources[] = $routingResource; 59 | } 60 | } 61 | } 62 | 63 | public function addProtectedRoutingResource(ProtectedRoutingResourceInterface $routingResource, array $tags = []) 64 | { 65 | if (empty($tags)) { 66 | $this->protectedRoutingResources[] = $routingResource; 67 | 68 | return; 69 | } 70 | 71 | foreach ($tags as $tag) { 72 | if (empty($tag) || empty($tag['env'])) { 73 | $this->protectedRoutingResources[] = $routingResource; 74 | } else if (!empty($tag['env']) && $this->env === $tag['env']) { 75 | $this->protectedRoutingResources[] = $routingResource; 76 | } 77 | } 78 | } 79 | 80 | public function load($resource, $type = null) 81 | { 82 | $routeCollection = new RouteCollection(); 83 | 84 | // Add api routing resources 85 | foreach ($this->apiRoutingResources as $routingResource) { 86 | $collection = $this->import($routingResource->getResourcePath(), $routingResource->getResourceType()); 87 | 88 | foreach ($collection->all() as $name => $route) { 89 | $route->setPath(self::API_PATH_PREFIX . ltrim($route->getPath(), '/')); 90 | $route->addDefaults(['_locale' => '%locale%']); 91 | $route->addRequirements(['_locale' => '%app_locales%']); 92 | } 93 | 94 | $routeCollection->addCollection($collection); 95 | } 96 | 97 | // Add private routing resources 98 | foreach ($this->protectedRoutingResources as $routingResource) { 99 | $collection = $this->import($routingResource->getResourcePath(), $routingResource->getResourceType()); 100 | 101 | foreach ($collection->all() as $name => $route) { 102 | $route->setPath(self::PROTECTED_PATH_PREFIX . ltrim($route->getPath(), '/')); 103 | $route->addDefaults(['_locale' => '%locale%']); 104 | $route->addRequirements(['_locale' => '%app_locales%']); 105 | } 106 | 107 | $routeCollection->addCollection($collection); 108 | } 109 | 110 | // Add public routing resources 111 | foreach ($this->exposedRoutingResources as $routingResource) { 112 | $collection = $this->import($routingResource->getResourcePath(), $routingResource->getResourceType()); 113 | 114 | foreach ($collection->all() as $name => $route) { 115 | $route->setPath(self::EXPOSED_PATH_PREFIX . ltrim($route->getPath(), '/')); 116 | $route->addDefaults(['_locale' => '%locale%']); 117 | $route->addRequirements(['_locale' => '%app_locales%']); 118 | } 119 | 120 | $routeCollection->addCollection($collection); 121 | } 122 | 123 | return $routeCollection; 124 | } 125 | 126 | public function supports($resource, $type = null) 127 | { 128 | return 'uvdesk_extensions' === $type; 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /Definition/Routing/ApiRoutingResourceInterface.php: -------------------------------------------------------------------------------- 1 | getRootNode('uvdesk_extensions') 14 | ->children() 15 | ->node('dir', 'scalar')->defaultValue('%kernel.project_dir%/apps')->end() 16 | ->end(); 17 | 18 | return $treeBuilder; 19 | } 20 | } -------------------------------------------------------------------------------- /DependencyInjection/ContainerExtension.php: -------------------------------------------------------------------------------- 1 | processConfiguration($this->getConfiguration($configs, $container), $configs) as $param => $value) { 39 | switch ($param) { 40 | case 'dir': 41 | $container->setParameter("uvdesk_extensions.dir", $value); 42 | break; 43 | default: 44 | break; 45 | } 46 | } 47 | 48 | // Define services 49 | $loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); 50 | $loader->load('services.yaml'); 51 | 52 | // Compile modules 53 | $env = $container->getParameter('kernel.environment'); 54 | $path = $container->getParameter("kernel.project_dir") . "/uvdesk.lock"; 55 | $mappingResource = $container->findDefinition(MappingResource::class); 56 | $availableConfigurations = $this->parsePackageConfigurations($container->getParameter("kernel.project_dir") . "/config/extensions"); 57 | 58 | foreach ($this->getCachedPackages($path) as $attributes) { 59 | $reference = current(array_keys($attributes['package'])); 60 | $supportedEnvironments = $attributes['package'][$reference]; 61 | 62 | // Check if package is supported in the current environment 63 | if (in_array('all', $supportedEnvironments) || in_array($env, $supportedEnvironments)) { 64 | $class = new \ReflectionClass($reference); 65 | 66 | if (!$class->implementsInterface(PackageInterface::class)) { 67 | throw new \Exception("Class $reference could not be registered as a package. Please check that it implements the " . PackageInterface::class . " interface."); 68 | } 69 | 70 | if ($class->implementsInterface(ConfigurablePackageInterface::class)) { 71 | $schema = $class->newInstanceWithoutConstructor()->getConfiguration(); 72 | 73 | if (!empty($schema)) { 74 | $qualifiedName = str_replace(['/', '-'], '_', $attributes['name']); 75 | 76 | if (empty($availableConfigurations[$qualifiedName])) { 77 | throw new \Exception("No available configurations found for package '" . $attributes['name'] . "'"); 78 | } 79 | 80 | // Validate package configuration params 81 | $packageConfigurations = $this->processConfiguration($schema, $availableConfigurations[$qualifiedName]); 82 | 83 | // Unset and cache package params for later re-use 84 | unset($availableConfigurations[$qualifiedName]); 85 | $mappingResource->addMethodCall('setPackageConfigurations', array($reference, $packageConfigurations)); 86 | } 87 | } 88 | 89 | // Prepare package for configuration 90 | $this->loadPackageServices($class->getFileName(), $loader); 91 | 92 | if ($container->hasDefinition($reference)) { 93 | $mappingResource->addMethodCall('setPackageMetadata', array($reference, $attributes)); 94 | } 95 | } 96 | } 97 | 98 | if (!empty($availableConfigurations)) { 99 | // @TODO: Raise exception about invalid configurations 100 | dump('Invalid configurations found'); 101 | dump($availableConfigurations); 102 | die; 103 | } 104 | 105 | // Configure services 106 | $container->registerForAutoconfiguration(PackageInterface::class)->addTag(PackageInterface::class)->setLazy(true)->setPublic(true); 107 | $container->registerForAutoconfiguration(ApplicationInterface::class)->addTag(ApplicationInterface::class)->setLazy(true)->setPublic(true); 108 | $container->registerForAutoconfiguration(ContainerBuilderAwarePackageInterface::class)->addTag(ContainerBuilderAwarePackageInterface::class); 109 | $container->registerForAutoconfiguration(RoutingResourceInterface::class)->addTag(RoutingResourceInterface::class); 110 | } 111 | 112 | private function getCachedPackages($path) : array 113 | { 114 | try { 115 | if (file_exists($path)) { 116 | return json_decode(file_get_contents($path), true)['packages'] ?? []; 117 | } 118 | } catch (\Exception $e) { 119 | // Skip module compilation ... 120 | } 121 | 122 | return []; 123 | } 124 | 125 | private function loadPackageServices($classPath, YamlFileLoader $loader) 126 | { 127 | $path = dirname($classPath) . "/Resources/config/services.yaml"; 128 | 129 | if (file_exists($path)) { 130 | $loader->load($path); 131 | } 132 | } 133 | 134 | private function parsePackageConfigurations($prefix) : array 135 | { 136 | $configs = []; 137 | 138 | if (file_exists($prefix) && is_dir($prefix)) { 139 | foreach (array_diff(scandir($prefix), ['.', '..']) as $extensionConfig) { 140 | $path = "$prefix/$extensionConfig"; 141 | 142 | if (!is_dir($path) && 'yaml' === pathinfo($path, PATHINFO_EXTENSION)) { 143 | $configs[pathinfo($path, PATHINFO_FILENAME)] = Yaml::parseFile($path); 144 | } 145 | } 146 | } 147 | 148 | return $configs; 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /DependencyInjection/Passes/ConfigurationPass.php: -------------------------------------------------------------------------------- 1 | has(MappingResource::class)) { 20 | $configurator = new Reference(Configurator::class); 21 | $mappingResource = $container->findDefinition(MappingResource::class); 22 | 23 | foreach ($container->findTaggedServiceIds(PackageInterface::class) as $reference => $tags) { 24 | $mappingResource->addMethodCall('setPackage', array($reference, $tags)); 25 | 26 | $packageDefinition = $container->findDefinition($reference); 27 | $packageDefinition->setConfigurator([$configurator, 'configurePackage']); 28 | } 29 | 30 | foreach ($container->findTaggedServiceIds(ApplicationInterface::class) as $reference => $tags) { 31 | $mappingResource->addMethodCall('setApplication', array($reference, $tags)); 32 | 33 | $applicationDefinition = $container->findDefinition($reference); 34 | $applicationDefinition->setConfigurator([$configurator, 'configureApplication']); 35 | } 36 | 37 | $container->findDefinition(Configurator::class)->addMethodCall('autoconfigure'); 38 | } 39 | 40 | if ($container->has(PackageCollection::class)) { 41 | $packageCollectionDefinition = $container->findDefinition(PackageCollection::class); 42 | $packageCollectionDefinition->setLazy(true)->addMethodCall('organizeCollection'); 43 | } 44 | 45 | if ($container->has(ApplicationCollection::class)) { 46 | $packageCollectionDefinition = $container->findDefinition(ApplicationCollection::class); 47 | $packageCollectionDefinition->setLazy(true)->addMethodCall('organizeCollection')->setLazy(true); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /DependencyInjection/Passes/PackageConfigurationPass.php: -------------------------------------------------------------------------------- 1 | findTaggedServiceIds(ContainerBuilderAwarePackageInterface::class) as $reference => $tags) { 15 | $package = (new \ReflectionClass($reference))->newInstanceWithoutConstructor(); 16 | $package->process($container); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /DependencyInjection/Passes/RoutingPass.php: -------------------------------------------------------------------------------- 1 | has(RouteLoader::class)) { 19 | $router = $container->findDefinition(RouteLoader::class); 20 | 21 | foreach ($container->findTaggedServiceIds(RoutingResourceInterface::class) as $id => $tags) { 22 | $class = new \ReflectionClass($id); 23 | 24 | if ($class->implementsInterface(ExposedRoutingResourceInterface::class)) { 25 | $router->addMethodCall('addExposedRoutingResource', array(new Reference($id), $tags)); 26 | } else if ($class->implementsInterface(ProtectedRoutingResourceInterface::class)) { 27 | $router->addMethodCall('addProtectedRoutingResource', array(new Reference($id), $tags)); 28 | } else if ($class->implementsInterface(ApiRoutingResourceInterface::class)) { 29 | $router->addMethodCall('addApiRoutingResource', array(new Reference($id), $tags)); 30 | } 31 | } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /EventListener/Console.php: -------------------------------------------------------------------------------- 1 | kernel = $kernel; 22 | $this->container = $container; 23 | $this->mappingResource = $mappingResource; 24 | } 25 | 26 | public function onConsoleCommand(ConsoleCommandEvent $event) 27 | { 28 | $command = $event->getCommand(); 29 | 30 | switch (true) { 31 | case $command instanceof SymfonyFrameworkCommand\CacheClearCommand: 32 | // $application = new Application($this->kernel); 33 | 34 | // $application->setAutoExit(false); 35 | // $application->run(new ArrayInput(['command' => 'uvdesk_extensions:build']), $event->getOutput()); 36 | break; 37 | case $command instanceof SymfonyFrameworkCommand\AssetsInstallCommand: 38 | // Update symbolic links between packages 39 | $this->symlinkAvailablePackageResources(); 40 | 41 | break; 42 | default: 43 | break; 44 | } 45 | 46 | return; 47 | } 48 | 49 | public function onConsoleTerminate(ConsoleTerminateEvent $event) 50 | { 51 | return; 52 | } 53 | 54 | private function scanDirectory(string $path, bool $return_full_path = true) 55 | { 56 | if (!file_exists($path) || !is_dir($path)) { 57 | throw new \Exception("Not a directory : '$path'"); 58 | } 59 | 60 | $scannedFiles = array_diff(scandir($path), ['.', '..']); 61 | 62 | if ($return_full_path) { 63 | $scannedFiles = array_map(function ($file) use ($path) { 64 | return "$path/$file"; 65 | }, $scannedFiles); 66 | } 67 | 68 | return $scannedFiles; 69 | } 70 | 71 | private function emptyDirectory(string $path) 72 | { 73 | if (!file_exists($path) || !is_dir($path)) { 74 | throw new \Exception("Not a directory : '$path'"); 75 | } 76 | 77 | $scannedFiles = $this->scanDirectory($path); 78 | 79 | if (!empty($scannedFiles)) { 80 | foreach ($scannedFiles as $filepath) { 81 | if (!is_dir($filepath) || is_link($filepath)) { 82 | unlink($filepath); 83 | } else { 84 | if (null != $this->scanDirectory($filepath)) { 85 | $this->emptyDirectory($filepath); 86 | } 87 | 88 | rmdir($filepath); 89 | } 90 | } 91 | } 92 | } 93 | 94 | private function symlinkAvailablePackageResources() 95 | { 96 | $collection = []; 97 | $prefix = dirname(__DIR__) . '/Resources/public/extensions'; 98 | $prefix = $this->container->getParameter('kernel.project_dir') . '/public/community-packages'; 99 | 100 | foreach (array_keys($this->mappingResource->getPackages()) as $id) { 101 | $packageReflectionClass = new \ReflectionClass($id); 102 | $attributes = $this->mappingResource->getPackage($id); 103 | 104 | list($vendorName, $packageName) = explode('/', $attributes['metadata']['name']); 105 | 106 | $source = dirname($packageReflectionClass->getFileName()) . '/Resources/public'; 107 | 108 | if (file_exists($source) && is_dir($source)) { 109 | $collection[] = [ 110 | 'source' => $source, 111 | 'destination' => [ 112 | 'base' => "$prefix/$vendorName", 113 | 'path' => "$prefix/$vendorName/$packageName", 114 | ], 115 | ]; 116 | } 117 | } 118 | 119 | // Clear existing resources from extensions directory 120 | if (file_exists($prefix) && is_dir($prefix)) { 121 | $this->emptyDirectory($prefix); 122 | } 123 | 124 | // Link package assets within bundle assets 125 | foreach ($collection as $package) { 126 | if (!is_dir($package['destination']['base'])) { 127 | mkdir($package['destination']['base'], 0755, true); 128 | } 129 | 130 | symlink($package['source'], $package['destination']['path']); 131 | } 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /EventListener/Kernel.php: -------------------------------------------------------------------------------- 1 | container = $container; 20 | $this->mappingResource = $mappingResource; 21 | } 22 | 23 | public function onKernelRequest(RequestEvent $event) 24 | { 25 | if (!$event->isMasterRequest()) { 26 | return; 27 | } 28 | 29 | if ('GET' === strtoupper($event->getRequest()->getMethod())) { 30 | $this->configureTwigResources(); 31 | } 32 | } 33 | 34 | public function onKernelControllerArguments(ControllerArgumentsEvent $event) 35 | { 36 | if (!$event->isMasterRequest()) { 37 | return; 38 | } 39 | 40 | // $request = $event->getRequest(); 41 | // list($class, $method) = explode('::', $request->get('_controller')); 42 | 43 | // $reflectionClass = new \ReflectionClass($class); 44 | 45 | // if ($reflectionClass->hasMethod($method)) { 46 | // $args = []; 47 | // $controllerArguments = $event->getArguments(); 48 | 49 | // foreach ($reflectionClass->getMethod($method)->getParameters() as $index => $parameter) { 50 | // if ($parameter->getType() != null && ApplicationInterface::class === $parameter->getType()->getName()) { 51 | // if (false === (bool) ($controllerArguments[$index] instanceof ApplicationInterface)) { 52 | // $vendor = $request->get('vendor'); 53 | // $package = $request->get('extension'); 54 | // $name = $request->get('application'); 55 | 56 | // $application = $this->applicationCollection->findApplicationByFullyQualifiedName($vendor, $package, $name); 57 | 58 | // if (!empty($application)) { 59 | // $args[] = $application; 60 | 61 | // continue; 62 | // } 63 | // } 64 | // } 65 | 66 | // $args[] = $controllerArguments[$index]; 67 | // } 68 | 69 | // $event->setArguments($args); 70 | // } 71 | } 72 | 73 | private function configureTwigResources() 74 | { 75 | if ($this->isTwigConfigured) { 76 | return $this; 77 | } 78 | 79 | $twig = $this->container->get('uvdesk_extension.twig_loader'); 80 | 81 | foreach ($this->mappingResource->getPackages() as $id => $attributes) { 82 | $class = new \ReflectionClass($id); 83 | $resources = dirname($class->getFileName()) . "/Resources/views"; 84 | 85 | list($vendor, $package) = explode('/', $attributes['metadata']['name']); 86 | 87 | if (is_dir($resources)) { 88 | $twig->addPath($resources, sprintf("_uvdesk_extension_%s_%s", str_replace('-', '_', $vendor), str_replace('-', '_', $package))); 89 | } 90 | } 91 | 92 | $this->isTwigConfigured = true; 93 | 94 | return $this; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Open Software License ("OSL") v. 3.0 2 | 3 | This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: 4 | 5 | Licensed under the Open Software License version 3.0 6 | 7 | 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: 8 | 9 | 1. to reproduce the Original Work in copies, either alone or as part of a collective work; 10 | 11 | 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; 12 | 13 | 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License; 14 | 15 | 4. to perform the Original Work publicly; 16 | 17 | 5. to display the Original Work publicly. 18 | 19 | 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. 20 | 21 | 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. 22 | 23 | 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. 24 | 25 | 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). 26 | 27 | 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. 28 | 29 | 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. 30 | 31 | 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. 32 | 33 | 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including 'fair use' or 'fair dealing'). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). 34 | 35 | 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. 36 | 37 | 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. 38 | 39 | 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. 40 | 41 | 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. 42 | 43 | 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. 44 | 45 | 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. 46 | 47 | 16. Modification of This License. This License is Copyright (C) 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | The extension framework bundle empowers merchants and developers alike with the ability to utilize the full benefits of the uvdesk community. 13 | 14 | Whether you're a merchant looking for solutions to extend the capabilities of your helpdesk system, or a developer looking to roll out their own solutions for other merchants to use, the extension framework bundle provides you with all the tools necessary to easily build powerful integrations. 15 | 16 | Installation 17 | -------------- 18 | 19 | Before installing, make sure that you have [Composer][1] installed. 20 | 21 | To require the extension framework bundle into your uvdesk community helpdesk project, simply run the following from your project's root: 22 | 23 | ```bash 24 | $ composer require uvdesk/extension-framework 25 | ``` 26 | 27 | Installing packages 28 | -------------- 29 | 30 | To add packages to your helpdesk system, simply copy the desired packages into your project's **apps** directory as per the name of the package. 31 | 32 | **Example**: Suppose if we want to integrate the [uvdesk/ecommerce][2] package to our helpdesk system, we'll simply copy the package to the *apps/uvdesk/ecommerce* directory relative to our project's root. 33 | 34 | Once you've copied all the packages you would like to integrate into your helpdesk system, run the following command from your project's root: 35 | 36 | ```bash 37 | $ php bin/console uvdesk_extensions:configure-extensions 38 | ``` 39 | 40 | This command will automatically search and configure any available packages found within the apps directory. Once your packages have been configured successfully, they are ready for use. 41 | 42 | >**Please Note:** 43 | > 44 | >Although running this command alone should take care of the entire package installation process, your helpdesk system may require some futher additional configurations varying from package to package in order to ensure they work as expected. 45 | > 46 | > Therefore, it is usually a good idea to also follow up running the extension configurations command with the following commands as well: 47 | > 48 | >```bash 49 | >$ php bin/console assets:install 50 | >$ php bin/console doctrine:migrations:diff 51 | >$ php bin/console doctrine:migrations:migrate 52 | >``` 53 | > 54 | >These commands will install any missing web assets as well as update your database with any entities found within the packages. 55 | 56 | 57 | 58 | License 59 | -------------- 60 | 61 | The **UVDesk Extension Framework Bundle** and libraries included within the bundle are released under the [OSL-3.0 license][3] 62 | 63 | [1]: https://getcomposer.org/ 64 | [2]: https://github.com/uvdesk/ecommerce 65 | [3]: https://github.com/uvdesk/extension-framework/blob/master/LICENSE.txt -------------------------------------------------------------------------------- /Resources/config/routes.yaml: -------------------------------------------------------------------------------- 1 | uvdesk_extensions_private_routing_resources: 2 | resource: "routes/private.yaml" 3 | prefix: /{_locale}/%uvdesk_site_path.member_prefix%/ 4 | requirements: 5 | _locale: '%app_locales%' 6 | defaults: 7 | _locale: '%locale%' 8 | 9 | uvdesk_extensions_public_routing_resources: 10 | resource: "routes/public.yaml" 11 | prefix: / 12 | requirements: 13 | _locale: '%app_locales%' 14 | defaults: 15 | _locale: '%locale%' 16 | -------------------------------------------------------------------------------- /Resources/config/routes/private.yaml: -------------------------------------------------------------------------------- 1 | uvdesk_extensions_applications_dashboard: 2 | path: /apps 3 | controller: Webkul\UVDesk\ExtensionFrameworkBundle\Controller\Dashboard::applications 4 | defaults: { panelId: 'apps' } 5 | 6 | uvdesk_extensions_applications_dashboard_xhr: 7 | path: /apps/collection 8 | controller: Webkul\UVDesk\ExtensionFrameworkBundle\Controller\Dashboard::applicationsXHR 9 | methods: [GET, POST] 10 | 11 | uvdesk_extensions_standalone_application_dashboard: 12 | path: /apps/{vendor}/{package}/{qualifiedName} 13 | controller: Webkul\UVDesk\ExtensionFrameworkBundle\Controller\Application::dashboard 14 | 15 | uvdesk_extensions_standalone_application_api_endpoint: 16 | path: /apps/{vendor}/{package}/{qualifiedName}/api 17 | controller: Webkul\UVDesk\ExtensionFrameworkBundle\Controller\Application::apiEndpointXHR 18 | methods: [GET, POST, PUT, DELETE] 19 | 20 | uvdesk_extensions_standalone_application_callback_endpoint: 21 | path: /apps/{vendor}/{package}/{qualifiedName}/callback 22 | controller: Webkul\UVDesk\ExtensionFrameworkBundle\Controller\Application::callbackEndpointXHR 23 | methods: [GET, POST] 24 | -------------------------------------------------------------------------------- /Resources/config/routes/public.yaml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uvdesk/extension-framework/9af44f9c37bb235e3c5859d29c76ff6d0aa21838/Resources/config/routes/public.yaml -------------------------------------------------------------------------------- /Resources/config/services.yaml: -------------------------------------------------------------------------------- 1 | services: 2 | _defaults: 3 | autowire: true 4 | autoconfigure: true 5 | public: false 6 | 7 | Webkul\UVDesk\ExtensionFrameworkBundle\: 8 | resource: '../../*' 9 | exclude: '../../{DependencyInjection,Templates,Package}' 10 | 11 | Webkul\UVDesk\ExtensionFrameworkBundle\EventListener\Kernel: 12 | tags: 13 | - { name: kernel.event_listener, event: kernel.request } 14 | - { name: kernel.event_listener, event: kernel.controller_arguments } 15 | 16 | Webkul\UVDesk\ExtensionFrameworkBundle\EventListener\Console: 17 | tags: 18 | - { name: kernel.event_listener, event: console.command } 19 | - { name: kernel.event_listener, event: console.terminate } 20 | 21 | # Aliases 22 | uvdesk_extension.twig_loader: 23 | public: true 24 | alias: twig.loader 25 | 26 | uvdesk_extension.assets_manager: 27 | public: true 28 | alias: assets.packages 29 | -------------------------------------------------------------------------------- /Resources/views/applicationDashboard.html.twig: -------------------------------------------------------------------------------- 1 | {% extends "@UVDeskCoreFramework//Templates//layout.html.twig" %} 2 | 3 | {% block title %}{{ application.getMetadata().getName() }}{% endblock %} 4 | 5 | {% block templateCSS %} 6 | 11 | {% endblock %} 12 | 13 | {% block pageContent %} 14 | 15 | 16 | 17 | 18 | {% if dashboard.template is not empty %} 19 | {{ include(dashboard.template) }} 20 | {% endif %} 21 | 22 | 23 | 24 | {% endblock %} 25 | 26 | {% block footer %} 27 | {{ parent() }} 28 | {% endblock %} -------------------------------------------------------------------------------- /Resources/views/dashboard.html.twig: -------------------------------------------------------------------------------- 1 | {% extends "@UVDeskCoreFramework//Templates//layout.html.twig" %} 2 | 3 | {% block title %}{{ 'Apps Dashboard'|trans }}{% endblock %} 4 | 5 | {% block templateCSS %} 6 | 21 | {% endblock %} 22 | 23 | {% block pageContent %} 24 | 25 | 26 | {{ 'Installed Applications'|trans }} 27 | 28 | 29 | 30 | {# App Listing #} 31 | 32 | 33 | {# Navigate Listing #} 34 | 35 | 36 | 37 | {% endblock %} 38 | 39 | {% block footer %} 40 | {{ parent() }} 41 | 42 | 52 | 53 | 62 | 63 | 70 | 71 | 269 | {% endblock %} 270 | -------------------------------------------------------------------------------- /Routing/RoutingResource.php: -------------------------------------------------------------------------------- 1 | 12 | 13 | 14 | SVG; 15 | 16 | public static function getIcon() : string 17 | { 18 | return self::SVG; 19 | } 20 | 21 | public static function getTitle() : string 22 | { 23 | return "Explore Apps"; 24 | } 25 | 26 | public static function getRouteName() : string 27 | { 28 | return 'uvdesk_extensions_applications_dashboard'; 29 | } 30 | 31 | public static function getSectionReferenceId() : string 32 | { 33 | return Apps::class; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /UIComponents/Dashboard/Homepage/Sections/Apps.php: -------------------------------------------------------------------------------- 1 | 14 | 15 | 16 | SVG; 17 | 18 | public static function getIcon() : string 19 | { 20 | return self::SVG; 21 | } 22 | 23 | public static function getTitle() : string 24 | { 25 | return "Apps"; 26 | } 27 | 28 | public static function getRouteName() : string 29 | { 30 | return 'uvdesk_extensions_applications_dashboard'; 31 | } 32 | 33 | public static function getRoles() : array 34 | { 35 | return ['ROLE_AGENT_MANAGE_APP']; 36 | } 37 | 38 | public function getChildrenRoutes() : array 39 | { 40 | return []; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /UIComponents/Dashboard/Search/Apps.php: -------------------------------------------------------------------------------- 1 | 14 | 15 | 16 | SVG; 17 | 18 | public static function getIcon() : string 19 | { 20 | return self::SVG; 21 | } 22 | 23 | public static function getTitle() : string 24 | { 25 | return "Apps"; 26 | } 27 | 28 | public static function getRouteName() : string 29 | { 30 | return 'uvdesk_extensions_applications_dashboard'; 31 | } 32 | 33 | public function getChildrenRoutes() : array 34 | { 35 | return []; 36 | } 37 | 38 | public static function getRoles() : array 39 | { 40 | return ['ROLE_AGENT_MANAGE_APP']; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /UVDeskExtensionFrameworkBundle.php: -------------------------------------------------------------------------------- 1 | addCompilerPass(new RoutingPass()) 25 | ->addCompilerPass(new ConfigurationPass()) 26 | ->addCompilerPass(new PackageConfigurationPass()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Utils/ApplicationCollection.php: -------------------------------------------------------------------------------- 1 | container = $container; 22 | $this->mappingResource = $mappingResource; 23 | $this->packageCollection = $packageCollection; 24 | } 25 | 26 | public function organizeCollection() 27 | { 28 | if ($this->isOrganized) { 29 | return; 30 | } 31 | 32 | // Organize applications by vendors, packages, maintain bi-directional reference between application name & classpath. 33 | $applications = $this->mappingResource->getApplications(); 34 | 35 | foreach ($applications as $id => $tags) { 36 | // @TODO: Support tags to modify the application 37 | $class = new \ReflectionClass($id);$application = $class->newInstanceWithoutConstructor(); 38 | 39 | $metadata = $application->getMetadata(); 40 | $packageReference = $this->packageCollection->getQualifiedPackageReference($id); 41 | $packageQualifiedName = $this->packageCollection->getPackageQualifiedName($packageReference); 42 | 43 | $qualifiedName = $metadata->getQualifiedName(); 44 | $fullyQualifiedName = "$packageQualifiedName/$qualifiedName"; 45 | list($vendorName, $packageName) = explode('/', $packageQualifiedName); 46 | 47 | $this->applications[$id] = $this->container->get($id); 48 | $this->fullyQualifiedApplicationNames[$id] = $fullyQualifiedName; 49 | $this->applicationsByFullyQualifiedName[$fullyQualifiedName] = $id; 50 | $this->applicationsByQualifiedPackageName[$vendorName][$packageName][$qualifiedName] = $id; 51 | } 52 | 53 | $this->isOrganized = true; 54 | } 55 | 56 | public function getCollection() 57 | { 58 | return array_values($this->applications); 59 | } 60 | 61 | public function findApplicationsByVendor($vendor) 62 | { 63 | dump('return applications by vendor name'); 64 | die; 65 | } 66 | 67 | public function findApplicationsByPackage(PackageInterface $package) 68 | { 69 | dump('return applications by package'); 70 | die; 71 | } 72 | 73 | public function findApplicationByFullyQualifiedName($vendorName, $packageName, $applicationQualifiedName) : ?ApplicationInterface 74 | { 75 | $id = $this->applicationsByQualifiedPackageName[$vendorName][$packageName][$applicationQualifiedName] ?? null; 76 | 77 | return !empty($id) ? $this->applications[$id] : null; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /Utils/PackageCollection.php: -------------------------------------------------------------------------------- 1 | container = $container; 23 | $this->mappingResource = $mappingResource; 24 | } 25 | 26 | public function organizeCollection() 27 | { 28 | if ($this->isOrganized) { 29 | return; 30 | } 31 | 32 | // Organize packages by vendors, maintain bi-directional reference between package name & classpath. 33 | $packages = $this->mappingResource->getPackages(); 34 | 35 | foreach ($packages as $id => $attributes) { 36 | // @TODO: Support tags to modify the package 37 | $qualifiedName = $attributes['metadata']['name']; 38 | list($vendorName, $packageName) = explode('/', $qualifiedName); 39 | 40 | // Derive base namespace where the package lives 41 | $baseNamespace = substr($id, 0, strrpos($id, '\\')); 42 | 43 | $this->packages[$id] = $this->container->get($id); 44 | $this->qualifiedPackageNames[$id] = $qualifiedName; 45 | $this->packagesByBaseNamespace[$baseNamespace] = $id; 46 | $this->packagesByQualifiedName[$qualifiedName] = $id; 47 | $this->packagesByQualifiedVendorName[$vendorName][$packageName] = $id; 48 | } 49 | 50 | $this->isOrganized = true; 51 | } 52 | 53 | public function getQualifiedPackageReference($class) : ?string 54 | { 55 | $iterations = []; 56 | 57 | foreach (explode('\\', $class) as $index => $section) { 58 | if ($index == 0) { 59 | $iterations[$index] = $section; 60 | continue; 61 | } 62 | 63 | $iterations[$index] = $iterations[$index - 1] . '\\' . $section; 64 | } 65 | 66 | $iterations = array_reverse($iterations); 67 | 68 | foreach ($iterations as $namespace) { 69 | if (isset($this->packagesByBaseNamespace[$namespace])) { 70 | return $this->packagesByBaseNamespace[$namespace]; 71 | } 72 | } 73 | 74 | return null; 75 | } 76 | 77 | public function getPackageQualifiedName($id) : ?string 78 | { 79 | return $this->qualifiedPackageNames[$id] ?? null; 80 | } 81 | 82 | public function getPackageReferenceByQualifiedName($name) : ?string 83 | { 84 | return $this->packagesByQualifiedName[$name] ?? null; 85 | } 86 | 87 | public function getCollection() 88 | { 89 | return array_values($this->packages); 90 | } 91 | 92 | public function getPackageByAttributes($vendor, $package) 93 | { 94 | $orgpackages = []; 95 | $packages = $this->mappingResource->getPackages(); 96 | 97 | foreach ($packages as $id => $attributes) { 98 | $orgpackages[$attributes['metadata']['name']] = $id; 99 | } 100 | 101 | dump($vendor, $package); 102 | dump($packages); 103 | dump($orgpackages); 104 | 105 | die; 106 | 107 | // dump($this->packageCollection->getPackageByAttributes($vendor, $package)); 108 | // dump($this->mappingResource); 109 | // die; 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "uvdesk/extension-framework", 3 | "description": "UVDesk Community Helpdesk Extension Framework Bundle", 4 | "type": "symfony-bundle", 5 | "license": "MIT", 6 | "authors": [ 7 | { 8 | "name": "UVdesk Support", 9 | "email": "support@uvdesk.com" 10 | } 11 | ], 12 | "require": { 13 | "php": "^7.2.5 || ^8.0", 14 | "uvdesk/core-framework": "^1.1.5" 15 | }, 16 | "autoload": { 17 | "psr-4": { "Webkul\\UVDesk\\ExtensionFrameworkBundle\\": "" } 18 | }, 19 | "minimum-stability": "stable" 20 | } 21 | --------------------------------------------------------------------------------
2 | 3 |
6 | 7 | 8 | 9 | 10 |