Class: Vemto

Vemto()

This class represents the Vemto API and is automatically injected inside plugin's code (vemto on main.js and window.vemtoApi inside Vue components)

Constructor

new Vemto()

Properties:
Name Type Description
log LogBase Class for log from plugins
generator object An object that allows to control the code generation process
Properties
Name Type Description
abort function Allows you to abort the code generation process

Methods

addBlockReason(reason)

You can use this method to explain why a plugin installation was blocked inside the canInstall Hook
Parameters:
Name Type Description
reason string The message you want to show when the installation is blocked

addEntityMarker(entity, text, coloropt, textColor=opt)

Method responsible for creating an entity marker within Vemto Schema
Parameters:
Name Type Attributes Default Description
entity Entity The entity you want to add the marker
text string The text you want to show in the marker
color string <optional>
#14B8A6 The background color
textColor= string <optional>
Optional, leave it empty and it will choose a color by the background contrast

debounce(callback, time) → {string}

You can use this method to debounce operations on the plugin Vue component without the need of installing a debounce library.
Parameters:
Name Type Description
callback function
time number
Returns:
Type
string

executeCommand(command)

You can use this method to run a command inside the project folder
Parameters:
Name Type Description
command string The command you want to run

getMultiTenancyStrategy() → {string}

Returns the multitenancy strategy (login, single-database, multi-database)
Returns:
Type
string

getPluginData() → {object}

Returns the current plugin data
Returns:
Type
object

getProject() → {Project}

Returns the project
Returns:
Type
Project

getProjectEntities() → {Array.<Entity>}

Returns the project entities (models and tables)
Returns:
Type
Array.<Entity>

getProjectModels() → {Array.<Entity>}

Returns the project models
Returns:
Type
Array.<Entity>

getProjectSettings() → {object}

Returns the project settings
Returns:
Type
object

parsePhp(content) → {PhpParser}

You can use this method to parse a php file
Parameters:
Name Type Description
content string The content you want to parse
Returns:
Type
PhpParser

projectHasMultiTenancy() → {boolean}

Check if this project has already an installed multiTenancy plugin
Returns:
Type
boolean

renderTemplate(from, to, optionsopt) → {string}

You can use this method to render a custom template from a Vemto plugin
Parameters:
Name Type Attributes Default Description
from string The template path relative to your plugin folder
to string The generated file path, relative to the project folder
options object <optional>
{}
Properties
Name Type Attributes Default Description
formatAs= object <optional>
The formatter you want to use (php, html, blade) - Not obligatory
data object <optional>
{} The data you are passing to the template - Not obligatory
Returns:
Type
string

replaceTemplate(template, replacementPath)

You can use this method to replace a default Vemto template (it will work similarly to change) the template content in the Template Editor
Parameters:
Name Type Description
template string The template path (exactly how you see in the Template Editor) you want to replace
replacementPath string Path to the file, inside the plugin folder, you want to use as a replacement

savePluginData(data) → {string}

Returns the multitenancy strategy (login, single-database, multi-database)
Parameters:
Name Type Description
data object The data you want to save for your plugin (the data is saved in the project, and not globally)
Returns:
Type
string