/** * attach an admin instance to the given FieldDescription * * @param \Sonata\AdminBundle\Admin\FieldDescriptionInterface $fieldDescription */ public function attachAdminClass(FieldDescriptionInterface $fieldDescription) { $pool = $this->getConfigurationPool(); $admin = $pool->getAdminByClass($fieldDescription->getTargetEntity()); if (!$admin) { return; } $fieldDescription->setAssociationAdmin($admin); }
/** * {@inheritdoc} */ public function attachAdminClass(FieldDescriptionInterface $fieldDescription) { $pool = $this->getConfigurationPool(); $adminCode = $fieldDescription->getOption('admin_code'); if ($adminCode !== null) { $admin = $pool->getAdminByAdminCode($adminCode); } else { $admin = $pool->getAdminByClass($fieldDescription->getTargetEntity()); } if (!$admin) { return; } if ($this->hasRequest()) { $admin->setRequest($this->getRequest()); } $fieldDescription->setAssociationAdmin($admin); }
/** * attach an admin instance to the given FieldDescription * * @param \Sonata\AdminBundle\Admin\FieldDescriptionInterface $fieldDescription */ public function attachAdminClass(FieldDescriptionInterface $fieldDescription) { $pool = $this->getConfigurationPool(); $admin = $pool->getAdminByClass($fieldDescription->getTargetEntity()); if (!$admin) { throw new \RuntimeException(sprintf('You must define an Admin class for the `%s` field (targetEntity=%s)', $fieldDescription->getFieldName(), $fieldDescription->getTargetEntity())); } $fieldDescription->setAssociationAdmin($admin); }