public static function getByKey($key)
{
$fc = null;
$cacheKey = "fieldcollection_" . $key;
try {
$fc = \Zend_Registry::get($cacheKey);
if (!$fc) {
throw new \Exception("FieldCollection in registry is not valid");
}
} catch (\Exception $e) {
$fieldCollectionFolder = PIMCORE_CLASS_DIRECTORY . "/fieldcollections";
$fieldFile = $fieldCollectionFolder . "/" . $key . ".php";
if (is_file($fieldFile)) {
$fc = (include $fieldFile);
\Zend_Registry::set($cacheKey, $fc);
}
}
if ($fc) {
return $fc;
}
throw new \Exception("Field-Collection with key: " . $key . " does not exist.");
}