示例#1
0
    /**
     * 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);
    }
示例#2
0
 /**
  * {@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);
 }
示例#3
0
 /**
  * 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);
 }