/** * Static helper to get an asset by the passed path (returned is not the concrete asset like Asset_Folder!) * * @param string $path * @return Asset */ public static function getByPath($path) { // remove trailing slash if ($path != "/") { $path = rtrim($path, "/ "); } // correct wrong path (root-node problem) $path = str_replace("//", "/", $path); try { $asset = new Asset(); if (Pimcore_Tool::isValidPath($path)) { $asset->getResource()->getByPath($path); return self::getById($asset->getId()); } } catch (Exception $e) { Logger::warning($e); } return null; }
/** * @static * @param $path * @return bool */ public static function pathExists($path, $type = null) { $path = Element_Service::correctPath($path); try { $object = new Object_Abstract(); if (Pimcore_Tool::isValidPath($path)) { $object->getResource()->getByPath($path); return true; } } catch (Exception $e) { } return false; }
/** * Static helper to get an asset by the passed path (returned is not the concrete asset like Asset_Folder!) * * @param string $path * @return Asset */ public static function getByPath($path) { $path = Element_Service::correctPath($path); try { $asset = new Asset(); if (Pimcore_Tool::isValidPath($path)) { $asset->getResource()->getByPath($path); return self::getById($asset->getId()); } } catch (Exception $e) { Logger::warning($e); } return null; }
/** * @static * @param $path * @return bool */ public static function pathExists($path) { $path = Element_Service::correctPath($path); try { $document = new Document(); // validate path if (Pimcore_Tool::isValidPath($path)) { $document->getResource()->getByPath($path); return true; } } catch (Exception $e) { } return false; }