Symfony 2 Web sitesinde How to Override any Part of a Bundle sayfasını takip ediyorum. Bu ilginç:Symfony 2 istek servisini genişletiyor musunuz?
Yani benSen app/config/config.yml bunu ayarlayarak kendi sınıfına hizmetin sınıf adı tutan parametre ayarlayabilirsiniz. Bu, eğer sınıf adı, hizmeti içeren paketin servisinde konfigürasyonunda bir parametre olarak tanımlanmışsa, sadece mümkündür.
/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Resources/config
bakıp i
session.xml
%session.class%
parametreyi tanımlayan olduğunu buldum ve böyle bir şeyle Symfony'nin
Session
sınıfını genişletmek için kolay olmalıdır:
namespace Acme\HelloBundle\Component\HttpFoundation;
use Symfony\Component\HttpFoundation\Session;
class ExtendedSession extends Session
{
public function setSuccessFlashText($text, array params = array())
{
parent::setFlash('success', $this->getTranslator()->trans($text, $params);
}
}
Henüz bu test din't. Ama request
özel servisiyle aynı şeyi nasıl yapabilirim? Kodumun okunmasını kolaylaştırmak için bazı kullanışlı kısayollar eklemek istiyorum.
<!--
If you want to change the Request class, modify the code in
your front controller (app.php) so that it passes an instance of
YourRequestClass to the Kernel.
This service definition only defines the scope of the request.
It is used to check references scope.
-->
<service id="request" scope="request" synthetic="true" />
İşte benim app.php
geçerli:
services.xml
dosyada buldum. Özel istek sınıfımın bir örneğini nasıl geçirmem gerekiyor?
require_once __DIR__.'/../app/bootstrap.php.cache';
require_once __DIR__.'/../app/AppKernel.php';
//require_once __DIR__.'/../app/AppCache.php';
use Symfony\Component\HttpFoundation\Request;
$kernel = new AppKernel('prod', false);
$kernel->loadClassCache();
//$kernel = new AppCache($kernel);
$kernel->handle(Request::createFromGlobals())->send();
'web/app.php': Ayrıca comment doc onun sınıfını tanımlayabilirsiniz IDE için bir hizmet olarak veya bir kontrol cihazından isteği almak istiyorsanız durumunda
, Böyle var? O_o –
@thecatontheflat lol: '/ app' klasörüne bakıyordum ... o zaman soruyu güncelleyeceğim. – gremo