SilverStripe Model Annotations Task

Last update: Apr 21, 2022

SilverStripe Model Annotations Task

Build Status codecov Scrutinizer Code Quality

This module adds a dev task which generates annotations for your data object models. The problem is if you are working a lot with silver stripe models you will learn that no IDE can handle the DB fields as properties and/or collections as methods. So i made this task which completes my models with annotations from existing configs of the model itself and all extensions of it. Configs handled: db, has_one, has_many, many_many, many_many(through), belongs_to, belongs_many_many.

  1. Requirements
  2. Installation
  3. Usage
    1. Web
    2. Terminal
    3. Optional params
  4. Options
    1. dryRun (default: true)
    2. quiet (default: false)
    3. createBackupFile (default: false)
    4. addUseStatements (default: false)
  5. Example
  6. Documentation
  7. License
  8. Maintainers
  9. Bugtracker
  10. Development and contribution

Requirements

  • PHP 7.4 - PHP 8.0
  • PHP-AST extension
  • PHP-BCMATH extension
  • SilverStripe ^4.10

Installation

composer require --dev csoellinger/silverstripe-model-annotations-task

Usage

Run dev build to load the task and after you can execute it in your browser or cli.

Web

http://localhost/tasks/ModelAnnotationsTask

Terminal

vendor/bin/sake dev/tasks/ModelAnnotationsTask

Optional params

  • dryRun=0/1
  • quiet=0/1
  • createBackupFile=0/1
  • addUseStatements=0/1

Take a look at options section below to get more information about the params.

Options

All optional params from above can be set as silverstripe config at the ModelAnnotationsTask. Only difference is that the config is set as boolean var and not as integer. By default dryRun is set to true. If you want write the files with this task you need to set the config or set the param to false.

dryRun (default: true)

Only print the changes inside your browser or terminal and don't write any file.

quiet (default: false)

No output.

createBackupFile (default: false)

Create a backup file before writing the model. Only if dryRun is false.

addUseStatements (default: false)

Collect data types which are not declared as use statement and add them to the file. If this config is true it also shortens the data types.

Example

Here you see a small example how it will look your model file after using the task.

Your Input



class Player extends DataObject
{
    private static $db = [
        'Name' => 'Varchar(255)',
    ];
    private static $has_many = [
        'Jobs' => 'Job',
    ];
}

Task would write this file:



/**
 * @property string $Name Name...
 *
 * @method HasManyList Jobs() Get jobs
 */
class Player extends DataObject
{
    private static $db = [
        'Name' => 'Varchar(255)',
    ];
    private static $has_many = [
        'Jobs' => 'Job',
    ];
}

Documentation

License

See License

Maintainers

Bugtracker

Bugs are tracked in the issues section of this repository. Before submitting an issue please read over existing issues to ensure yours is unique.

If the issue does look like a new bug:

  • Create a new issue
  • Describe the steps required to reproduce your issue, and the expected outcome. Unit tests, screenshots and screencasts can help here.
  • Describe your environment as detailed as possible: SilverStripe version, Browser, PHP version, Operating System, any installed SilverStripe modules.

Please report security issues to the module maintainers directly. Please don't file security issues in the bugtracker.

Development and contribution

If you would like to make contributions to the module please ensure you raise a pull request and discuss with the module maintainers.

GitHub

https://github.com/CSoellinger/silverstripe-model-annotations-task
You might also like...

Markdownfield - Markdown field for SilverStripe

MarkdownField This module introduces a new DB field type Markdown & Markdown Editor. It uses github style Markdown style. And uses the simple markdown

Apr 21, 2022

Automatically delete old SiteTree page versions from Silverstripe

Version truncator for Silverstripe An extension for Silverstripe to automatically delete old versioned DataObject records from your database when a re

Mar 28, 2022

Silverstripe-populate - Populate your database through YAML files

Populate Module This module provides a way to populate a database from YAML fixtures and custom classes. For instance, when a building a web applicati

Apr 29, 2022

Silverstripe-ideannotator - Generate docblocks for DataObjects, Page, PageControllers and (Data)Extensions

