AdminModel
abstract class AdminModel extends FormModel
Prototype admin model.
Traits
Trait which supports form behavior.
Defines the trait for a FormFactoryInterface Aware Class.
MVCFactory aware trait.
Trait for classes which require a user to work with.
Defines the trait for a CacheControllerFactoryInterface Aware Class.
Trait which supports state behavior
Trait which contains the legacy getInstance functionality
Trait which contains the legacy methods that formerly were inherited from \Joomla\CMS\Object\CMSObject to set and get errors in a class.
Trait which contains the legacy methods that formerly were inherited from \Joomla\CMS\Object\CMSObject to set and get properties of the current class.
Properties
protected bool
Since: 4.0.0
|
$__state_set | Indicates if the internal state has been set |
from StateBehaviorTrait |
protected State
Since: 4.0.0
|
$state | A state object |
from StateBehaviorTrait |
protected array
deprecated
Since: 1.7.0
|
$_errors | An array of error messages or Exception objects. |
from LegacyErrorHandlingTrait |
protected string
Since: 4.0.0
|
$name | The model (base) name |
from BaseModel |
static protected array
Since: 4.0.0
|
$paths | The include paths |
from BaseModel |
protected string
Since: 3.0
|
$option | The URL option for the component. |
from BaseDatabaseModel |
protected string
Since: 3.0
|
$event_clean_cache | The event to trigger when cleaning cache. |
from BaseDatabaseModel |
protected Form[]
Since: 4.0.0
|
$_forms | Array of form objects. |
from FormBehaviorTrait |
protected array
Since: 3.6
|
$events_map | Maps events to plugin groups. |
from FormModel |
string
Since: 3.8.6
|
$typeAlias | The type alias for this content type (for example, 'com_content.article'). |
|
protected string
Since: 1.6
|
$text_prefix | The prefix to use with controller messages. |
|
protected string
Since: 1.6
|
$event_after_delete | The event to trigger after deleting the data. |
|
protected string
Since: 1.6
|
$event_after_save | The event to trigger after saving the data. |
|
protected string
Since: 1.6
|
$event_before_delete | The event to trigger before deleting the data. |
|
protected string
Since: 1.6
|
$event_before_save | The event to trigger before saving the data. |
|
protected string
Since: 4.0.0
|
$event_before_change_state | The event to trigger before changing the published state of the data. |
|
protected string
Since: 1.6
|
$event_change_state | The event to trigger after changing the published state of the data. |
|
protected string
Since: 4.0.0
|
$event_before_batch | The event to trigger before batch. |
|
protected string
Since: 3.4
|
$batch_copymove | Batch copy/move command. If set to false, the batch copy/move command is not supported |
|
protected array
Since: 3.4
|
$batch_commands | Allowed batch commands |
|
protected string
Since: 3.4.4
|
$associationsContext | The context used for the associations table |
|
protected ?bool
Since: 3.8.2
|
$batchSet | A flag to indicate if member variables for batch actions (and saveorder) have been initialized |
|
protected object
Since: 3.8.2
|
$user | The user performing the actions (re-usable in batch methods & saveorder(), initialized via initBatch()) |
|
protected Table
Since: 3.8.2
|
$table | A \Joomla\CMS\Table\Table instance (of appropriate type) to manage the DB records (re-usable in batch methods & saveorder(), initialized via initBatch()) |
|
protected string
Since: 3.8.2
|
$tableClassName | The class name of the \Joomla\CMS\Table\Table instance managing the DB records (re-usable in batch methods & saveorder(), initialized via initBatch()) |
|
protected object
Since: 3.8.2
|
$contentType | UCM Type corresponding to the current model class (re-usable in batch action methods, initialized via initBatch()) |
|
protected object
Since: 3.8.2
|
$type | DB data of UCM Type corresponding to the current model class (re-usable in batch action methods, initialized via initBatch()) |
Methods
Method to get state variables.
Method to set state variables.
Stock method to auto-populate the model state.
Returns a Model object, always creating it
Sets a default value if not already assigned
Returns a property of the object or the default value if the property is not set.
Modifies a property of the object, creating it if it does not already exist.
Constructor.
Add a directory where \JModelLegacy should search for models. You may either pass a string or an array of directories.
Returns the current user, if none is set the identity of the global app is returned. This will change in 6.0 and an empty user will be returned.
Get the CacheControllerFactoryInterface.
Set the cache controller factory to use.
Gets an array of objects from the results of database query.
Returns a record count for the query.
Method to load and return a table object.
Method to get a table object, load it if necessary.
Boots the component with the given name.
Dispatches the given event on the internal dispatcher, does a fallback to the global one.
Method to get a form object.
Method to get the data that should be injected in the form.
Method to allow derived classes to preprocess the data.
Method to allow derived classes to preprocess the form.
Set the form factory to use.
Method override to check-in a record or an array of record
Method override to check-out a record.
Method to perform batch operations on an item or a set of items.
Batch access level changes for a group of rows.
Batch copy items to a new category or current.
Function that can be overridden to do any data cleanup after batch copying data
Batch language changes for a group of rows.
Batch move items to a new category
Method to test whether a record can be deleted.
Method to test whether a record can have its state changed.
Method to delete one or more records.
Method to change the title & alias.
Method to change the published state of one or more records.
Method to adjust the ordering of a row.
Method to save the form data.
Saves the manually set order of records.
Method to check the validity of the category ID for batch copy and move
A method to preprocess generating a new title in order to allow tables with alternative names for alias and title to use the batch move and copy methods
Method to initialize member variables used by batch methods and other methods like saveorder()
Method to load an item in com_associations.
Details
mixed
getState(string $property = null, mixed $default = null)
Method to get state variables.
static protected string
_createFileName(string $type, array $parts = [])
deprecated
deprecated 4.3 will be removed in 6.0 Will be removed without replacement
Create the filename for a resource
static LegacyModelLoaderTrait|bool
getInstance(string $type, string $prefix = '', array $config = [])
deprecated
deprecated 4.3 will be removed in 6.0 Will be removed without replacement. Get the model through the MVCFactory instead Example: Factory::getApplication()->bootComponent('com_xxx')->getMVCFactory()->createModel($type, $prefix, $config);
Returns a Model object, always creating it
static void
addTablePath(mixed $path)
deprecated
deprecated 4.3 will be removed in 6.0 Will be removed without replacement. Get the model through the MVCFactory instead
Adds to the stack of model table paths in LIFO order.
string
getError(int $i = null, bool $toString = true)
deprecated
deprecated 3.1.4 will be removed in 6.0 Will be removed without replacement Catch thrown Exceptions instead of getError
Get the most recent error message.
array
getErrors()
deprecated
deprecated 3.1.4 will be removed in 6.0 Will be removed without replacement Catch thrown Exceptions instead of getErrors
Return all errors, if any.
void
setError(string $error)
deprecated
deprecated 3.1.4 will be removed in 6.0 Will be removed without replacement Throw an Exception instead of using setError
Add an error message.
mixed
def(string $property, mixed $default = null)
deprecated
deprecated 4.3.0 will be removed in 6.0 Defining dynamic properties should not be used anymore
Sets a default value if not already assigned
mixed
get(string $property, mixed $default = null)
deprecated
deprecated 4.3.0 will be removed in 6.0 Create a proper getter function for the property
Returns a property of the object or the default value if the property is not set.
array
getProperties(bool $public = true)
deprecated
deprecated 4.3.0 will be removed in 6.0 Create a proper getter function for the property
Returns an associative array of object properties.
mixed
set(string $property, mixed $value = null)
deprecated
deprecated 4.3.0 will be removed in 6.0 Create a proper setter function for the property
Modifies a property of the object, creating it if it does not already exist.
bool
setProperties(mixed $properties)
deprecated
deprecated 4.3.0 will be removed in 6.0 Create a proper setter function for the property
Set the object properties based on a named array/hash.
__construct(array $config = [], MVCFactoryInterface|null $factory = null, FormFactoryInterface|null $formFactory = null)
Constructor.
static array
addIncludePath(mixed $path = '', string $prefix = '')
deprecated
deprecated 4.3 will be removed in 6.0 Will be removed without replacement. Get the model through the MVCFactory + namespace instead
Add a directory where \JModelLegacy should search for models. You may either pass a string or an array of directories.
string
getName()
Method to get the model name
The model name. By default parsed using the classname or it can be set by passing a $config['name'] in the class constructor
protected User
getCurrentUser()
Returns the current user, if none is set the identity of the global app is returned. This will change in 6.0 and an empty user will be returned.
protected CacheControllerFactoryInterface
getCacheControllerFactory()
Get the CacheControllerFactoryInterface.
void
setCacheControllerFactory(CacheControllerFactoryInterface|null $cacheControllerFactory = null)
Set the cache controller factory to use.
protected object[]
_getList(DatabaseQuery|string $query, int $limitstart = 0, int $limit = 0)
Gets an array of objects from the results of database query.
protected int
_getListCount(DatabaseQuery|string $query)
Returns a record count for the query.
Note: Current implementation of this method assumes that getListQuery() returns a set of unique rows, thus it uses SELECT COUNT(*) to count the rows. In cases that getListQuery() uses DISTINCT then either this method must be overridden by a custom implementation at the derived Model Class or a GROUP BY clause should be used to make the set unique.
protected Table|bool
_createTable(string $name, string $prefix = 'Table', array $config = [])
Method to load and return a table object.
Table
getTable(string $name = '', string $prefix = '', array $options = [])
Method to get a table object, load it if necessary.
bool
isCheckedOut(stdClass $item)
Method to check if the given record is checked out by the current user
protected ComponentInterface
bootComponent(string $component)
Boots the component with the given name.
DispatcherInterface
getDispatcher()
Get the event dispatcher.
The override was made to keep a backward compatibility for legacy component. TODO: Remove the override in 6.0
protected void
dispatchEvent(EventInterface $event)
deprecated
deprecated 4.4 will be removed in 6.0. Use $this->getDispatcher() directly.
Dispatches the given event on the internal dispatcher, does a fallback to the global one.
DatabaseInterface
getDbo()
deprecated
deprecated 4.3 will be removed in 6.0 Use getDatabase() instead Example: $model->getDatabase();
Method to get the database driver object.
void
setDbo(DatabaseInterface|null $db = null)
deprecated
deprecated 4.3 will be removed in 6.0 Use setDatabase() instead Example: $model->setDatabase($db);
Set the database driver.
mixed
__get(string $name)
deprecated
deprecated 4.3 will be removed in 6.0 Use getDatabase() instead of directly accessing _db
Proxy for _db variable.
protected Form
loadForm(string $name, string $source = null, array $options = [], bool $clear = false, string $xpath = null)
Method to get a form object.
protected array
loadFormData()
Method to get the data that should be injected in the form.
protected void
preprocessData(string $context, mixed $data, string $group = 'content')
Method to allow derived classes to preprocess the data.
protected void
preprocessForm(Form $form, mixed $data, string $group = 'content')
Method to allow derived classes to preprocess the form.
$this
setFormFactory(FormFactoryInterface|null $formFactory = null)
Set the form factory to use.
array|bool
validate(Form $form, array $data, string $group = null)
Method to validate the form data.
bool
batch(array $commands, array $pks, array $contexts)
Method to perform batch operations on an item or a set of items.
protected bool
batchAccess(int $value, array $pks, array $contexts)
Batch access level changes for a group of rows.
protected array|bool
batchCopy(int $value, array $pks, array $contexts)
Batch copy items to a new category or current.
protected void
cleanupPostBatchCopy(TableInterface $table, int $newId, int $oldId)
Function that can be overridden to do any data cleanup after batch copying data
protected bool
batchLanguage(string $value, array $pks, array $contexts)
Batch language changes for a group of rows.
protected bool
batchMove(int $value, array $pks, array $contexts)
Batch move items to a new category
protected bool
batchTag(int $value, array $pks, array $contexts)
deprecated
deprecated 5.3 will be removed in 7.0
Batch tag a list of item.
protected bool
canEditState(object $record)
Method to test whether a record can have its state changed.
protected array
generateNewTitle(int $categoryId, string $alias, string $title)
Method to change the title & alias.
protected string[]
getReorderConditions(Table $table)
A protected method to get a set of ordering conditions.
protected void
prepareTable(Table $table)
Prepare and sanitise the table data prior to saving.
bool
publish(array $pks, int $value = 1)
Method to change the published state of one or more records.
bool|null
reorder(int $pks, int $delta = 0)
Method to adjust the ordering of a row.
Returns NULL if the user did not have edit privileges for any of the selected primary keys.
bool
saveorder(array $pks = [], int $order = null)
Saves the manually set order of records.
protected bool
checkCategoryId(int $categoryId)
Method to check the validity of the category ID for batch copy and move
void
generateTitle(int $categoryId, Table $table)
A method to preprocess generating a new title in order to allow tables with alternative names for alias and title to use the batch move and copy methods
void
initBatch()
Method to initialize member variables used by batch methods and other methods like saveorder()