これをアーカイブする他の方法があることは知っていますが、問題は...次のようなものの短所です:
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);
}
記事.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;
}