PHP code example of zeix / craft-entry-type-policy

1. Go to this page and download the library: Download zeix/craft-entry-type-policy library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

zeix / craft-entry-type-policy example snippets


// German and Italian editors need permission for service pages. French doesn't.
['section' => 'pages', 'entryType' => 'servicesPage', 'sites' => ['de', 'it'], 'userGroups' => ['superUsers']],

['section' => 'pages', 'entryType' => 'newsOverview', 'limit' => 1, 'limitPer' => 'site'],

['section' => 'pages', 'entryType' => 'newsOverview', 'sites' => ['fr'], 'limit' => 3],
['section' => 'pages', 'entryType' => 'newsOverview', 'limit' => 1, 'userGroups' => ['superUsers'], 'limitPer' => 'site'],



return [
    'rules' => [
        ['section' => 'pages', 'entryType' => 'servicesPage', 'userGroups' => ['superUsers']],
        ['section' => 'pages', 'entryType' => 'newsOverview', 'limit' => 1, 'limitPer' => 'site', 'userGroups' => ['superUsers']],
    ],
];
sh
composer test        # php tests/resolve-rule-test.php
composer check-cs
composer phpstan
sh
ddev exec php plugins/craft-entry-type-policy/tests/integration-check.php