"backpack/pro": "^1.6.4",
"cubist/cms-front": "dev-backpack5",
"cubist/util": "dev-master",
- "cubist/locale": "dev-master",
+ "cubist/locale": "dev-backpack5",
"cubist/laravel-backpack-dropzone-field": "dev-master",
"spatie/laravel-translatable": "^6.4.0",
"venturecraft/revisionable": "^1.40.0",
return $this->_trigger($model, 'restored');
}
+ function retrieved(CubistMagicAbstractModel $model){
+ return $this->_trigger($model, 'retrieved');
+ }
+
+
protected function _trigger($model, $event)
{
$event = Str::camel('on_' . $event);
public function __construct(array $attributes = [])
{
$this->setup();
-
parent::__construct($attributes);
}
if (null !== $this->connection) {
$this->setConnection($this->connection);
}
- start_measure('Set form fields');
+ $label = 'Set '.get_class($this).' form fields';
+ start_measure($label);
$this->setFields();
$this->postSetFields();
- stop_measure('Set form fields');
+ stop_measure($label);
}
/**
}
- public function newFromBuilder($attributes = [], $connection = null)
- {
- $res = parent::newFromBuilder($attributes, $connection);
- $this->onRetreived();
- return $res;
- }
-
-
- public function onRetreived()
- {
-
- }
-
public function getPrimaryKey()
{
return $this->primaryKey;
return $nb;
}
+ public function onRetrieved(): bool
+ {
+ return true;
+ }
+
public function onSaved(): bool
{
return true;
return $field;
}
- public function getTranslations(string $key = null): array
+ public function getTranslations(string $key = null, array $allowedLocales = null): array
{
if ($key !== null) {
if (isset($this->_translations[$key])) {
return $this->_translations[$key];
}
- start_measure('Get translation of ' . $key);
+ $measure_label = 'Get translation of ' . get_class($this) . '::' . $key;
+ throw new \Error(':(');
+ start_measure($measure_label);
$this->guardAgainstNonTranslatableAttribute($key);
$attrs = $this->getAttributes();
if (!isset($attrs[$key])) {
});
}
$this->_translations[$key] = $res;
- stop_measure('Get translation of ' . $key);
+ stop_measure($measure_label);
return $res;
}
start_measure('Get all translations');
$res = array_reduce($this->getTranslatableAttributes(), function ($result, $item) {
$result[$item] = $this->getTranslations($item);
-
return $result;
});
stop_measure('Get all translations');
$value = $this->_migrateTranslation($key);
}
- if(str_starts_with($key,'t_') && !$value){
- $value='';
+ if (str_starts_with($key, 't_') && !$value) {
+ $value = '';
}
if (null === $f) {
$currentSection = '-';
$sections = [$currentSection => []];
+
foreach ($translate->getStringToTranslate() as $sectionLabel => $strings) {
$toTranslate = [];
foreach ($strings as $string) {
}
}
+ public function onRetrieved(): bool
+ {
+ $res = parent::onRetrieved();
+ return $res;
+ }
+
protected static function _encodeKey($string)
{
return 't_' . base64_encode($string);
}
-
public function onSaving(): bool
{
$this->saveLanguageFile();