Upgrade to 3.3.0
This commit is contained in:
@@ -19,6 +19,14 @@ use Throwable;
|
||||
*/
|
||||
abstract class ModelWithContent extends Model
|
||||
{
|
||||
/**
|
||||
* Each model must define a CLASS_ALIAS
|
||||
* which will be used in template queries.
|
||||
* The CLASS_ALIAS is a short human-readable
|
||||
* version of the class name. I.e. page.
|
||||
*/
|
||||
const CLASS_ALIAS = null;
|
||||
|
||||
/**
|
||||
* The content
|
||||
*
|
||||
@@ -194,8 +202,8 @@ abstract class ModelWithContent extends Model
|
||||
* Decrement a given field value
|
||||
*
|
||||
* @param string $field
|
||||
* @param integer $by
|
||||
* @param integer $min
|
||||
* @param int $by
|
||||
* @param int $min
|
||||
* @return self
|
||||
*/
|
||||
public function decrement(string $field, int $by = 1, int $min = 0)
|
||||
@@ -231,8 +239,8 @@ abstract class ModelWithContent extends Model
|
||||
* Increment a given field value
|
||||
*
|
||||
* @param string $field
|
||||
* @param integer $by
|
||||
* @param integer $max
|
||||
* @param int $by
|
||||
* @param int $max
|
||||
* @return self
|
||||
*/
|
||||
public function increment(string $field, int $by = 1, int $max = null)
|
||||
@@ -246,10 +254,21 @@ abstract class ModelWithContent extends Model
|
||||
return $this->update([$field => $value]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the model is locked for the current user
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isLocked(): bool
|
||||
{
|
||||
$lock = $this->lock();
|
||||
return $lock && $lock->isLocked() === true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the data has any errors
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isValid(): bool
|
||||
{
|
||||
@@ -382,6 +401,38 @@ abstract class ModelWithContent extends Model
|
||||
return $image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of all actions
|
||||
* that can be performed in the Panel
|
||||
* This also checks for the lock status
|
||||
*
|
||||
* @param array $unlock An array of options that will be force-unlocked
|
||||
* @return array
|
||||
*/
|
||||
public function panelOptions(array $unlock = []): array
|
||||
{
|
||||
$options = $this->permissions()->toArray();
|
||||
|
||||
if ($this->isLocked()) {
|
||||
foreach ($options as $key => $value) {
|
||||
if (in_array($key, $unlock)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$options[$key] = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Must return the permissions object for the model
|
||||
*
|
||||
* @return \Kirby\Cms\ModelPermissions
|
||||
*/
|
||||
abstract public function permissions();
|
||||
|
||||
/**
|
||||
* Creates a string query, starting from the model
|
||||
*
|
||||
@@ -618,7 +669,7 @@ abstract class ModelWithContent extends Model
|
||||
*
|
||||
* @param array $input
|
||||
* @param string $languageCode
|
||||
* @param boolean $validate
|
||||
* @param bool $validate
|
||||
* @return self
|
||||
*/
|
||||
public function update(array $input = null, string $languageCode = null, bool $validate = false)
|
||||
@@ -657,7 +708,7 @@ abstract class ModelWithContent extends Model
|
||||
* @internal
|
||||
* @param array $data
|
||||
* @param string $languageCode
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function writeContent(array $data, string $languageCode = null): bool
|
||||
{
|
||||
|
Reference in New Issue
Block a user