Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Awilum authored Dec 23, 2020
1 parent b7953a9 commit f44200f
Showing 1 changed file with 7 additions and 134 deletions.
141 changes: 7 additions & 134 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,15 @@ There are several **core objects** that are available to a Twig template, and ea
#### registry

Registry stored all flextype, themes and plugins settings.<br>
You can access Flextype registry via the registry object.
You can access and manipulate Flextype registry via the registry object.

Usage:

```twig
{{ registry.flextype.theme }} {# returns the currently configured theme #}
{{ registry.dump() }}
{{ registry.set() }}
{{ registry.has() }}
{{ registry.get() }}
```

##### entry
Expand Down Expand Up @@ -334,7 +337,7 @@ Usage:
{% do emitter.emitBatch({'onThemeHeader', 'onSomeOtherEvent'}) %}
```

##### arr
##### arrays

Contains methods that can be useful when working with arrays.

Expand All @@ -343,143 +346,13 @@ Sorts a multi-dimensional array by a certain column
Usage:

```twig
{% set new_array = arr.sort(old.array, 'title') %}
```

Sets an array value using "dot notation".

Usage:

```twig
{% set entry = arr.set(entry, 'title', 'New Title') %}
```

Return value from array using "dot notation".
If the key does not exist in the array, the default value will be returned instead.

Usage:

```twig
{{ arr.get(entry, 'title') }}
```

Delete an array value using "dot notation".

Usage:

```twig
{% set entry = arr.delete(entry, 'title') %}
```

Checks if the given dot-notated key exists in the array.

Usage:

```twig
{% if arr.keyExists(entry, 'title') %}
Do something...
{% endif %}
```

Returns a random value from an array.

Usage:

```twig
{{ arr.random(['php', 'js', 'css', 'html']) }}
```

Returns TRUE if the array is associative and FALSE if not.

Usage:

```twig
{% if arr.isAssoc(entry) %}
Do something...
{% endif %}
```

Returns TRUE if the array is associative and FALSE if not.

Usage:

```twig
{% set array1 = {'name': 'john', 'mood': 'happy', 'food': 'bacon'} %}
{% set array2 = {'name': 'jack', 'food': 'tacos', 'drink': 'beer'} %}
{% set array3 = arr.overwrite(array1, array2) %}
```

Converts an array to a JSON string

Usage:

```twig
{{ arr.json(entry) }}
```

Returns the first element of an array

Usage:

```twig
{{ arr.first(entry) }}
```

Returns the last element of an array

Usage:

```twig
{{ arr.last(entry) }}
```

Converts an array to a JSON string

Usage:

```twig
{{ arr.toJson(entry) }}
```

Create an new Array from JSON string.

Usage:

```twig
{% set array = arr.createFromJson($string) %}
```

Create an new Array object via string.

Usage:

```twig
{% set array = arr.createFromString('cat, dog, bird', ',') %}
```

Counts all elements in an array.

Usage:

```twig
{{ arr.size(array) }}
```

Return an array with elements in reverse order.

Usage:

```twig
{% set new_array = arr.reverse(old_array) %}
{% set new_array = arrays(old.array).sortBy('title') %}
```

#### Global Variables

```twig
{{ PATH_PROJECT }} {# Returns the path to the project directory (without trailing slash). #}
{{ PATH_LOGS }} {# Returns the path to the logs directory (without trailing slash). #}
{{ PATH_CONFIG }} {# Returns the path to the default config directory (without trailing slash). #}
{{ PATH_CACHE }} {# Returns the path to the cache directory (without trailing slash). #}
{{ PHP_VERSION }} {# Returns the php version #}
```

Expand Down

0 comments on commit f44200f

Please sign in to comment.