PHPackages                             conan/silverstripe-data-object-utils - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. conan/silverstripe-data-object-utils

ActiveSilverstripe-vendormodule[Utility &amp; Helpers](/categories/utility)

conan/silverstripe-data-object-utils
====================================

Useful constants, CMS field helper functions and a permission extension for Silverstripe CMS ^4.

0.7.0(6y ago)0506[4 issues](https://github.com/conny-nyman/silverstripe-data-object-utils/issues)MITPHPPHP &gt;=7.1.0CI failing

Since Nov 17Pushed 2y ago1 watchersCompare

[ Source](https://github.com/conny-nyman/silverstripe-data-object-utils)[ Packagist](https://packagist.org/packages/conan/silverstripe-data-object-utils)[ RSS](/packages/conan-silverstripe-data-object-utils/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (24)Used By (0)

silverstripe-data-object-utils
==============================

[](#silverstripe-data-object-utils)

[![Build Status](https://camo.githubusercontent.com/e67cb84e0ce53fc1e3ebac608ae25c879f42edf6dc2d261c33911801c3924992/68747470733a2f2f7472617669732d63692e636f6d2f636f6e6e792d6e796d616e2f73696c7665727374726970652d646174612d6f626a6563742d7574696c732e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/conny-nyman/silverstripe-data-object-utils)[![codecov](https://camo.githubusercontent.com/f3455b25ab29902be33ea123bab8f4a0539f57ff34499be86f131ef901c56482/68747470733a2f2f636f6465636f762e696f2f67682f636f6e6e792d6e796d616e2f73696c7665727374726970652d646174612d6f626a6563742d7574696c732f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/conny-nyman/silverstripe-data-object-utils)

Description
-----------

[](#description)

Useful constants, CMS field helper functions and a permission extension for [Silverstripe CMS ^4](https://github.com/silverstripe/silverstripe-cms).

Keep your SilverStripe code DRY!

Constants
---------

[](#constants)

- Data types
- Search filter modifiers
- Data object fields
- Site tree fields
- Group fields

CMS fields util functions
-------------------------

[](#cms-fields-util-functions)

- Translate title and description on form fields using the same naming convention

Test/Validation utils
---------------------

[](#testvalidation-utils)

- Generate error message strings

Data object permission extension
--------------------------------

[](#data-object-permission-extension)

Apply and configure:

- `canView`
- `canEdit`
- `canCreate`
- `canDelete`

permission checks to data objects through an extension.

Example usages
--------------

[](#example-usages)

### Apply permission checks to data objects

[](#apply-permission-checks-to-data-objects)

First set the allowed group codes in a config file.

```
Conan\DataObjectUtils\DataObjectGroupPermissionExtension:
  can_view_group_codes:
    - 'administrators'
    - 'can_view_group_codes'
  can_edit_group_codes:
    - 'administrators'
    - 'can_edit_group_codes'
  can_create_group_codes:
    - 'administrators'
    - 'can_create_group_codes'
  can_delete_group_codes:
    - 'administrators'
    - 'can_delete_group_codes'

```

Then apply the extension to data objects.

```
namespace The\Namespace;

use Conan\DataObjectUtils\DataObjectGroupPermissionExtension;
use SilverStripe\ORM\DataObject;

class MyClass extends DataObject
{
    private static $extensions = [
        DataObjectGroupPermissionExtension::class,
    ];
}

```

### Translate CMS fields

[](#translate-cms-fields)

```
namespace The\Namespace;

use Conan\DataObjectUtils\DBConstants;
use Conan\DataObjectUtils\CMSFieldUtils;
use SilverStripe\ORM\DataObject;

class MyClass extends DataObject
{
    const MY_STRING_FIELD = 'MyStringField';
    const MY_INT_FIELD = 'MyIntField';

    private static $db = [
        self::MY_STRING_FIELD => DBConstants::VARCHAR,
        self::MY_INT_FIELD => DBConstants::INT,
    ];

    public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        $myStringField = $fields->dataFieldByName(self::MY_STRING_FIELD);
        CMSFieldUtils::setTitle($myStringField, 'My title');
        CMSFieldUtils::setDescription($myStringField, 'My description');

        // Or for both title and description you can use this
        // CMSFieldUtils::setTitleAndDescription($myStringField, 'My title', 'My description');
    }
}

```

The field can then be translated like this:

```
en:
  The\Namespace\MyClass:
    MyStringField.Title: 'Translated title'
    MyStringField.Description: 'Translated description'

```

By default the namespaced class name is used, but it is possible to pass a custom value as the caller class. e.g. `CMSFieldUtils::setTitle($myStringField, 'My title', 'MyModule');` and then translate it like this:

```
en:
  MyModule:
    MyStringField.Title: 'Translated title'
    MyStringField.Description: 'Translated description'

```

Versioning
----------

[](#versioning)

This library uses semantic versioning.

License
-------

[](#license)

`silverstripe-data-object-utils` is released under the MIT license. Please see the LICENSE file for more information.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~4 days

Total

19

Last Release

2300d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/71422eddadbca9494dbe39ee92963cf2f0fef07e3e0c29d027a5d8ddd0eeea1a?d=identicon)[conny-nyman](/maintainers/conny-nyman)

---

Top Contributors

[![conny-nyman](https://avatars.githubusercontent.com/u/25151529?v=4)](https://github.com/conny-nyman "conny-nyman (55 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/conan-silverstripe-data-object-utils/health.svg)

```
[![Health](https://phpackages.com/badges/conan-silverstripe-data-object-utils/health.svg)](https://phpackages.com/packages/conan-silverstripe-data-object-utils)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
