public function createObjectBrick($name, $jsonPath = null)
{
try {
$objectBrick = Object\Objectbrick\Definition::getByKey($name);
} catch (\Exception $e) {
if ($jsonPath == null) {
$jsonPath = PIMCORE_PLUGINS_PATH . "/CoreShop/install/fieldcollection-{$name}.json";
}
$objectBrick = new Object\Objectbrick\Definition();
$objectBrick->setKey($name);
$json = file_get_contents($jsonPath);
$result = Plugin::getEventManager()->trigger('install.objectbrick.preCreate', $this, array("objectbrickName" => $name, "json" => $json), function ($v) {
return !preg_match('/[^,:{}\\[\\]0-9.\\-+Eaeflnr-u \\n\\r\\t]/', preg_replace('/"(\\.|[^"\\\\])*"/', '', $v));
});
if ($result->stopped()) {
$resultJson = $result->last();
if ($resultJson) {
$json = $resultJson;
}
}
Object\ClassDefinition\Service::importObjectBrickFromJson($objectBrick, $json, true);
}
return $objectBrick;
}