添加多个前端界面所需的图片、字体、音频等静态资源文件,包括: - 管理员后台的图标、背景图、组件图片 - 移动端页面的商品图片、用户中心图片、活动图标 - 第三方库的示例图片和字体文件 - 浏览器兼容性配置文件 - 图标字体文件(eot、ttf、woff、woff2格式) 这些资源是前端界面正常显示所必需的,之前可能因版本控制忽略或遗漏而缺失。
78 lines
2.5 KiB
PHP
78 lines
2.5 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Symfony package.
|
|
*
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Symfony\Contracts\Service;
|
|
|
|
use Psr\Container\ContainerInterface;
|
|
use Symfony\Contracts\Service\Attribute\SubscribedService;
|
|
|
|
/**
|
|
* Implementation of ServiceSubscriberInterface that determines subscribed services from
|
|
* method return types. Service ids are available as "ClassName::methodName".
|
|
*
|
|
* @author Kevin Bond <kevinbond@gmail.com>
|
|
*/
|
|
trait ServiceSubscriberTrait
|
|
{
|
|
/** @var ContainerInterface */
|
|
protected $container;
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public static function getSubscribedServices(): array
|
|
{
|
|
$services = method_exists(get_parent_class(self::class) ?: '', __FUNCTION__) ? parent::getSubscribedServices() : [];
|
|
|
|
foreach ((new \ReflectionClass(self::class))->getMethods() as $method) {
|
|
if (self::class !== $method->getDeclaringClass()->name) {
|
|
continue;
|
|
}
|
|
|
|
if (!$attribute = $method->getAttributes(SubscribedService::class)[0] ?? null) {
|
|
continue;
|
|
}
|
|
|
|
if ($method->isStatic() || $method->isAbstract() || $method->isGenerator() || $method->isInternal() || $method->getNumberOfRequiredParameters()) {
|
|
throw new \LogicException(sprintf('Cannot use "%s" on method "%s::%s()" (can only be used on non-static, non-abstract methods with no parameters).', SubscribedService::class, self::class, $method->name));
|
|
}
|
|
|
|
if (!$returnType = $method->getReturnType()) {
|
|
throw new \LogicException(sprintf('Cannot use "%s" on methods without a return type in "%s::%s()".', SubscribedService::class, $method->name, self::class));
|
|
}
|
|
|
|
$serviceId = $returnType instanceof \ReflectionNamedType ? $returnType->getName() : (string) $returnType;
|
|
|
|
if ($returnType->allowsNull()) {
|
|
$serviceId = '?'.$serviceId;
|
|
}
|
|
|
|
$services[$attribute->newInstance()->key ?? self::class.'::'.$method->name] = $serviceId;
|
|
}
|
|
|
|
return $services;
|
|
}
|
|
|
|
/**
|
|
* @required
|
|
*/
|
|
public function setContainer(ContainerInterface $container): ?ContainerInterface
|
|
{
|
|
$this->container = $container;
|
|
|
|
if (method_exists(get_parent_class(self::class) ?: '', __FUNCTION__)) {
|
|
return parent::setContainer($container);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|