Download the PHP package dd/evolutioncms-libraries-ddtools without Composer

On this page you can find all versions of the php package dd/evolutioncms-libraries-ddtools. 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 evolutioncms-libraries-ddtools

(MODX)EvolutionCMS.libraries.ddTools

A library with various tools facilitating your work.

Requires

Installation

Manually

  1. Create a new folder assets/libs/ddTools/.
  2. Extract the archive to the folder.

Using Composer

Just add dd/evolutioncms-libraries-ddtools to your composer.json.

ddTools version must be 0.14 or higher to use this method. If you use it, the compatibility with all your snippets, modules, etc. that use ddTools versions under 0.14 will be maintained.

Update using (MODX)EvolutionCMS.libraries.ddInstaller

Just run the following PHP code in your sources or Console:

Parameters description

\ddTools::isEmpty($value)

Determines whether a variable is empty.

The following values are considered as empty:

\ddTools::convertUrlToAbsolute($params)

Converts relative URLs to absolute.

The method tends to change URL as little as possible and just prepends required scheme and/or host (or sometimes nothing at all). All kinds of query parameters, hash, ports, etc. are not modified.

Returns

\ddTools::getTpl($tpl = '')

The same as $modx->getTpl with some differences:

Returns

\ddTools::parseText($params)

Replaces placeholders in a text with required values.

Returns

\ddTools::verifyRenamedParams($params)

The method checks an array for deprecated parameters and writes warning messages into the MODX event log. It returns an associative array, in which the correct parameter names are the keys and the parameter values are the values. You can use the exctract function to turn the array into variables of the current symbol table.

Returns

\DDTools\Tools\Files

\DDTools\Tools\Files::modifyImage($params)

Modify your images: create thumbnails, crop, resize, fill background color or add watermark.

\DDTools\Tools\Objects

\DDTools\Tools\Objects::isPropExists($params)

Checks if the object, class or array has a property / element. This is a “syntactic sugar” for checking an element in one way regardless of the “object” type.

The first reason for creating this method is convenience to not thinking about type of “object” variables. Second, the different order of parameters in the native PHP functions makes us crazy.

\DDTools\Tools\Objects::getPropValue($params)

Get the value of an object property or an array element in any nesting level in one way regardless of the “object” type.

Returns

\DDTools\Tools\Objects::convertType($params)

Converts an object type. Arrays, JSON and Query string objects are also supported.

Returns

\DDTools\Tools\Objects::extend($params)

Merge the contents of two or more objects or arrays together into the first one.

\DDTools\Tools\Objects::unfold($params)

Converts a multidimensional array/object into an one-dimensional one joining the keys with $params->keySeparator. For example, it can be helpful while using placeholders like [+size.width+].

Returns

\DDTools\Tools\Cache

You can cache some data (e. g. a snippet result).

\DDTools\Tools\Cache::save($params)

Saves custom data to cache storage.

\DDTools\Tools\Cache::saveSeveral($params)

Saves data of several items to cache storage.

\DDTools\Tools\Cache::get($params)

Retrieves item data from cache storage.

Returns

\DDTools\Tools\Cache::getSeveral($params)

Retrieves data of several items from cache storage.

Returns

\DDTools\Tools\Cache::delete($params)

Deletes one or more cache items.

\DDTools\ObjectCollection

Class representing a collection of some objects or arrays.

\DDTools\ObjectCollection::__construct($params)

\DDTools\ObjectCollection::setItems($params)

Sets new collection items. Existing items will be removed.

Has the same parameters as \DDTools\ObjectCollection::__construct($params).

\DDTools\ObjectCollection::addItems($params)

Appends items onto the end of collection.

Has the same parameters as \DDTools\ObjectCollection::__construct($params).

\DDTools\ObjectCollection::getItems($params)

Gets an array of required collection items.

Returns

\DDTools\ObjectCollection::getOneItem($params)

Gets required item.

\DDTools\ObjectCollection::count()

Counts all items.

\DDTools\ObjectCollection::convertItemsType($params)

Converts type of needed items in collection.

\DDTools\ObjectCollection::updateItems($params)

Undates properties of existing items with new values.

\DDTools\ObjectCollection::deleteItems($params)

Deletes required items from collection.

\DDTools\ObjectCollection::toJSON(), \DDTools\ObjectCollection::__toString()

Gets an JSON-array of all collection items.

Returns

\DDTools\ObjectCollection::setOneItemData (protected)

Sets data of an item object. All setting of an item data inside the class must be use this method. It's convenient to override this method in child classes if items are not plain objects.

\DDTools\ObjectCollection::getOneItemData (protected)

Returns data of an item object. All getting of an item data inside the class must use this method. It's convenient to override this method in child classes if items are not plain objects.

Returns

\DDTools\Base\Base

Simple abstract class with some small methods facilitating your work. It is convenient to inherit your classes from this.

You can see an example of how it works in the (MODX)EvolutionCMS.snippets.ddGetDocumentField code.

\DDTools\Base\Base::getClassName()

Gets data about a class name.

Returns

\DDTools\Base\Base::setExistingProps($props)

Sets existing object properties.

\DDTools\Base\Base::toArray()