silverstripe-ideannotator This module generates @property, @method and @mixin tags for DataObjects, PageControllers and (Data)Extensions, so ide's lik

May 9, 2022

Silverstripe-tinytidy - Control which styles are available in TinyMCE's style dropdown menu and what elements they can be applied to

Silverstripe-tinytidy - Control which styles are available in TinyMCE's style dropdown menu and what elements they can be applied to

TinyTidy for SilverStripe This module mainly serves as an example of how to customise the 'styles' dropdown menu in the TinyMCE editor to control whic

Jul 30, 2020

Alerts users in the SilverStripe CMS when multiple people are editing the same page.

Multi-User Editing Alert Alerts users in the SilverStripe CMS when multiple people are editing the same page. Maintainer Contact Julian Seidenberg ju

Dec 17, 2021

This module integrates Silverstripe CMS with Google Translate API and then allows content editors to use automatic translation for every translatable field.

This module integrates Silverstripe CMS with Google Translate API and then allows content editors to use automatic translation for every translatable field.

Autotranslate This module integrates Silverstripe CMS with Google Translate API and then allows content editors to use automatic translation for every

Jan 3, 2022

Silverstripe module allowing editors to create newsletters using elemental blocks and export them to a sendy instance

Silverstripe Sendy Silverstripe module allowing editors to create newsletters using elemental blocks and export them to a sendy instance. Introduction

Apr 20, 2022

Helper plugin to install SilverStripe recipes

Helper plugin to install SilverStripe recipes

SilverStripe recipe-plugin Introduction This plugin enhances composer and allows for the installation of "silverstripe-recipe" packages. These recipes

Apr 1, 2022
Silverstripe-debugbar/ - SilverStripe DebugBar module
Silverstripe-debugbar/ - SilverStripe DebugBar module

SilverStripe DebugBar module Requirements SilverStripe ^4.0 maximebf/php-debugbar jdorn/sql-formatter Installation You can install the debug bar with

Nov 3, 2021
Silverstripe-fulltextsearch - Adds external full text search engine support to SilverStripe

FullTextSearch module Adds support for fulltext search engines like Sphinx and Solr to SilverStripe CMS. Compatible with PHP 7.2 Important notes when

Mar 25, 2022
Silverstripe-searchable - Adds to the default Silverstripe search by adding a custom results controller and allowing properly adding custom data objects and custom fields for searching

SilverStripe Searchable Module UPDATE - Full Text Search This module now uses Full Text Support for MySQL/MariaDB databases in version 3.* Adds more c

Apr 14, 2022
A SilverStripe module for conveniently injecting JSON-LD metadata into the header of each rendered page in SilverStripe

A SilverStripe module for conveniently injecting JSON-LD metadata into the header of each rendered page in Silver

Apr 20, 2022
Annotations Docblock Parser

Doctrine Annotations Docblock Annotations Parser library (extracted from Doctrine Common). Documentation See the doctrine-project website. Contributin

May 19, 2022
Add scalar type hints and return types to existing PHP projects using PHPDoc annotations

PHPDoc to Type Hint Archived! This repository is now archived. Consider using PHP CS Fixer (and especially the phpdoc_to_param_type and phpdoc_to_retu

May 22, 2022
Task for GrumPHP that adds CSS linting support with stylelint. An easy way to enforce convention and avoid errors in your styles

grumphp-stylelint-task Installation Stylelint is a static analysis tool for styles. A mighty, modern linter that helps you avoid errors and enforce co

Apr 29, 2021
SilverStripe Garbage Collection Module

SilverStripe Module for defining and processing Garbage Collection on SilverStripe Applications.

Apr 15, 2022
Silverstripe-sspy - Python based SSPAK export with higher reliability and cross-platform compatibility

SSPY - Python Stand-alone SSPAK solution © Simon Firesphere Erkelens; Moss Mossman Cantwell Usage: sspy [create|load|extract] (db|assets) --file=my.

Jun 29, 2021
Sspak - Tool for managing bundles of db/assets from SilverStripe environments

SSPak SSPak is a SilverStripe tool for managing database and assets content, for back-up, restoration, or transfer between environments. The file form

May 23, 2022