PHP code example of napp / modulecore

1. Go to this page and download the library: Download napp/modulecore 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/ */

    

napp / modulecore example snippets



 

namespace Napp\Forms;

use Napp\Forms\Event\FormWasSubmittedEvent;
use Napp\Forms\Listener\SendFormSubmissionEmailListener;
use Napp\Forms\Model\Form;
use Napp\Forms\Observer\FormObserver;
use Napp\Forms\Repository\FormsRepository;
use Napp\Forms\Repository\FormsRepositoryInterface;
use Napp\Core\Module\Provider\CoreServiceProvider;

class FormsServiceProvider extends CoreServiceProvider
{
    protected $routeNamespace = 'Napp\Forms';
    
    public const EXTENSION_FORM_BUILDER = 'extension.form_builder';
    
    public const FEATURE_ALLOW_SOMETHING = 'feature.form_allow_something';
    
    protected $repositories = [
        FormsRepositoryInterface::class => FormsRepository::class
    ];
    
    protected $features = [
        self::FEATURE_ALLOW_SOMETHING => [
            'translation_key',
            true // boolean true if the feature has settings    
        ],
        self::FEATURE_ALLOW_SOMETHING => 'translation_key'    
    ];
    
    protected $events = [
        FormWasSubmittedEvent::class => SendFormSubmissionEmailListener::class
    ];

    protected $permissions = [
        'forms.view',
        'forms.create',
        'forms.update',
        'forms.delete',
        'forms.duplicate',
        'forms.entries'
    ];

    protected $observers = [
        Form::class => FormObserver::class
    ];

    protected $extensions = [
        self::EXTENSION_FORMS => 'extensions.forms'
    ];

    protected function getCMSRoutes()
    {
        return __DIR__ . '/routes/cms.php';
    }

    protected function getApiRoutes()
    {
        return __DIR__ . '/routes/api.php';
    }

    protected function getFrontRoutes()
    {
        return __DIR__ . '/routes/front.php';
    }

    protected function getFrontApiRoutes()
    {
        return __DIR__ . '/routes/frontApi.php';
    }
}