Code Monkey home page Code Monkey logo

nette-configurator's Introduction

Configurator & translator

Installation

$ composer require geniv/nette-configurator

or

"geniv/nette-configurator": "^4.0"

require:

"php": ">=7.0",
"nette/nette": ">=2.4",
"dibi/dibi": ">=3.0",
"geniv/nette-locale": ">=2.0",
"geniv/nette-search-content": ">=1.0",
"geniv/nette-translator": ">=2.0"

Include in application

available source drivers:

  • DevNullDriver (default values)
  • DibiDriver (dibi + cache _Configurator-DibiDriver)

self translator class:

  • ConfiguratorTranslator (cache _Configurator-ConfiguratorTranslator)

neon configure:

# configurator
configurator:
#   debugger: true
#   autowired: true
#    driver: Configurator\Drivers\DevNullDriver
    driver: Configurator\Drivers\DibiDriver(%tablePrefix%)
    translator: false
#    searchMask: 
#       - *Translation.neon
    searchPath:
        - %appDir%/presenters/AppTranslation.neon
#    excludePath:
#        - CustomExcludeTranslation.neon

neon configure extension:

extensions:
    configurator: Configurator\Bridges\Nette\Extension

description

internal combination id_ident and id_locale must by unique! type content is only like "category" or "flag of type"

Internal data are loading in first usage component.

Available interface: IConfigurator

usage:

protected function createComponentConfig(IConfigurator $configurator): IConfigurator
{
    // disable auto create ident
    //$configurator->setAutoCreate(false);
    return $configurator;
}
$this['config']->isEnable('ident'): bool;
$this['config']->getValue('ident'): mixed;

// echo value of ident
$this['config']->renderText('ident');
// return value of ident
$this['config']->renderText('ident', true);

// substitute logic
$this['config']->renderText('ident', null, 'arg');
$this['config']->renderText('ident', null, ['arg']);

// set data like translator
$this['config']->setTranslator('ident', 'text');
$this['config']->setEditor('ident', 'new text');

$this['config']->getDataByIdent('ident');

usage:

{control config:text 'web-title'}

{control config:text 'web-title', true}

{control config:text 'web-title', null, 'argument'}
{control config:text 'web-title', null, ['argument']}

<h1 n:if="$presenter['config']->isEnable('web-title')">{control config:text 'web-title'}</h1>

<h1 n:if="$presenter['config']->getValue('show-web-title')">{control config:text 'web-title'}</h1>

{* long equivalent - WHY?!: *}
<h1 n:if="$presenter['config']->renderCheckbox('show-web-title', true)">{control config:text 'web-title'}</h1>

nette-configurator's People

Contributors

geniv avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.