Returns all properties of this object as an associative array independent of their visibility.

Returns

\DDTools\Base\Base::toJSON()

Returns all properties of this object as an JSON string independent of their visibility.

Returns

\DDTools\Base\Base::__toString()

The same as \DDTools\Base\Base::toJSON().

\DDTools\Base\AncestorTrait

Simple trait for ancestors with some small methods facilitating your work.

You can see an example of how it works in the (MODX)EvolutionCMS.snippets.ddGetDocumentField code.

\DDTools\Base\AncestorTrait::createChildInstance($params)

Returns

\DDTools\Base\AncestorTrait::getChildClassName($params)

Returns

\DDTools\Snippet

Abstract class for snippets.

Properties

\DDTools\Snippet::__construct($params)

\DDTools\Snippet::run()

Abstract method for main snippet action.

You must define it in your child class declaration.

\DDTools\Snippet::runSnippet($params)

Static method for easy running needed snippet using only it's name and parameters (if needed).

Examples

\ddTools::convertUrlToAbsolute($params): Convert relative URLs to absolute

$params->url can be set in various ways for more convenience:

Returns this with any of the above URLs:

Verify renamed snippet params (\ddTools::verifyRenamedParams($params))

Suppose we have the snippet ddSendFeedback with the getEmail and getId parameters. Over time, we decided to rename the parameters as docField and docId respectively (as it happened in version 1.9). And we want to save backward compatibility, the snippet must work with the old names and send message to the MODX event log.

Below we can use $docField and $docId and not to worry. The method will check everything and will send a message to the MODX event log.

After some time we decided to rename the parameters again as email_docField и email_docId. Nothing wrong, the method can works with multiple old names, just pass an array:

\ddTools::parseText($params)

Basic example

Returns:

Nested objects in $params->data

Returns:

\DDTools\Tools\Objects

\DDTools\Tools\Objects::convertType($params)

Convert a JSON or Query encoded string to an array

For example, some snippet supports 2 formats in one of parameters: JSON or Query string. Users use the format that is convenient to them and we support both. Just call this method and don't care about it.

Both calls return:

Convert a Query encoded string to a JSON object string

Returns:

Convert a JSON object to a JSON array

Returns:

Convert a HJSON encoded string to an object

Returns:

Convert an associative array to a string of HTML attributes

Returns:

\DDTools\Tools\Objects::extend($params)

Merge two objects, modifying the first

Returns:

Also you can extend arrays

Returns:

Moreover, objects can extend arrays and vice versa

Returns:

Don't overwrite fields with empty values ($params->overwriteWithEmpty == false)

By default, empty field values (e. g. '') are treated as other values and will replace non-empty ones.

Returns:

Empty lastName from the second object replaced non-empty lastName from the first.

If you want to ignore empty values, just use $params->overwriteWithEmpty == false:

Returns:

Extending only specific properties from subsequent objects ($params->extendableProperties)

Sometimes you want to keep only the key ingredients, like avoiding the pineapple on your pizza.

Returns:

\DDTools\Tools\Objects::unfold($params)

Unfold an object

Returns:

Unfold an array

Returns:

Use custom key separator

Returns:

Cross-type unfolding ($params->isCrossTypeEnabled == true)
Without cross-type unfolding (by default)

Returns:

With cross-type unfolding enabled

Returns:

\DDTools\Tools\Objects::isPropExists($params)

Checks if the object, class or array has a property / element using the same syntax.

You can pass an object:

Or an array:

Both calls return true.

\DDTools\Tools\Objects::getPropValue($params)

Get the value of an object property or an array element using the same syntax

You can pass an object:

Or an array:

Both calls return 'Floyd'.

Get the value of an object property or an array element in any nesting level

Source object can be nested, and elements of all levels can be mix of objects and arrays.

Get a first-level property

There's nothing special, just look at this example for the full picture.

Returns:

Get a second-level property

Let's make it a little more interesting: let's get the 4th element of the second-level indexed array.

Returns:

Get a third-level property

Any level of nesting is supported.

No matter what type of element is used in any nesting level, the method will work fine. So let's get Roger's name. As you remember, he is stdClass as opposed to the other members who are associative arrays.

Returns:

Of course, it works fine with single-level objects that contain '.' in their property names

Returns:

\DDTools\ObjectCollection

Create a collection with items

Set items as a JSON string

\DDTools\ObjectCollection::getItems($params)

Get an array of items using filter ($params->filter)
Filter by existence of a property

Returns:

Filter by a property value

Returns:

Filter using several conditions

Returns:

Get an associative array of items using a property value as a result key

Returns:

Get a one-dimensional array of item property values

Returns:

\DDTools\ObjectCollection::getOneItem($params)

Returns:

Custom results when no items found

Returns:

\DDTools\ObjectCollection::convertItemsType($params)

Returns:

\DDTools\ObjectCollection::updateItems($params)

Returns:

\DDTools\ObjectCollection::deleteItems($params)

Returns:

Links


All versions of evolutioncms-libraries-ddtools with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.0
dd/composer-plugin-modxevo-library-ddtools-installer Version 1.0.5
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 dd/evolutioncms-libraries-ddtools contains the following files

Loading the files please wait ....