/**
* Method to add a path to the list of include paths for one of the form's entities.
* Currently supported entities: field, rule and form. You are free to support your own in a subclass.
*
* @param string $entity Form's entity name for which paths will be added.
* @param mixed $new A path or array of paths to add.
*
* @return array The list of paths that have been added.
*
* @since 1.7.0
*/
protected static function addPath($entity, $new = null)
{
if (!isset(self::$paths[$entity])) {
self::$paths[$entity] = [];
}
// Reference to an array with paths for current entity
$paths =& self::$paths[$entity];
// Force the new path(s) to an array.
settype($new, 'array');
// Add the new paths to the stack if not already there.
foreach ($new as $path) {
$path = \trim($path);
if (!\in_array($path, $paths)) {
\array_unshift($paths, $path);
}
}
return $paths;
}