Download the PHP package pragmatic-modules/jslayout-parser without Composer

On this page you can find all versions of the php package pragmatic-modules/jslayout-parser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package jslayout-parser

JS Layout Parser

Lightweight standalone PHP library that was created to make work with $jsLayout in Magento 2 less spaghetti, and more object-oriented.

Installation

Usage On Checkout

Add new layout processor by implementing LayoutProcessorInterface, and inject it into layoutProcessors array.

File: etc/frontend/di.xml

Inject Pragmatic\JsLayoutParser\Model\JsLayoutParser into processor and parse $jsLayout for selected root component.

You can find a list of available component methods below.

JsLayoutParser Methods

parse( array $jsLayout, string $rootComponent )

Parse $jsLayout into nested component objects tree.

$rootComponent is name of the component out of $jsLayout['components'] that will be used as a base path for any operations.

Returns root Component object.


Component Methods

asArray( )

Recursively converts component object and all of its nested children into a plain array that can be returned through $jsLayout.

Example:

scroll up️


getComponentName( )

Get component name in layout.

Returns string.

Example:

jsLayout equivalent:

In associative $jsLayout array components are stored as nested key-value pairs, where value are arrays with nested children. It is not possible to determine parent's key within child scope. The same array might be used in multiple places within jsLayout, so recursive searching is not an option.

In other words, you must know the name before retrieving component:

and once you get into child scope, there is no way to dynamically tell what's the parent key:

The closest you can get to the parser behaviour is by doing:

scroll up️


getParent( )

Get parent component.

Returns ComponentInterface if parent exists.

Returns NULL if parent does not exist.

Example:

jsLayout equivalent:

scroll up️


remove( )

Remove component with all descendants from the component tree.

This method has no return value.

Example:

jsLayout equivalent:

scroll up️


hasChild ( string $componentName )

Check if component has a child with a given name.

Returns bool.

Example:

jsLayout equivalent:

scroll up️


getChild( string $componentName )

Get component child.

Returns ComponentInterface if child exists.

Returns NULL if child does not exist.

Example:

jsLayout equivalent:

scroll up️


addChild( ComponentInterface $component )

Add new component as a child of the current component object.

This method throws Exception if component with the same name is already a child of current component.

Returns self on success.

Example:

jsLayout equivalent:

scroll up️


removeChild ( string $componentName )

Remove child from the component.

This method throws Exception if child does not exist within component.

This method has no return value.

Example:

jsLayout equivalent:

scroll up️


hasNestedChild ( string $path, string $childSeparator = '.' )

Check if component has a nested child with a given path.

By default, children are separated by a dot. This behaviour can be adjusted by passing custom separator as a second argument.

Returns bool.

Example:

jsLayout equivalent:

scroll up️


getNestedChild ( string $componentName, string $childSeparator = '.' )

Get component nested child.

By default, children are separated by a dot. This behaviour can be adjusted by passing custom separator as a second argument.

Returns ComponentInterface if nested child exists.

Returns NULL if nested child does not exist.

Example:

jsLayout equivalent:

scroll up️


moveNestedChild ( string $sourcePath, string $destinationPath, string $childSeparator = '.' )

Move nested child from source to destination.

By default, children are separated by a dot. This behaviour can be adjusted by passing custom separator as a third argument.

This method throws Exception if source or destination does not exist.

This method has no return value.

Example:

jsLayout equivalent:

scroll up️


removeNestedChild ( string $path, string string $childSeparator = '.' )

Remove nested child by path.

By default, children are separated by a dot. This behaviour can be adjusted by passing custom separator as a third argument.

This method throws Exception if source or destination does not exist.

This method has no return value.

Example:

jsLayout equivalent:

scroll up️


hasChildren ( )

Check if component has children.

Returns true if at least one child exists, returns false otherwise.

Example:

jsLayout equivalent:

scroll up️


getChildren ( )

Get component children.

Returns array of components.

Returns empty array if component has no children.

Example:

jsLayout equivalent:

scroll up️


isChildOf ( ComponentInterface $component )

Check if component is child of given component.

Example:

jsLayout equivalent:

In associative $jsLayout array components are stored as nested key-value pairs, where value are arrays with nested children. It is not possible to determine parent within child scope.

scroll up️


getComponent ( )

Get UI Component of given component object.

Example:

jsLayout equivalent:

scroll up️


setComponent ( string $component )

Set UI Component of given component object.

Example:

jsLayout equivalent:

scroll up️


getConfig ( )

Get component configuration.

Returns array.

Example:

jsLayout equivalent:

scroll up️


setConfig ( array $config, bool $replace = false )

Set component configuration.

Configurations are merged together by default. Previous values remain intact except the ones that have the same keys as $config array.

$config values have higher priority and can be used to replace parts of existing configuration.

Entire component configuration can be overwritten by $config by using $replace = true.

Returns self.

Example:

jsLayout equivalent:

scroll up️


getDataScope ( )

Get component data scope.

Returns string or null.

Example:

jsLayout equivalent:

scroll up️


setDataScope ( string $dataScope )

Set component data scope.

Returns self.

Example:

jsLayout equivalent:

scroll up️


getDisplayArea ( )

Get component display area.

Returns string or null.

Example:

jsLayout equivalent:

scroll up️


setDisplayArea ( string $displayArea )

Set component display area.

Returns self.

Example:

jsLayout equivalent:

scroll up️


getLabel ( )

Get component label.

Returns string, Magento\Framework\Phrase, or null.

Example:

jsLayout equivalent:

scroll up️


setLabel ( $label )

Set component label.

$label should be either string, Magento\Framework\Phrase, or null.

Returns self.

Example:

jsLayout equivalent:

scroll up️


getProvider ( )

Get component provider.

Returns string or null.

Example:

jsLayout equivalent:

scroll up️


setProvider ( string $provider )

Set component provider.

Returns self.

Example:

jsLayout equivalent:

scroll up️


getSortOrder ( )

Get component sort order.

Returns string, or null.

Example:

jsLayout equivalent:

scroll up️


setSortOrder ( string $sortOrder )

Set component sort order.

Returns self.

Example:

jsLayout equivalent:

scroll up️


getValidation ( )

Get component validation rules.

Returns array or null.

Example:

jsLayout equivalent:

scroll up️


setValidation ( array $validation )

Set component validation rules.

Returns self.

Example:

jsLayout equivalent:

scroll up️


getFilterBy ( )

Get component filter by configuration.

Returns array or null.

Example:

jsLayout equivalent:

scroll up️


setFilterBy ( ?array $filterBy )

Set component filter by configuration.

Returns self.

Example:

jsLayout equivalent:

scroll up️


isVisible ( )

Get component visibility.

Returns bool.

Example:

jsLayout equivalent:

scroll up️


setIsVisible ( bool $visible )

Set component visibility.

Returns self.

Example:

jsLayout equivalent:

scroll up️


isRequired ( )

Get component required flag.

Returns bool.

Example:

jsLayout equivalent:

scroll up️


setIsRequired ( bool $required )

Set component required flag.

Returns self.

Example:

jsLayout equivalent:

scroll up️



All versions of jslayout-parser with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package pragmatic-modules/jslayout-parser contains the following files

Loading the files please wait ....