1
我知道有其他的方法來歸檔此,但問題是...... 這是關於類似利弊:缺點PARAMS
MyGlobalConfig.php
<?php
namespace Acme\DemoBundle;
class MyGlobalConfig
{
public static $uploadsDir;
}
AppKernel.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);
}
Article.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;
}
對不起,等待,我希望更多的在此,謝謝! – coma 2013-05-10 09:08:10