让我解释一下:我有一个Entity类Item,其中包含getName()方法,命名空间App\Entity.我在Sonata Admin,命名空间App\Admin中有一个管理类,并且想从内部调用该方法,怎么做?
//Symfony2 Entity
...
class Item
{
public function getName(){
return $this->name;
}
}
...
//Sonata Admin class
class ItemAdmin extends Admin
{
...
protected function configureListFields(ListMapper $listMapper){
//how to access Item class' getName() method from here?
}
}
Run Code Online (Sandbox Code Playgroud)
编辑:这在configureListFields()内部工作,但如果没有find()和如果只有find(),那么如何自动获取'id'?
$item=$this->getConfigurationPool()->getContainer()->get('Doctrine')->getRepository('AppBundle:Item')->find('15');
echo $item->getName();
Run Code Online (Sandbox Code Playgroud) 我有干净的删除特殊卡拉科特功能从字符串,但该功能还消除土耳其卡拉科特(?,?,?,C,O)从字符串
function clean($string) {
$string = str_replace(' ', ' ', $string);
$string = preg_replace('/[^A-Za-z0-9\-]/', ' ', $string);
return preg_replace('/-+/', '-', $string);
}
Run Code Online (Sandbox Code Playgroud)
我该如何解决?