1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075 |
- <?php
- /*
- * This file is part of the Sonata Project package.
- *
- * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
- namespace Sonata\AdminBundle\Admin;
- use Knp\Menu\FactoryInterface as MenuFactoryInterface;
- use Knp\Menu\ItemInterface;
- use Sonata\AdminBundle\Builder\DatagridBuilderInterface;
- use Sonata\AdminBundle\Builder\FormContractorInterface;
- use Sonata\AdminBundle\Builder\ListBuilderInterface;
- use Sonata\AdminBundle\Builder\RouteBuilderInterface;
- use Sonata\AdminBundle\Datagrid\ProxyQueryInterface;
- use Sonata\AdminBundle\Route\RouteCollection;
- use Sonata\AdminBundle\Route\RouteGeneratorInterface;
- use Sonata\AdminBundle\Security\Handler\SecurityHandlerInterface;
- use Sonata\AdminBundle\Translator\LabelTranslatorStrategyInterface;
- use Sonata\CoreBundle\Model\Metadata;
- use Sonata\CoreBundle\Validator\ErrorElement;
- use Symfony\Component\Form\Form;
- use Symfony\Component\Form\FormBuilderInterface;
- use Symfony\Component\HttpFoundation\Request;
- use Symfony\Component\Translation\TranslatorInterface;
- use Symfony\Component\Validator\Validator\ValidatorInterface;
- use Symfony\Component\Validator\ValidatorInterface as LegacyValidatorInterface;
- /**
- * @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
- */
- interface AdminInterface
- {
- /**
- * @param FormContractorInterface $formContractor
- */
- public function setFormContractor(FormContractorInterface $formContractor);
- /**
- * Set ListBuilder.
- *
- * @param ListBuilderInterface $listBuilder
- */
- public function setListBuilder(ListBuilderInterface $listBuilder);
- /**
- * Get ListBuilder.
- *
- * @return ListBuilderInterface
- */
- public function getListBuilder();
- /**
- * Set DatagridBuilder.
- *
- * @param DatagridBuilderInterface $datagridBuilder
- */
- public function setDatagridBuilder(DatagridBuilderInterface $datagridBuilder);
- /**
- * Get DatagridBuilder.
- *
- * @return DatagridBuilderInterface
- */
- public function getDatagridBuilder();
- /**
- * Set translator.
- *
- * @param TranslatorInterface $translator
- */
- public function setTranslator(TranslatorInterface $translator);
- /**
- * Get translator.
- *
- * @return TranslatorInterface
- */
- public function getTranslator();
- /**
- * @param Request $request
- */
- public function setRequest(Request $request);
- /**
- * @param Pool $pool
- */
- public function setConfigurationPool(Pool $pool);
- /**
- * @param RouteGeneratorInterface $routeGenerator
- */
- public function setRouteGenerator(RouteGeneratorInterface $routeGenerator);
- /**
- * Returns subjectClass/class/subclass name managed
- * - subclass name if subclass parameter is defined
- * - subject class name if subject is defined
- * - class name if not.
- *
- * @return string
- */
- public function getClass();
- /**
- * @param \Sonata\AdminBundle\Admin\FieldDescriptionInterface $fieldDescription
- */
- public function attachAdminClass(FieldDescriptionInterface $fieldDescription);
- /**
- * @return \Sonata\AdminBundle\Datagrid\DatagridInterface
- */
- public function getDatagrid();
- /**
- * Set base controller name.
- *
- * @param string $baseControllerName
- */
- public function setBaseControllerName($baseControllerName);
- /**
- * Get base controller name.
- *
- * @return string
- */
- public function getBaseControllerName();
- /**
- * Generates the object url with the given $name.
- *
- * @param string $name
- * @param mixed $object
- * @param array $parameters
- * @param bool $absolute
- *
- * @return string return a complete url
- */
- public function generateObjectUrl($name, $object, array $parameters = array(), $absolute = false);
- /**
- * Generates an url for the given parameters.
- *
- * @param string $name
- * @param array $parameters
- * @param bool $absolute
- *
- * @return string return a complete url
- */
- public function generateUrl($name, array $parameters = array(), $absolute = false);
- /**
- * Generates an url for the given parameters.
- *
- * @param string $name
- * @param array $parameters
- * @param bool $absolute
- *
- * @return array return url parts: 'route', 'routeParameters', 'routeAbsolute'
- */
- public function generateMenuUrl($name, array $parameters = array(), $absolute = false);
- /**
- * @return \Sonata\AdminBundle\Model\ModelManagerInterface
- */
- public function getModelManager();
- /**
- * @return string the manager type of the admin
- */
- public function getManagerType();
- /**
- * @param string $context NEXT_MAJOR: remove this argument
- *
- * @return ProxyQueryInterface
- */
- public function createQuery($context = 'list');
- /**
- * @return FormBuilderInterface the form builder
- */
- public function getFormBuilder();
- /**
- * Return FormFieldDescription.
- *
- * @param string $name
- *
- * @return FieldDescriptionInterface
- */
- public function getFormFieldDescription($name);
- /**
- * Build and return the collection of form FieldDescription.
- *
- * @return array collection of form FieldDescription
- */
- public function getFormFieldDescriptions();
- /**
- * Returns a form depend on the given $object.
- *
- * @return Form
- */
- public function getForm();
- /**
- * @return Request
- *
- * @throws \RuntimeException if no request is set
- */
- public function getRequest();
- /**
- * @return bool true if a request object is linked to this Admin, false
- * otherwise
- */
- public function hasRequest();
- /**
- * @return string
- */
- public function getCode();
- /**
- * @return string
- */
- public function getBaseCodeRoute();
- /**
- * Return the roles and permissions per role
- * - different permissions per role for the acl handler
- * - one permission that has the same name as the role for the role handler
- * This should be used by experimented users.
- *
- * @return array [role] => array([permission], [permission])
- */
- public function getSecurityInformation();
- /**
- * @param FieldDescriptionInterface $parentFieldDescription
- */
- public function setParentFieldDescription(FieldDescriptionInterface $parentFieldDescription);
- /**
- * Get parent field description.
- *
- * @return FieldDescriptionInterface The parent field description
- */
- public function getParentFieldDescription();
- /**
- * Returns true if the Admin is linked to a parent FieldDescription.
- *
- * @return bool
- */
- public function hasParentFieldDescription();
- /**
- * translate a message id.
- *
- * NEXT_MAJOR: remove this method
- *
- * @param string $id
- * @param array $parameters
- * @param null $domain
- * @param null $locale
- *
- * @return string the translated string
- *
- * @deprecated since 3.9, to be removed in 4.0
- */
- public function trans($id, array $parameters = array(), $domain = null, $locale = null);
- /**
- * Returns the list of available urls.
- *
- * @return RouteCollection the list of available urls
- */
- public function getRoutes();
- /**
- * Return the parameter name used to represent the id in the url.
- *
- * @return string
- */
- public function getRouterIdParameter();
- /**
- * Returns the parameter representing request id, ie: id or childId.
- *
- * @return string
- */
- public function getIdParameter();
- /**
- * Returns true if the route $name is available.
- *
- * @param string $name
- *
- * @return bool
- */
- public function hasRoute($name);
- /**
- * Check the current request is given route or not.
- *
- * TODO: uncomment this method before releasing 4.0
- *
- * ```
- * $this->isCurrentRoute('create'); // is create page?
- * $this->isCurrentRoute('edit', 'some.admin.code'); // is some.admin.code admin's edit page?
- * ```
- *
- * @param string $name
- * @param string $adminCode
- *
- * @return bool
- */
- // public function isCurrentRoute($name, $adminCode = null);
- /**
- * Returns true if the admin has a FieldDescription with the given $name.
- *
- * @param string $name
- *
- * @return bool
- */
- public function hasShowFieldDescription($name);
- /**
- * add a FieldDescription.
- *
- * @param string $name
- * @param FieldDescriptionInterface $fieldDescription
- */
- public function addShowFieldDescription($name, FieldDescriptionInterface $fieldDescription);
- /**
- * Remove a ShowFieldDescription.
- *
- * @param string $name
- */
- public function removeShowFieldDescription($name);
- /**
- * add a list FieldDescription.
- *
- * @param string $name
- * @param FieldDescriptionInterface $fieldDescription
- */
- public function addListFieldDescription($name, FieldDescriptionInterface $fieldDescription);
- /**
- * Remove a list FieldDescription.
- *
- * @param string $name
- */
- public function removeListFieldDescription($name);
- /**
- * Returns true if the filter FieldDescription exists.
- *
- * @param string $name
- *
- * @return bool
- */
- public function hasFilterFieldDescription($name);
- /**
- * add a filter FieldDescription.
- *
- * @param string $name
- * @param FieldDescriptionInterface $fieldDescription
- */
- public function addFilterFieldDescription($name, FieldDescriptionInterface $fieldDescription);
- /**
- * Remove a filter FieldDescription.
- *
- * @param string $name
- */
- public function removeFilterFieldDescription($name);
- /**
- * Returns the filter FieldDescription collection.
- *
- * @return FieldDescriptionInterface[]
- */
- public function getFilterFieldDescriptions();
- /**
- * Returns a filter FieldDescription.
- *
- * @param string $name
- *
- * @return FieldDescriptionInterface|null
- */
- public function getFilterFieldDescription($name);
- /**
- * Returns a list depend on the given $object.
- *
- * @return FieldDescriptionCollection
- */
- public function getList();
- /**
- * @param SecurityHandlerInterface $securityHandler
- */
- public function setSecurityHandler(SecurityHandlerInterface $securityHandler);
- /**
- * @return SecurityHandlerInterface|null
- */
- public function getSecurityHandler();
- /**
- * @param string $name
- * @param object|null $object
- *
- * @return bool
- */
- public function isGranted($name, $object = null);
- /**
- * @param mixed $entity
- *
- * @return string a string representation of the id that is save to use in an url
- */
- public function getUrlsafeIdentifier($entity);
- /**
- * @param mixed $entity
- *
- * @return string a string representation of the identifiers for this instance
- */
- public function getNormalizedIdentifier($entity);
- /**
- * Shorthand method for templating.
- *
- * @param object $entity
- *
- * @return mixed
- */
- public function id($entity);
- /**
- * @param ValidatorInterface|LegacyValidatorInterface $validator
- */
- public function setValidator($validator);
- /**
- * @return ValidatorInterface|LegacyValidatorInterface
- */
- public function getValidator();
- /**
- * @return array
- */
- public function getShow();
- /**
- * @param array $formTheme
- */
- public function setFormTheme(array $formTheme);
- /**
- * @return array
- */
- public function getFormTheme();
- /**
- * @param array $filterTheme
- */
- public function setFilterTheme(array $filterTheme);
- /**
- * @return array
- */
- public function getFilterTheme();
- /**
- * @param AdminExtensionInterface $extension
- */
- public function addExtension(AdminExtensionInterface $extension);
- /**
- * Returns an array of extension related to the current Admin.
- *
- * @return AdminExtensionInterface[]
- */
- public function getExtensions();
- /**
- * @param \Knp\Menu\FactoryInterface $menuFactory
- */
- public function setMenuFactory(MenuFactoryInterface $menuFactory);
- /**
- * @return \Knp\Menu\FactoryInterface
- */
- public function getMenuFactory();
- /**
- * @param RouteBuilderInterface $routeBuilder
- */
- public function setRouteBuilder(RouteBuilderInterface $routeBuilder);
- /**
- * @return RouteBuilderInterface
- */
- public function getRouteBuilder();
- /**
- * @param mixed $object
- *
- * @return string
- */
- public function toString($object);
- /**
- * @param LabelTranslatorStrategyInterface $labelTranslatorStrategy
- */
- public function setLabelTranslatorStrategy(LabelTranslatorStrategyInterface $labelTranslatorStrategy);
- /**
- * @return LabelTranslatorStrategyInterface
- */
- public function getLabelTranslatorStrategy();
- /**
- * Returning true will enable preview mode for
- * the target entity and show a preview button
- * when editing/creating an entity.
- *
- * @return bool
- */
- public function supportsPreviewMode();
- /**
- * add an Admin child to the current one.
- *
- * @param AdminInterface $child
- */
- public function addChild(AdminInterface $child);
- /**
- * Returns true or false if an Admin child exists for the given $code.
- *
- * @param string $code Admin code
- *
- * @return bool True if child exist, false otherwise
- */
- public function hasChild($code);
- /**
- * Returns an collection of admin children.
- *
- * @return array list of Admin children
- */
- public function getChildren();
- /**
- * Returns an admin child with the given $code.
- *
- * @param string $code
- *
- * @return AdminInterface|null
- */
- public function getChild($code);
- /**
- * @return mixed a new object instance
- */
- public function getNewInstance();
- /**
- * @param string $uniqId
- */
- public function setUniqid($uniqId);
- /**
- * Returns the uniqid.
- *
- * @return int
- */
- public function getUniqid();
- /**
- * @param mixed $id
- *
- * @return mixed
- */
- public function getObject($id);
- /**
- * @param object $subject
- */
- public function setSubject($subject);
- /**
- * @return mixed
- */
- public function getSubject();
- /**
- * Returns a list FieldDescription.
- *
- * @param string $name
- *
- * @return FieldDescriptionInterface
- */
- public function getListFieldDescription($name);
- /**
- * Returns true if the list FieldDescription exists.
- *
- * @param string $name
- *
- * @return bool
- */
- public function hasListFieldDescription($name);
- /**
- * Returns the collection of list FieldDescriptions.
- *
- * @return array
- */
- public function getListFieldDescriptions();
- /**
- * Returns the array of allowed export formats.
- *
- * @return array
- */
- public function getExportFormats();
- /**
- * Returns SourceIterator.
- *
- * @return \Exporter\Source\SourceIteratorInterface
- */
- public function getDataSourceIterator();
- public function configure();
- /**
- * @param mixed $object
- *
- * @return mixed
- */
- public function update($object);
- /**
- * @param mixed $object
- *
- * @return mixed
- */
- public function create($object);
- /**
- * @param mixed $object
- */
- public function delete($object);
- //TODO: uncomment this method for 4.0
- // /**
- // * @param mixed $object
- // */
- // public function preValidate($object);
- /**
- * @param mixed $object
- */
- public function preUpdate($object);
- /**
- * @param mixed $object
- */
- public function postUpdate($object);
- /**
- * @param mixed $object
- */
- public function prePersist($object);
- /**
- * @param mixed $object
- */
- public function postPersist($object);
- /**
- * @param mixed $object
- */
- public function preRemove($object);
- /**
- * @param mixed $object
- */
- public function postRemove($object);
- /**
- * Call before the batch action, allow you to alter the query and the idx.
- *
- * @param string $actionName
- * @param ProxyQueryInterface $query
- * @param array $idx
- * @param bool $allElements
- */
- public function preBatchAction($actionName, ProxyQueryInterface $query, array &$idx, $allElements);
- /**
- * Return array of filter parameters.
- *
- * @return array
- */
- public function getFilterParameters();
- /**
- * Return true if the Admin is related to a subject.
- *
- * @return bool
- */
- public function hasSubject();
- /**
- * NEXT_MAJOR: remove this method.
- *
- * @param ErrorElement $errorElement
- * @param mixed $object
- *
- * @deprecated this feature cannot be stable, use a custom validator,
- * the feature will be removed with Symfony 2.2
- */
- public function validate(ErrorElement $errorElement, $object);
- /**
- * @param string $context
- *
- * @return bool
- */
- public function showIn($context);
- /**
- * Add object security, fe. make the current user owner of the object.
- *
- * @param mixed $object
- */
- public function createObjectSecurity($object);
- /**
- * @return AdminInterface
- */
- public function getParent();
- /**
- * @param AdminInterface $admin
- */
- public function setParent(AdminInterface $admin);
- /**
- * Returns true if the Admin class has an Parent Admin defined.
- *
- * @return bool
- */
- public function isChild();
- /**
- * Returns template.
- *
- * @param string $name
- *
- * @return null|string
- */
- public function getTemplate($name);
- /**
- * Set the translation domain.
- *
- * @param string $translationDomain the translation domain
- */
- public function setTranslationDomain($translationDomain);
- /**
- * Returns the translation domain.
- *
- * @return string the translation domain
- */
- public function getTranslationDomain();
- /**
- * Return the form groups.
- *
- * @return array
- */
- public function getFormGroups();
- /**
- * Set the form groups.
- *
- * @param array $formGroups
- */
- public function setFormGroups(array $formGroups);
- public function getFormTabs();
- public function setFormTabs(array $formTabs);
- public function getShowTabs();
- public function setShowTabs(array $showTabs);
- /**
- * Remove a form group field.
- *
- * @param string $key
- */
- public function removeFieldFromFormGroup($key);
- /**
- * Returns the show groups.
- *
- * @return array
- */
- public function getShowGroups();
- /**
- * Set the show groups.
- *
- * @param array $showGroups
- */
- public function setShowGroups(array $showGroups);
- /**
- * Reorder items in showGroup.
- *
- * @param string $group
- * @param array $keys
- */
- public function reorderShowGroup($group, array $keys);
- /**
- * add a FieldDescription.
- *
- * @param string $name
- * @param FieldDescriptionInterface $fieldDescription
- */
- public function addFormFieldDescription($name, FieldDescriptionInterface $fieldDescription);
- /**
- * Remove a FieldDescription.
- *
- * @param string $name
- */
- public function removeFormFieldDescription($name);
- /**
- * Returns true if this admin uses ACL.
- *
- * @return bool
- */
- public function isAclEnabled();
- /**
- * Sets the list of supported sub classes.
- *
- * @param array $subClasses the list of sub classes
- */
- public function setSubClasses(array $subClasses);
- /**
- * Returns true if the admin has the sub classes.
- *
- * @param string $name The name of the sub class
- *
- * @return bool
- */
- public function hasSubClass($name);
- /**
- * Returns true if a subclass is currently active.
- *
- * @return bool
- */
- public function hasActiveSubClass();
- /**
- * Returns the currently active sub class.
- *
- * @return string the active sub class
- */
- public function getActiveSubClass();
- /**
- * Returns the currently active sub class code.
- *
- * @return string the code for active sub class
- */
- public function getActiveSubclassCode();
- /**
- * Returns the list of batchs actions.
- *
- * @return array the list of batchs actions
- */
- public function getBatchActions();
- /**
- * Returns Admin`s label.
- *
- * @return string
- */
- public function getLabel();
- /**
- * Returns an array of persistent parameters.
- *
- * @return array
- */
- public function getPersistentParameters();
- /**
- * NEXT_MAJOR: remove this signature
- * Get breadcrumbs for $action.
- *
- * @param string $action
- *
- * @return mixed array|Traversable
- */
- public function getBreadcrumbs($action);
- /**
- * Set the current child status.
- *
- * @param bool $currentChild
- */
- public function setCurrentChild($currentChild);
- /**
- * Returns the current child status.
- *
- * @return bool
- */
- public function getCurrentChild();
- /**
- * Get translation label using the current TranslationStrategy.
- *
- * @param string $label
- * @param string $context
- * @param string $type
- *
- * @return string
- */
- public function getTranslationLabel($label, $context = '', $type = '');
- /**
- * NEXT_MAJOR: remove this method.
- *
- * @param string $action
- * @param AdminInterface $childAdmin
- *
- * @return ItemInterface|bool
- *
- * @deprecated Use buildTabMenu instead
- */
- public function buildSideMenu($action, AdminInterface $childAdmin = null);
- /**
- * Build the tab menu related to the current action.
- *
- * @param string $action
- * @param AdminInterface $childAdmin
- *
- * @return ItemInterface|bool
- */
- public function buildTabMenu($action, AdminInterface $childAdmin = null);
- /**
- * @param $object
- *
- * @return Metadata
- */
- public function getObjectMetadata($object);
- /**
- * @return array
- */
- public function getListModes();
- /**
- * @param string $mode
- */
- public function setListMode($mode);
- /**
- * return the list mode.
- *
- * @return string
- */
- public function getListMode();
- /**
- * Return the controller access mapping.
- *
- * @return array
- */
- public function getAccessMapping();
- /**
- * Hook to handle access authorization.
- *
- * @param string $action
- * @param object $object
- */
- public function checkAccess($action, $object = null);
- /*
- * Configure buttons for an action
- *
- * @param string $action
- * @param object $object
- *
- */
- // public function configureActionButtons($action, $object = null);
- // TODO: uncomment this method for next major release
- // /**
- // * Hook to handle access authorization, without throw Exception
- // *
- // * @param string $action
- // * @param object $object
- // *
- // * @return bool
- // */
- // public function hasAccess($action, $object = null);
- //TODO: uncomment this method for 4.0
- /*
- * Returns the result link for an object.
- *
- * @param mixed $object
- *
- * @return string|null
- */
- //public function getSearchResultLink($object)
- // TODO: uncomment this method in 4.0
- // /**
- // * Setting to true will enable mosaic button for the admin screen.
- // * Setting to false will hide mosaic button for the admin screen.
- // *
- // * @param bool $isShown
- // */
- // public function showMosaicButton($isShown);
- /*
- * Checks if a filter type is set to a default value
- *
- * @param string $name
- *
- * @return bool
- */
- // NEXT_MAJOR: uncomment this method in 4.0
- // public function isDefaultFilter($name);
- }
|