$source = $modx->getObject('modMediaSource', 2); $path = $source->getBasePath();
PHP Fatal error: Call to a member function sanitizePath() on a non-object in /Applications/MAMP/htdocs/revo228/core/model/modx/sources/modfilemediasource.class.php on line 43It wants a fileHandler, but why do I need a fileHandler object if all I want to do is get the base path of the Media Source?
This question has been answered by sottwell. See the first response.
$source = $modx->getObject('modMediaSource', 2); $properties = $source->getProperties(); $path = $properties['basePath']['value']; return $path;
$source = $modx->getObject('modMediaSource', 2); $path = $source->getBasePath($source);
public function getBasePath($object = '') { $bases = $this->getBases($object); return $bases['pathAbsolute']; }
$source = $modx->getObject('modMediaSource', $id); $properties = $source->getProperties(); $prop = $properties[$property]['value']; return $prop;
$allowed = $source->checkPolicy('view', null, $userObject);
$allowed = $source->checkPolicy('view', array('sources.modAccessMediaSource'), $userObject);
/** * Allow overriding of checkPolicy to always allow media sources to be loaded * * @param string|array $criteria * @param array $targets * @param modUser $user * @return bool */ public function checkPolicy($criteria, $targets = null, modUser $user = null) { if ($criteria == 'load') { $success = true; } else { $success = parent::checkPolicy($criteria,$targets,$user); } return $success; }