2013-07-02 2 views
0

이외에서 서비스를 호출하는 방법은 컨트롤러에서이 서비스를 호출 할 수 있습니다 나는이컨트롤러

<?php 
namespace Acme\TopBundle\MyServices; 


class MyFunc 
{ 
    public function generateRandomString($length = 8) { 
     // 

     return $randomString; 
    } 
} 

같은 서비스를

컨트롤러 이외에서 서비스를 호출하는 방법을

$this->get('myfunc')->generateRandomString() 

그러나 제어기 외부로부터의 것

$this->get('myfunc')->generateRandomString() 

FatalErrorException: Error: Call to undefined method Acme\AdminBundle\Admin\LessonAdmin::get() in 

$this->container->get('myfunc')->generateRandomString() 

내가 컨트롤러의 외부에서 서비스를 호출 할 수있는 방법

Undefined property: Acme\AdminBundle\Admin\UserAdmin::$container in /Users/daichi/httproot/muty/src/Acme/AdminBundle/Admin/UserAdmin.php 

표시를 보여줍니다?

답변