Symfony 4原则,覆盖现有方法

时间:2017-12-30 09:09:17

标签: oop php-7 symfony4

来自Symfony4的学说供应商,'坚持' method在参数中使用一个实体。我想创建我自己的apersist函数,它在参数中获取一个实体数组,如何通过一种新方法覆盖自定义类的EntityManager-> persist方法' apersist'像这样 ?

class MyEm extends EntityManager 
{
  public function apersist($entities){
    foreach($entities as $entity){
      // ?? (I tried with '$this->persist($entity)' or 'parent::persist($entity)' but I get errors) 
    }
}

来自班级管理员:

public function create(MyEm $mem){ // I get errors when I try use my MyEm class from create parameter
  $entities[] = new foo();
  $entities[] = new foo();
  $mem->apersist($entities);
}

0 个答案:

没有答案