{"id":20260030,"url":"https://github.com/networking/sonata-admin-annotation-bundle","last_synced_at":"2026-05-11T15:38:21.270Z","repository":{"id":150239037,"uuid":"223364772","full_name":"networking/sonata-admin-annotation-bundle","owner":"networking","description":"Replacement for Ibrows bundle","archived":false,"fork":false,"pushed_at":"2019-11-22T09:21:58.000Z","size":16,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-03T18:47:53.511Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/networking.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-22T09:04:33.000Z","updated_at":"2019-12-10T08:53:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"32fd6994-f88f-47c8-a103-6e56bc049186","html_url":"https://github.com/networking/sonata-admin-annotation-bundle","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/networking/sonata-admin-annotation-bundle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/networking%2Fsonata-admin-annotation-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/networking%2Fsonata-admin-annotation-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/networking%2Fsonata-admin-annotation-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/networking%2Fsonata-admin-annotation-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/networking","download_url":"https://codeload.github.com/networking/sonata-admin-annotation-bundle/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/networking%2Fsonata-admin-annotation-bundle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32902242,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-10T13:40:02.631Z","status":"online","status_checked_at":"2026-05-11T02:00:05.975Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T11:17:44.933Z","updated_at":"2026-05-11T15:38:21.265Z","avatar_url":"https://github.com/networking.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"IbrowsSonataAdminAnnotationBundle \n============================\n\nManage Sonata Form, Data, List and ShowMapper over annotations\n\n[![Latest Stable Version](https://poser.pugx.org/ibrows/sonata-admin-annotation-bundle/v/stable)](https://packagist.org/packages/ibrows/sonata-admin-annotation-bundle) [![Total Downloads](https://poser.pugx.org/ibrows/sonata-admin-annotation-bundle/downloads)](https://packagist.org/packages/ibrows/sonata-admin-annotation-bundle)\n\n[![knpbundles.com](http://knpbundles.com/ibrows/IbrowsSonataAdminAnnotationBundle/badge-short)](http://knpbundles.com/ibrows/IbrowsSonataAdminAnnotationBundle)\n\nHow to install\n==============\n\n### Add Bundle to your composer.json\n\n```js\n// composer.json\n\n{\n    \"require\": {\n        \"ibrows/sonata-admin-annotation-bundle\": \"*\"\n    }\n}\n```\n\n### Install the bundle from console with composer.phar\n\n``` bash\n$ php composer.phar update ibrows/sonata-admin-annotation-bundle\n```\n\n### Enable the bundle in AppKernel.php - Dont forget to give AppKernel to the Bundle and register the Bundle *BEFORE* SonataAdminBundle\n\n``` php\n\u003c?php\n// app/AppKernel.php\n\npublic function registerBundles()\n{\n    $bundles = array(\n        // ...\n        new Ibrows\\Bundle\\SonataAdminAnnotationBundle\\IbrowsSonataAdminAnnotationBundle($this),\n    );\n}\n```\n\n### Configuration (Only needed if @AutoService is used)\n\n``` yaml\nibrows_sonata_admin_annotation:\n    autoservice:\n        service_id_prefix: companyname.admin\n        default_entity:\n            admin: CompanyName\\ProjectNameBundle\\Admin\\DefaultAdmin\n            controller: CompanyNameProjectNameBundle:Admin/DefaultAdmin\n        entities:\n            - {directory: %kernel.root_dir%/../src/CompanyName/ProjectNameBundle/Entity, prefix: CompanyName\\ProjectNameBundle\\Entity}\n```\n\n### The Annotations\n\n- Ibrows\\Bundle\\SonataAdminAnnotationBundle\\Annotation\\Order on classes for global orders like \"show me all properties\"\n- Ibrows\\Bundle\\SonataAdminAnnotationBundle\\Annotation on properties for specific configurations and excludes if orders are used\n\n\u003e If any FormMapperExclude Annotation is found on a property the reader assumes that there es an Order/FormMapperAll on the class (same goes for the other annotations - List/Form/Datagrid)\n\nHave a look on the Annotations to see what options they accept\n\n### Example\n\n``` php\n\u003c?php\n\nnamespace YourApp\\Entity;\n\nuse Ibrows\\Bundle\\SonataAdminAnnotationBundle\\Annotation as Sonata;\n\nuse Doctrine\\ORM\\Mapping as ORM;\nuse Doctrine\\Common\\Collections\\Collection;\nuse Doctrine\\Common\\Collections\\ArrayCollection;\n\n/**\n * @ORM\\Entity\n * @Sonata\\Order\\ListMapperAll\n * @Sonata\\Order\\ShowMapperAll\n * @Sonata\\Order\\FormMapperAll\n *\n * @Sonata\\Order\\ShowAndFormreorder(with=\"General\", keys={\"name\"})\n * @Sonata\\Order\\ShowAndFormreorder(keys={\"taxRate\"})\n *\n * @Sonata\\AutoService()\n */\nclass Country\n{\n    /**\n     * @var integer $id\n     * @ORM\\Column(type=\"integer\")\n     * @ORM\\Id\n     * @ORM\\GeneratedValue(strategy=\"AUTO\")\n     * @Sonata\\ListMapper(identifier=true)\n     * @Sonata\\Order\\FormMapperExclude\n     * @Sonata\\ShowMapper(with=\"General\")\n     */\n    protected $id;\n\n    /**\n     * @var string $name\n     * @ORM\\Column(type=\"string\")\n     * @Sonata\\ShowMapper(with=\"General\")\n     */\n    protected $name;\n\n    /**\n     * @var float\n     * @ORM\\Column(type=\"float\", name=\"shipping_free_limit\")\n     */\n    protected $shippingFreeLimit;\n\n    /**\n     * @var float\n     * @ORM\\Column(type=\"float\", name=\"shipping_fixed_rate\")\n     */\n    protected $shippingFixedRate;\n\n    /**\n     * @var float\n     * @ORM\\Column(type=\"float\", name=\"tax_rate\")\n     */\n    protected $taxRate;\n\n    /**\n     * @ORM\\ManyToMany(targetEntity=\"Article\", inversedBy=\"countries\")\n     * @ORM\\JoinTable(name=\"article_country\")\n     * @Sonata\\Order\\ListMapperExclude\n     * @Sonata\\FormMapper(options={\"required\"=false})\n     **/\n    protected $articles;\n}\n```\n\n``` php\n\u003c?php\n\nnamespace YourApp\\Entity;\n\nuse Ibrows\\Bundle\\SonataAdminAnnotationBundle\\Annotation as Sonata;\n\nuse Sonata\\AdminBundle\\Form\\FormMapper;\nuse Sonata\\AdminBundle\\Show\\ShowMapper;\nuse Sonata\\AdminBundle\\Datagrid\\DatagridMapper;\nuse Sonata\\AdminBundle\\Datagrid\\ListMapper;\n\nuse Application\\Sonata\\MediaBundle\\Entity\\Gallery;\n\nuse Doctrine\\ORM\\Mapping as ORM;\nuse Doctrine\\Common\\Collections\\Collection;\nuse Doctrine\\Common\\Collections\\ArrayCollection;\n\n/**\n * @ORM\\Entity\n * @Sonata\\Order\\ShowAndFormreorder(keys={\"name\"})\n */\nclass Article\n{\n    /**\n     * @var string $number\n     * @ORM\\Column(name=\"number\", type=\"string\", unique=true)\n     */\n    protected $number;\n\n    /**\n     * @var string $name\n     * @ORM\\Column(type=\"string\")\n     * @Sonata\\DatagridMapper\n     */\n    protected $name;\n\n    /**\n     * @var string $description\n     * @ORM\\Column(type=\"text\")\n     * @Sonata\\Order\\ListMapperExclude\n     */\n    protected $description;\n\n    /**\n     * @var string $matchCode\n     * @ORM\\Column(name=\"match_code\", type=\"string\")\n     * @Sonata\\Order\\ListMapperExclude\n     */\n    protected $matchCode;\n\n    /**\n     * @var string $articleGroup\n     * @ORM\\Column(name=\"article_group\", type=\"string\")\n     * @Sonata\\Order\\ListMapperExclude\n     * @Sonata\\Order\\ShowMapperExclude\n     */\n    protected $articleGroup;\n\n    /**\n     * @var ArrayCollection\n     * @ORM\\OneToMany(targetEntity=\"ArticlePrice\", mappedBy=\"articleEntity\")\n     * @Sonata\\Order\\ListMapperExclude\n     */\n    protected $prices;\n\n    /**\n     * @ORM\\ManyToMany(targetEntity=\"Country\", mappedBy=\"articles\")\n     **/\n    protected $countries;\n\n    /**\n     * @var Gallery $pictures\n     * @ORM\\ManyToOne(\n     *      targetEntity=\"Application\\Sonata\\MediaBundle\\Entity\\Gallery\",\n     *      cascade={\"persist\"}\n     * )\n     * @Sonata\\FormMapper(\n     *      type=\"sonata_type_model_list\",\n     *      options={\"required\"=false},\n     *      fieldDescriptionOptions={\n     *          \"link_parameters\"={\n     *              \"context\":\"article\",\n     *              \"provider\":\"sonata.media.provider.image\"\n     *          }\n     *      }\n     * )\n     */\n    protected $pictures;\n\n    /**\n     * @param \\Sonata\\AdminBundle\\Form\\FormMapper $formMapper\n     * @Sonata\\FormCallback\n     */\n    public static function configureFormFields(FormMapper $formMapper)\n    {\n        $formMapper-\u003eadd('countries');\n    }\n}\n```\n\n### Using in the Admin (maybe in an AbstractAdmin.php)\n\n#### With the AbstractSonataAdminAnnotationAdmin\n\n```php\n\u003c?php\n\nnamespace YourApp\\Admin;\n\nuse Ibrows\\Bundle\\SonataAdminAnnotationBundle\\Admin\\AbstractSonataAdminAnnotationAdmin;\n\nabstract class AbstractAdmin extends AbstractSonataAdminAnnotationAdmin\n{\n\n}\n```\n\n#### With Traits (PHP \u003e=5.4)\n```php\n\u003c?php\n\nnamespace YourApp\\Admin;\n\nuse Ibrows\\Bundle\\SonataAdminAnnotationBundle\\Admin\\SonataAdminAnnotationAllTrait;\n\nuse Sonata\\AdminBundle\\Admin\\Admin;\n\nabstract class AbstractAdmin extends Admin\n{\n    use SonataAdminAnnotationAllTrait;\n}\n```\n\n#### Own implementation\n\n``` php\n\u003c?php\n\nnamespace YourApp\\Admin;\n\nuse Ibrows\\Bundle\\SonataAdminAnnotationBundle\\Reader\\SonataAdminAnnotationReaderInterface;\n\nuse Symfony\\Component\\DependencyInjection\\ContainerInterface;\n\nuse Sonata\\AdminBundle\\Admin\\Admin;\n\nuse Sonata\\AdminBundle\\Datagrid\\ListMapper;\nuse Sonata\\AdminBundle\\Datagrid\\DatagridMapper;\nuse Sonata\\AdminBundle\\Form\\FormMapper;\nuse Sonata\\AdminBundle\\Show\\ShowMapper;\n\nabstract class AbstractAdmin extends Admin\n{\n    /**\n     * @param ListMapper $listMapper\n     */\n    protected function configureListFields(ListMapper $listMapper)\n    {\n        $this-\u003egetSonataAnnotationReader()-\u003econfigureListFields($this-\u003egetClass(), $listMapper);\n    }\n\n    /**\n     * @param FormMapper $formMapper\n     */\n    protected function configureFormFields(FormMapper $formMapper)\n    {\n        $this-\u003egetSonataAnnotationReader()-\u003econfigureFormFields($this-\u003egetClass(), $formMapper);\n    }\n\n    /**\n     * @param ShowMapper $showMapper\n     */\n    protected function configureShowFields(ShowMapper $showMapper)\n    {\n        $this-\u003egetSonataAnnotationReader()-\u003econfigureShowFields($this-\u003egetClass(), $showMapper);\n    }\n\n    /**\n     * @param DatagridMapper $datagridMapper\n     */\n    protected function configureDatagridFilters(DatagridMapper $datagridMapper)\n    {\n        $this-\u003egetSonataAnnotationReader()-\u003econfigureDatagridFilters($this-\u003egetClass(), $datagridMapper);\n    }\n\n    /**\n     * @return ContainerInterface\n     */\n    protected function getContainer()\n    {\n        return $this-\u003egetConfigurationPool()-\u003egetContainer();\n    }\n\n    /**\n     * @return SonataAdminAnnotationReaderInterface\n     */\n    protected function getSonataAnnotationReader()\n    {\n        return $this-\u003egetContainer()-\u003eget('ibrows_sonataannotation.reader');\n    }\n}\n```\n\nKnown issues\n============\n### Version 2.2.*\n\n- When using the @AutoService Annotation you have to clear the cache everytime you make changes on this Annotation (remove/add/edit). Reason is that the appDevDebugContainer is fully cached and the CompilerPass cannot register the new changes.\n\n### Version 1.1.*\n\n- Using oneToMany/manyToOne relations produces an \"entity not managed\" doctrine error. Reason is that FormMapper-Annotation per default sets by_reference to false, using @FormMapper(options={\"by_reference\"=true}) will fix that.\n\nNew features\n============\n\n### Version 2.4\n\n- New \"tab\" and \"tabOptions\" in FormMapper and ShowMapper Annotation for grouping -\u003e @FormMapper(tab=\"Main\")\n\n### Version 2.2\n\n- Allow to register SonataAdminServices over Annotations with @AutoService @see Known issues for caching problems\n\n### Version 1.2\n\n- Allow reorder of FormMapper/ShowMapper and ListMapper with @Order/FormReorder, @Order/ShowReorder, @Order/ListReorder or @Order/ShowAndFormReorder annotations\n\n### Version 1.1\n\n- New \"with\" and \"withOptions\" in FormMapper and ShowMapper Annotation for grouping -\u003e @FormMapper(with=\"Main\")\n- Allow configuration of static callback methods in entity with @FormCallback on Method (see @FormCallback example)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetworking%2Fsonata-admin-annotation-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetworking%2Fsonata-admin-annotation-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetworking%2Fsonata-admin-annotation-bundle/lists"}