### Install Python Dependencies for Documentation Source: https://github.com/sonata-project/sonataclassificationbundle/blob/4.x/CONTRIBUTING.md Installs the necessary Python packages for rendering documentation using Sphinx. Ensure you have pip installed. ```bash pip install --requirement docs/requirements.txt --user ``` -------------------------------- ### Install Sonata Classification Bundle via Composer Source: https://github.com/sonata-project/sonataclassificationbundle/blob/4.x/docs/reference/installation.md Use this command to add the Sonata Classification Bundle to your project dependencies. ```bash composer require sonata-project/classification-bundle ``` -------------------------------- ### Install and Run PHP Coding Standard Fixer Source: https://github.com/sonata-project/sonataclassificationbundle/blob/4.x/CONTRIBUTING.md Install PHP Coding Standard Fixer and run it to fix coding style issues before committing modifications. This ensures adherence to PSR-1, PSR-2, and Symfony Coding Standards. ```bash php-cs-fixer fix --verbose ``` -------------------------------- ### Good Commit Message Subject Example Source: https://github.com/sonata-project/sonataclassificationbundle/blob/4.x/CONTRIBUTING.md An example of a well-formed commit message subject. It is concise and clearly states the purpose of the change. ```git Document how to install the project ``` -------------------------------- ### PHP Docblock with Annotations Source: https://github.com/sonata-project/sonataclassificationbundle/blob/4.x/CONTRIBUTING.md Example of a PHP docblock demonstrating the use of @phpstan- annotations for static analysis and type hinting. Prefer @phpstan- annotations over classic ones for IDE support. ```php /** * @param Bar|Baz $foo * @param class-string $class * @param int $limit a crucial, fascinating comment * * @return object * * @phpstan-template T of object * @phpstan-param class-string $class * @phpstan-return T */ protected function bar($foo, string $class, int $limit): object { // ... } ``` -------------------------------- ### Bad Commit Message Subject Example Source: https://github.com/sonata-project/sonataclassificationbundle/blob/4.x/CONTRIBUTING.md An example of a commit message subject that is too vague. It should be more precise about the action taken. ```git Update README.md ``` -------------------------------- ### Commit Message with Description Example Source: https://github.com/sonata-project/sonataclassificationbundle/blob/4.x/CONTRIBUTING.md A good commit message that includes a clear subject line and a detailed description explaining the reasoning behind the changes and referencing related issues. ```git call foo::bar() instead of bar::baz() This fixes a bug that arises when doing this or that, because baz() needs a flux capacitor object that might not be defined. Fixes #42 ``` -------------------------------- ### Good Commit Message with Description (Fictional) Source: https://github.com/sonata-project/sonataclassificationbundle/blob/4.x/CONTRIBUTING.md An example of a commit message with a descriptive subject and a detailed explanation, including references to issues and a rationale for the change. ```git Change web UI background color to pink This is a consensus made on #4242 in addition to #1337. We agreed that blank color is boring and so deja vu. Pink is the new way to do. ``` -------------------------------- ### Open Local Documentation Build Source: https://github.com/sonata-project/sonataclassificationbundle/blob/4.x/CONTRIBUTING.md Opens the locally built HTML documentation in your web browser. This command assumes the documentation has been successfully built using 'make docs'. ```bash $YOUR_FAVORITE_BROWSER docs/_build/html/index.html ``` -------------------------------- ### Entity and Admin Class Mappings Source: https://github.com/sonata-project/sonataclassificationbundle/blob/4.x/docs/reference/advanced_configuration.md Configure the entity classes and admin classes for tags, categories, collections, and contexts. This allows customization of the underlying data models and admin interfaces. ```yaml sonata_classification: class: tag: App\Entity\SonataClassificationTag category: App\Entity\SonataClassificationCategory collection: App\Entity\SonataClassificationCollection context: App\Entity\SonataClassificationContext admin: tag: class: Sonata\ClassificationBundle\Admin\TagAdmin controller: Sonata\AdminBundle\Controller\CRUDController translation: SonataClassificationBundle category: class: Sonata\ClassificationBundle\Admin\CategoryAdmin controller: Sonata\ClassificationBundle\Controller\CategoryAdminController translation: SonataClassificationBundle collection: class: Sonata\ClassificationBundle\Admin\CollectionAdmin controller: Sonata\AdminBundle\Controller\CRUDController translation: SonataClassificationBundle context: class: Sonata\ClassificationBundle\Admin\ContextAdmin controller: Sonata\AdminBundle\Controller\CRUDController translation: SonataClassificationBundle ``` -------------------------------- ### Configure Sonata Classification Bundle Classes Source: https://github.com/sonata-project/sonataclassificationbundle/blob/4.x/docs/reference/installation.md Define custom entity classes for tags, categories, collections, and contexts in the Sonata Classification Bundle configuration. ```yaml # config/packages/sonata_classification.yaml sonata_classification: class: tag: App\Entity\SonataClassificationTag category: App\Entity\SonataClassificationCategory collection: App\Entity\SonataClassificationCollection context: App\Entity\SonataClassificationContext ``` -------------------------------- ### Custom Category List Block Service Source: https://github.com/sonata-project/sonataclassificationbundle/blob/4.x/docs/reference/block_bundle_integration.md Implement a custom block service by extending AbstractCategoriesBlockService to define settings and metadata for a dynamic category list. ```php class CustomCategoriesBlockService extends AbstractCategoriesBlockService { public function configureSettings(OptionsResolver $resolver): void { parent::configureSettings($resolver); $resolver->setDefaults([ 'context' => 'custom', 'template' => '@AcmeCustom/Block/block_categories.html.twig', ]); } public function getMetadata(): Metadata { return new Metadata('my_custom_block_title', null, null, 'AcmeCustomBundle', [ 'class' => 'fa fa-folder-open-o', ]); } } ``` -------------------------------- ### Marking Code for Future Major Release Source: https://github.com/sonata-project/sonataclassificationbundle/blob/4.x/CONTRIBUTING.md Use the `NEXT_MAJOR` comment to indicate code that should be uncommented or reworked in a subsequent major release. This is typically used when introducing new methods or features that are not backward compatible. ```php ['all' => true], ]; ``` -------------------------------- ### Update Doctrine Schema Source: https://github.com/sonata-project/sonataclassificationbundle/blob/4.x/docs/reference/installation.md After defining entities and mappings, run this command to update your database schema to reflect the changes. ```bash bin/console doctrine:schema:update --force ``` -------------------------------- ### Deprecate Service Definition in XML Source: https://github.com/sonata-project/sonataclassificationbundle/blob/4.x/CONTRIBUTING.md When deprecating a service, specify it in the service definition using the `` tag. Include a `NEXT_MAJOR` comment. ```xml The "%service_id%" service is deprecated since sonata-project/bar-bundle 42.x and will be removed in 43.0. ``` -------------------------------- ### Deprecate Method with @deprecated and @trigger_error Source: https://github.com/sonata-project/sonataclassificationbundle/blob/4.x/CONTRIBUTING.md For methods, use both the `@deprecated` tag and `@trigger_error` to signal deprecation. Include a `NEXT_MAJOR` comment. ```php /** * NEXT_MAJOR: Remove this method. * * @deprecated since sonata-project/foo-lib 42.x, to be removed in 43.0. */ public function iAmBatman() { @trigger_error(sprintf( 'Method %s() is deprecated since sonata-project/foo-lib 42.x and will be removed in version 43.0.', __METHOD__ ), \E_USER_DEPRECATED); echo "But this is not Gotham here."; } ``` -------------------------------- ### Mark Legacy Tests with @group legacy Source: https://github.com/sonata-project/sonataclassificationbundle/blob/4.x/CONTRIBUTING.md Mark unit tests that relate to deprecated features with the `@group legacy` annotation. Include a `NEXT_MAJOR` comment to explain future handling. ```php /** * @group legacy * NEXT_MAJOR: Remove this test. */ ``` -------------------------------- ### Define SonataClassificationContext Entity Source: https://github.com/sonata-project/sonataclassificationbundle/blob/4.x/docs/reference/installation.md Create a custom Context entity by extending the base Sonata Classification Bundle entity and defining its ORM mapping. ```php // src/Entity/SonataClassificationContext.php use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; use Sonata\ClassificationBundle\Entity\BaseContext; #[ORM\Entity] #[ORM\Table(name: 'classification__context')] class SonataClassificationContext extends BaseContext { #[ORM\Id] #[ORM\Column(type: Types::STRING)] protected ?string $id = null; } ``` -------------------------------- ### Configure Doctrine ORM Mapping for SonataClassificationBundle Source: https://github.com/sonata-project/sonataclassificationbundle/blob/4.x/docs/reference/installation.md Ensure Doctrine ORM recognizes the Sonata Classification Bundle's mappings. This can be done via explicit mapping definition or auto-mapping. ```yaml # config/packages/doctrine.yaml doctrine: orm: entity_managers: default: mappings: SonataClassificationBundle: ~ ``` -------------------------------- ### SonataClassificationContext Document Source: https://github.com/sonata-project/sonataclassificationbundle/blob/4.x/docs/reference/installation.md Defines the custom Context document for Doctrine MongoDB. Ensure this class extends Sonata tClassificationBundle tDocument BaseContext. ```php // src/Document/SonataClassificationContext.php use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; use Sonata\ClassificationBundle\Document\BaseContext; #[ODM\Document] class SonataClassificationContext extends BaseContext { #[ODM\Id] protected $id; } ``` -------------------------------- ### Sonata Classification Bundle Configuration Source: https://github.com/sonata-project/sonataclassificationbundle/blob/4.x/docs/reference/installation.md Configures the Sonata Classification Bundle to use the custom MongoDB document classes. This mapping is essential for the bundle to correctly interact with your database. ```yaml # config/packages/sonata_classification.yaml sonata_classification: class: tag: App\Document\SonataClassificationTag category: App\Document\SonataClassificationCategory collection: App\Document\SonataClassificationCollection context: App\Document\SonataClassificationContext ``` -------------------------------- ### Define SonataClassificationCategory Entity Source: https://github.com/sonata-project/sonataclassificationbundle/blob/4.x/docs/reference/installation.md Create a custom Category entity by extending the base Sonata Classification Bundle entity and defining its ORM mapping. ```php // src/Entity/SonataClassificationCategory.php use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; use Sonata\ClassificationBundle\Entity\BaseCategory; #[ORM\Entity] #[ORM\Table(name: 'classification__category')] class SonataClassificationCategory extends BaseCategory { #[ORM\Id] #[ORM\Column(type: Types::INTEGER)] #[ORM\GeneratedValue] protected ?int $id = null; public function getId(): ?int { return $this->id; } } ``` -------------------------------- ### Define SonataClassificationTag Entity Source: https://github.com/sonata-project/sonataclassificationbundle/blob/4.x/docs/reference/installation.md Create a custom Tag entity by extending the base Sonata Classification Bundle entity and defining its ORM mapping. ```php // src/Entity/SonataClassificationTag.php use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; use Sonata\ClassificationBundle\Entity\BaseTag; #[ORM\Entity] #[ORM\Table(name: 'classification__tag')] class SonataClassificationTag extends BaseTag { #[ORM\Id] #[ORM\Column(type: Types::INTEGER)] #[ORM\GeneratedValue] protected ?int $id = null; public function getId(): ?int { return $this->id; } } ``` -------------------------------- ### Define SonataClassificationCollection Entity Source: https://github.com/sonata-project/sonataclassificationbundle/blob/4.x/docs/reference/installation.md Create a custom Collection entity by extending the base Sonata Classification Bundle entity and defining its ORM mapping. ```php // src/Entity/SonataClassificationCollection.php use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; use Sonata\ClassificationBundle\Entity\BaseCollection; #[ORM\Entity] #[ORM\Table(name: 'classification__collection')] class SonataClassificationCollection extends BaseCollection { #[ORM\Id] #[ORM\Column(type: Types::INTEGER)] #[ORM\GeneratedValue] protected ?int $id = null; public function getId(): ?int { return $this->id; } } ``` -------------------------------- ### SonataClassificationTag Document Source: https://github.com/sonata-project/sonataclassificationbundle/blob/4.x/docs/reference/installation.md Defines the custom Tag document for Doctrine MongoDB. Ensure this class extends Sonata tClassificationBundle tDocument BaseTag. ```php // src/Document/SonataClassificationTag.php use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; use Sonata\ClassificationBundle\Document\BaseTag; #[ODM\Document] class SonataClassificationTag extends BaseTag { #[ODM\Id] protected $id; } ``` -------------------------------- ### SonataClassificationCollection Document Source: https://github.com/sonata-project/sonataclassificationbundle/blob/4.x/docs/reference/installation.md Defines the custom Collection document for Doctrine MongoDB. Ensure this class extends Sonata tClassificationBundle tDocument BaseCollection. ```php // src/Document/SonataClassificationCollection.php use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; use Sonata\ClassificationBundle\Document\BaseCollection; #[ODM\Document] class SonataClassificationCollection extends BaseCollection { #[ODM\Id] protected $id; } ``` -------------------------------- ### SonataClassificationCategory Document Source: https://github.com/sonata-project/sonataclassificationbundle/blob/4.x/docs/reference/installation.md Defines the custom Category document for Doctrine MongoDB. Ensure this class extends Sonata tClassificationBundle tDocument BaseCategory. ```php // src/Document/SonataClassificationCategory.php use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; use Sonata\ClassificationBundle\Document\BaseCategory; #[ODM\Document] class SonataClassificationCategory extends BaseCategory { #[ODM\Id] protected $id; } ``` -------------------------------- ### Deprecate General Code with @trigger_error Source: https://github.com/sonata-project/sonataclassificationbundle/blob/4.x/CONTRIBUTING.md For general code parts not covered by the `@deprecated` tag, use `@trigger_error` to signal deprecation. Include a `NEXT_MAJOR` comment and a clear message. ```php {{ item.name }} {% endblock %} ``` -------------------------------- ### Override Category Tree Template Source: https://github.com/sonata-project/sonataclassificationbundle/blob/4.x/docs/reference/advanced_usage.md Customize the admin tree view template for categories by specifying a new path in the SonataAdminBundle configuration. This allows for custom rendering of the category hierarchy. ```yaml sonata_admin: admin_services: sonata.classification.admin.category: templates: view: tree: '@App/CategoryAdmin/tree.html.twig' ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.