我知道还有其他方法可以存档,但问题是......这是关于以下内容的缺点:
MyGlobalConfig.php
<?php
namespace Acme\DemoBundle;
class MyGlobalConfig
{
public static $uploadsDir;
}
应用内核.php
<?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
use Acme\DemoBundle\MyGlobalConfig;
class AppKernel extends Kernel
{
public function __construct($environment, $debug)
{
MyGlobalConfig::$uploadsDir = __DIR__ .'/../uploads';
parent::__construct($environment, $debug);
}
文章.php
<?php
namespace Acme\DemoBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Acme\DemoBundle\MyGlobalConfig;
/**
* @ORM\Entity
*/
class Article
{
protected function getUploadsDir()
{
return MyGlobalConfig::$uploadsDir;
}