|
@@ -342,6 +342,8 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
|
|
|
|
|
|
protected $filterTheme = array('SonataAdminBundle:Form:filter_admin_fields.html.twig');
|
|
|
|
|
|
+ protected $extensions = array();
|
|
|
+
|
|
|
/**
|
|
|
* This method can be overwritten to tweak the form construction, by default the form
|
|
|
* is built by reading the FieldDescription
|
|
@@ -416,6 +418,20 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param \Sonata\AdminBundle\Validator\ErrorElement $errorElement
|
|
|
+ * @param $object
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function doValidate(ErrorElement $errorElement, $object)
|
|
|
+ {
|
|
|
+ $this->validate($errorElement, $object);
|
|
|
+
|
|
|
+ foreach ($this->extensions as $extension) {
|
|
|
+ $extension->validate($this, $errorElement, $object);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param string $code
|
|
|
* @param string $class
|
|
@@ -538,6 +554,10 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
|
|
|
}
|
|
|
|
|
|
$this->configureListFields($mapper);
|
|
|
+
|
|
|
+ foreach($this->extensions as $extension) {
|
|
|
+ $extension->configureListFields($mapper);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -597,6 +617,10 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
|
|
|
'operator_type' => 'hidden'
|
|
|
));
|
|
|
}
|
|
|
+
|
|
|
+ foreach($this->extensions as $extension) {
|
|
|
+ $extension->configureDatagridFilters($mapper);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -807,6 +831,10 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
|
|
|
|
|
|
$this->configureRoutes($collection);
|
|
|
|
|
|
+ foreach($this->extensions as $extension) {
|
|
|
+ $extension->configureRoutes($this, $collection);
|
|
|
+ }
|
|
|
+
|
|
|
$this->routes = $collection;
|
|
|
}
|
|
|
|
|
@@ -962,7 +990,7 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
|
|
|
$metadata = $this->validator->getMetadataFactory()->getClassMetadata($this->class);
|
|
|
$metadata->addConstraint(new \Sonata\AdminBundle\Validator\Constraints\InlineConstraint(array(
|
|
|
'service' => $this,
|
|
|
- 'method' => 'validate'
|
|
|
+ 'method' => 'doValidate'
|
|
|
)));
|
|
|
|
|
|
$this->formOptions['data_class'] = $this->getClass();
|
|
@@ -986,6 +1014,10 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
|
|
|
$mapper = new FormMapper($this->getFormContractor(), $formBuilder, $this);
|
|
|
|
|
|
$this->configureFormFields($mapper);
|
|
|
+
|
|
|
+ foreach($this->extensions as $extension) {
|
|
|
+ $extension->configureFormFields($mapper);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1071,6 +1103,10 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
|
|
|
|
|
|
$this->configureSideMenu($menu, $action, $childAdmin);
|
|
|
|
|
|
+ foreach ($this->extensions as $extension) {
|
|
|
+ $extension->configureSideMenu($this, $menu, $action, $childAdmin);
|
|
|
+ }
|
|
|
+
|
|
|
$this->menu = $menu;
|
|
|
}
|
|
|
|
|
@@ -2034,4 +2070,9 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
|
|
|
{
|
|
|
return $this->filterTheme;
|
|
|
}
|
|
|
+
|
|
|
+ public function addExtension(AdminExtensionInterface $extension)
|
|
|
+ {
|
|
|
+ $this->extensions[] = $extension;
|
|
|
+ }
|
|
|
}
|