first commit

This commit is contained in:
2025-08-02 16:30:27 +02:00
commit 23646bfcee
14851 changed files with 1750626 additions and 0 deletions

View File

@@ -0,0 +1,90 @@
<?php
/**
* Created by PhpStorm.
* User: joe
* Date: 3/22/17
* Time: 5:21 PM.
*/
namespace KupShop\KupShopBundle\Util\System;
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
use KupShop\KupShopBundle\Util\Functional\Mapping;
use KupShop\KupShopBundle\Util\StringUtil;
use Symfony\Component\DependencyInjection\Container;
class BundleFinder
{
/** @var Container */
private $container;
/** @var PathFinder */
private $pathFinder;
public function __construct(PathFinder $pathFinder)
{
$this->pathFinder = $pathFinder;
}
public function getBundles()
{
$bundles = $this->getContainer()->getParameter('kernel.bundles');
return array_filter($bundles, function ($value) {
return StringUtil::startsWith($value, 'KupShop')
|| StringUtil::startsWith($value, 'Shop')
|| StringUtil::startsWith($value, 'External');
});
}
public function getBundlesResource($path)
{
return Mapping::withKeys($this->getBundles(), function ($bundle, $tmp) use ($path) {
return "@{$bundle}/{$path}";
});
}
public function getBundlesPath($path)
{
return Mapping::withKeys($this->getBundles(), function ($bundle, $class) use ($path) {
$bundles = $this->getContainer()->getParameter('kernel.bundles_metadata');
return $bundles[$bundle]['path'].'/'.$path;
});
}
public function getExistingBundlesPath($path)
{
$bundles = $this->getBundlesPath($path);
$files = array_filter($bundles, function ($value) {
return file_exists($value);
});
return $files;
}
/**
* @param Container $container
*
* @return BundleFinder
*/
public function setContainer($container)
{
$this->container = $container;
return $this;
}
/**
* @return Container
*/
public function getContainer()
{
if ($this->container) {
return $this->container;
}
return $this->container = ServiceContainer::getContainer();
}
}