Custom module PHP properties and methods

@patrick

Do you have php versions for these two posts?

2 Likes

@patrick Would sure be great to have these when you have a minute.

@patrick toSystemPath usage for php?

Check the fs.php module, you need to include the \lib\core\Path namespace and then you can use it like:

$path = Path::toSystemPath($options->path);

Here the example of exists from the fs module

<?php

namespace modules;

use \lib\core\Module;
use \lib\core\FileSystem;
use \lib\core\Path;

class fs extends Module
{
  public function exists($options) {
    option_require($options, 'path');

    $options->path = $this->app->parseObject($options->path);

    if (FileSystem::isfile($path)) {
      if (isset($options->then)) {
        $this->app->exec($options->then, TRUE);
      }
    } else {
      if (isset($options->else)) {
        $this->app->exec($options->else, TRUE);
      }
    }
  }
}

for all methods in Path class see the file dmxConnectLib/lib/core/Path.php, there is also a FileSystem class that takes care of some encoding issues on windows filesystems, for all methods check the file dmxConnectLib/lib/core/FileSystem.php.

2 Likes

Perfect, that’s the pointer I needed. Welcome back. :slight_smile: